Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
June 2014
- 4 participants
- 14 discussions
Author: sbavencoff
Date: 2014-06-30 09:41:22 +0200 (Mon, 30 Jun 2014)
New Revision: 3834
Url: http://forge.chorem.org/projects/lima/repository/revisions/3834
Log:
refs #557 : Revoir les exceptions techniques et metiers
Added:
trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,6 +25,7 @@
package org.chorem.lima.business;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.Entry;
@@ -48,11 +49,11 @@
* @param account new account
* @throws LimaException if rule validation fails
*/
- void createAccountRules(Account account) throws LimaException;
+ void createAccountRules(Account account) throws InvalidAccountNumberException;
- void updateAccountRules(Account account) throws LimaException;
+ void updateAccountRules(Account account) throws InvalidAccountNumberException;
- void removeAccountRules(Account account) throws LimaException;
+ void removeAccountRules(Account account) throws UsedAccountException;
/**
* Entrybook rules.
@@ -60,7 +61,7 @@
* @param entryBook
* @throws LimaException
*/
- void removeEntryBookRules(EntryBook entryBook) throws LimaException;
+ void removeEntryBookRules(EntryBook entryBook) throws EntryBookException;
/**
* Fiscal Period rules
@@ -68,21 +69,21 @@
* @param fiscalPeriod
* @throws LimaException
*/
- List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
+ List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
- void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
+ void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
- void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
+ void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
/**
* Entry rules
*
* @param entry
- * @throws LimaException
+ * @throws FinancialTransactionException
*/
- void updateEntryRules(Entry entry, Entry entryOld) throws LimaException;
+ void updateEntryRules(Entry entry, Entry entryOld) throws EntryException;
- void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws LimaException;
+ void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws FinancialTransactionException;
/**
* Financialperiod/entrybook rules
@@ -90,7 +91,7 @@
* @param financialTransaction
* @throws LimaException
*/
- void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException;
+ void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException;
/**
* Check if a financial period can be closed.
@@ -98,5 +99,5 @@
* @param closedPeriodicEntryBook
* @throws LimaException
*/
- void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException;
+ void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,6 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaTechnicalException;
import org.chorem.lima.business.accountingrules.FranceAccountingRules;
import org.chorem.lima.business.migration.DatabaseMigrationClass;
import org.chorem.lima.entity.LimaCallaoEntityEnum;
@@ -78,7 +79,7 @@
config.parse();
} catch (ArgumentsParserException ex) {
- throw new LimaException("Can't read configuration", ex);
+ throw new LimaTechnicalException("Can't read configuration", ex);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,9 +29,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.LimaBusinessException;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.EntryBookException;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaInterceptor;
+import org.chorem.lima.business.UsedAccountException;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
@@ -46,13 +51,10 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
import org.chorem.lima.entity.LimaCallaoTopiaDaoSupplier;
-import org.nuiton.topia.persistence.TopiaException;
import java.util.Date;
import java.util.List;
-import static org.nuiton.i18n.I18n.t;
-
;
/**
@@ -82,44 +84,42 @@
* Rules to check before create accounts.
*/
@Override
- public void createAccountRules(Account account) throws LimaException {
+ public void createAccountRules(Account account) throws InvalidAccountNumberException {
// Check if the numberaccount is not blank
if (StringUtils.isBlank(account.getAccountNumber())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.invalidaccountnumber",
- account.getAccountNumber()));
+ throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.defaultaccountingrules.invalidaccountnumber");
}
}
@Override
- public void updateAccountRules(Account account) throws LimaException {
+ public void updateAccountRules(Account account) throws InvalidAccountNumberException {
// Check if the numberaccount is not blank
if (StringUtils.isBlank(account.getAccountNumber())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.invalidaccountnumber",
- account.getAccountNumber()));
+ throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.defaultaccountingrules.invalidaccountnumber");
}
}
/** Rules to check before create fiscals periods */
@Override
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
//check if the enddate period is after the begindate period
if (fiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.enddateerror"));
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.defaultaccountingrules.enddateerror");
}
return null;
}
/** Rules to check before block fiscals periods */
@Override
- public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException{
}
/** Rules to check before delete fiscals periods */
@Override
public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod)
- throws LimaException {
+ throws FiscalPeriodException {
}
/**
@@ -127,32 +127,24 @@
* Recursive function
*/
@Override
- public void removeAccountRules(Account account) throws LimaException {
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- // Check if account have entries
- int nbentries = entryTopiaDao.findAllByAccount(account).size();
- if (nbentries != 0) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.deleteaccounterror"));
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't remvoe account", ex);
+ public void removeAccountRules(Account account) throws UsedAccountException {
+
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ // Check if account have entries
+ if (entryTopiaDao.forAccountEquals(account).exists()) {
+ throw new UsedAccountException(account.getAccountNumber(), "lima-business.defaultaccountingrules.deleteaccounterror");
}
}
/** Check if entrybook have financial transaction */
@Override
- public void removeEntryBookRules(EntryBook entryBook) throws LimaException {
- try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ public void removeEntryBookRules(EntryBook entryBook) throws EntryBookException {
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- // Check if entrybook have entries
- long nbfinancialtransaction = financialTransactionTopiaDao.getCountByEntryBook(entryBook);
- if (nbfinancialtransaction != 0) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.deleteentrybookerror"));
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ // Check if entrybook have entries
+ long nbfinancialtransaction = financialTransactionTopiaDao.getCountByEntryBook(entryBook);
+ if (nbfinancialtransaction != 0) {
+ throw new EntryBookException(entryBook, "lima-business.defaultaccountingrules.deleteentrybookerror");
}
}
@@ -162,29 +154,28 @@
* check if all entrybook of his financial period are blocked
*/
@Override
- public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
+ public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException {
- try {
- //check financial period locked
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
- if (financialPeriod.isLocked()) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.financialperiodblocked"));
- }
-
- //check all entrybook of his financial period are blocked
- //FIXME echatellier 20120509 il doit y avoir moyen de faire plus
- //simple que de recuperer 2 listes et de comparer leur nombres
+ //check financial period locked
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
+ if (financialPeriod.isLocked()) {
+ throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.financialperiodblocked");
+ }
+
+ //check all entrybook of his financial period are blocked
+ //FIXME echatellier 20120509 il doit y avoir moyen de faire plus
+ //simple que de recuperer 2 listes et de comparer leur nombres
// List<EntryBook> closedEntryBooks = new ArrayList<EntryBook>();
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
// List<EntryBook> entryBooks = entryBookTopiaDao.findAll();
- // The following code should do the work but i'm not 100% sure.
- long nbEntryBooksClosed = closedPeriodicEntryBookTopiaDao.forProperties(
- ClosedPeriodicEntryBook.PROPERTY_LOCKED, true,
- ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod).addNotNull(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK).count();
+ // The following code should do the work but i'm not 100% sure.
+ long nbEntryBooksClosed = closedPeriodicEntryBookTopiaDao.forProperties(
+ ClosedPeriodicEntryBook.PROPERTY_LOCKED, true,
+ ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod).addNotNull(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK).count();
// for (EntryBook entryBook : entryBooks) {
// ClosedPeriodicEntryBook closedPeriodicEntryBook =
@@ -195,12 +186,9 @@
// }
// }
- long nbEntryBooks = entryBookTopiaDao.count();
- if (nbEntryBooks == nbEntryBooksClosed) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.allentrybookclosed"));
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ long nbEntryBooks = entryBookTopiaDao.count();
+ if (nbEntryBooks == nbEntryBooksClosed) {
+ throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.allentrybookclosed");
}
}
@@ -211,42 +199,37 @@
*/
@Override
public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook)
- throws LimaException {
+ throws ClosedPeriodicEntryBookException {
- try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- EntryTopiaDao entryDao = getDaoHelper().getEntryDao();
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- // reload object in current transaction
- closedPeriodicEntryBook = closedPeriodicEntryBookTopiaDao.findByTopiaId(closedPeriodicEntryBook.getTopiaId());
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ EntryTopiaDao entryDao = getDaoHelper().getEntryDao();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ // reload object in current transaction
+ closedPeriodicEntryBook = closedPeriodicEntryBookTopiaDao.findByTopiaId(closedPeriodicEntryBook.getTopiaId());
- // Check if all financial transactions of closedperiodicentrybook are equilibrate
- FinancialPeriod period = closedPeriodicEntryBook.getFinancialPeriod();
- if (financialTransactionTopiaDao.isExistUnbalancedTransaction(
- period.getBeginDate(),
- period.getEndDate(),
- closedPeriodicEntryBook.getEntryBook())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.blockerrorequillibrate"));
- }
-
- // Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in
- if (entryDao.isExistUnfilledEntry(
- period.getBeginDate(),
- period.getEndDate(),
- closedPeriodicEntryBook.getEntryBook())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.missingelements"));
- }
-
- // Check if all financial transactions have EntryBooks
- if (financialTransactionTopiaDao.isExistTransactionWithoutEntryBook(
- period.getBeginDate(),
- period.getEndDate())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.missingentrybook"));
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ // Check if all financial transactions of closedperiodicentrybook are equilibrate
+ FinancialPeriod period = closedPeriodicEntryBook.getFinancialPeriod();
+ if (financialTransactionTopiaDao.isExistUnbalancedTransaction(
+ period.getBeginDate(),
+ period.getEndDate(),
+ closedPeriodicEntryBook.getEntryBook())) {
+ throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.defaultaccountingrules.blockerrorequillibrate");
}
+
+ // Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in
+ if (entryDao.isExistUnfilledEntry(
+ period.getBeginDate(),
+ period.getEndDate(),
+ closedPeriodicEntryBook.getEntryBook())) {
+ throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.defaultaccountingrules.missingelements");
+ }
+
+ // Check if all financial transactions have EntryBooks
+ if (financialTransactionTopiaDao.isExistTransactionWithoutEntryBook(
+ period.getBeginDate(),
+ period.getEndDate())) {
+ throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.defaultaccountingrules.missingentrybook");
+ }
}
/**
@@ -257,37 +240,31 @@
* - third, the new choice entrybook belong to a blocked closedPeriodicEntryBook
*/
@Override
- public void updateEntryRules(Entry entry, Entry entryOld) throws LimaException {
+ public void updateEntryRules(Entry entry, Entry entryOld) throws EntryException {
- try {
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(entry.getFinancialTransaction().getTransactionDate());
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(entry.getFinancialTransaction().getTransactionDate());
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
-
- if (entryOld != null) {
- //second case
- ClosedPeriodicEntryBook closedPeriodicEntryBook =
- closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(
- entryOld.getFinancialTransaction().getEntryBook(), financialPeriod);
- if (closedPeriodicEntryBook.isLocked()) {
- throw new LimaBusinessException(t("lima-Business.defaultaccountingrules.updateentryerror"));
- }
- }
-
- //third case
- ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
+ if (entryOld != null) {
+ //second case
+ ClosedPeriodicEntryBook closedPeriodicEntryBook =
closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(
- entry.getFinancialTransaction().getEntryBook(), financialPeriod);
-
- // Check 2 & 3 cases
- if (closedPeriodicEntryBook2.isLocked()) {
- throw new LimaBusinessException(t("lima-Business.defaultaccountingrules.updateentryerror"));
+ entryOld.getFinancialTransaction().getEntryBook(), financialPeriod);
+ if (closedPeriodicEntryBook.isLocked()) {
+ throw new EntryException(entryOld, "lima-Business.defaultaccountingrules.updateentryerror");
}
+ }
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ //third case
+ ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
+ closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(
+ entry.getFinancialTransaction().getEntryBook(), financialPeriod);
+
+ // Check 2 & 3 cases
+ if (closedPeriodicEntryBook2.isLocked()) {
+ throw new EntryException(entry, "lima-Business.defaultaccountingrules.updateentryerror");
}
}
@@ -300,65 +277,59 @@
*/
@Override
public void updateFinancialTransactionDateRules(
- FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws LimaException {
+ FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws FinancialTransactionException {
- try {
-
- Date financialTransactionDate = financialTransaction.getTransactionDate();
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FiscalPeriod lastFiscalPeriod = fiscalPeriodTopiaDao.getLastFiscalPeriod();
- FiscalPeriod firstFiscalPeriod = fiscalPeriodTopiaDao.getFirstFiscalPeriod();
- Date beginDateFirstFiscalPeriod = firstFiscalPeriod.getBeginDate();
- Date endDateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
-
- //check if date are on fiscal period (test if date is after begindate of first f.p. and before enddate of last f.p.)
-
- if (log.isDebugEnabled()) {
- log.debug("Date de transaction modifiée sur l'ui " + financialTransactionDate);
- log.debug("Date de début du premier exercice : " + beginDateFirstFiscalPeriod);
- log.debug("Date de fin du dernier exercice : " + endDateLastFiscalPeriod);
- }
-
- //1-date not on a fiscal period
- if (financialTransactionDate.before(beginDateFirstFiscalPeriod) || financialTransactionDate.after(endDateLastFiscalPeriod)){
- if (financialTransactionDate.before(beginDateFirstFiscalPeriod)) {
- if (log.isDebugEnabled()) {
- log.debug("Date de la transaction avant (antérieure) la date de début du premier exercice");
- }
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.datebeforeerror"));
+ Date financialTransactionDate = financialTransaction.getTransactionDate();
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ FiscalPeriod lastFiscalPeriod = fiscalPeriodTopiaDao.getLastFiscalPeriod();
+ FiscalPeriod firstFiscalPeriod = fiscalPeriodTopiaDao.getFirstFiscalPeriod();
+ Date beginDateFirstFiscalPeriod = firstFiscalPeriod.getBeginDate();
+ Date endDateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
+
+ //check if date are on fiscal period (test if date is after begindate of first f.p. and before enddate of last f.p.)
+
+ if (log.isDebugEnabled()) {
+ log.debug("Date de transaction modifiée sur l'ui " + financialTransactionDate);
+ log.debug("Date de début du premier exercice : " + beginDateFirstFiscalPeriod);
+ log.debug("Date de fin du dernier exercice : " + endDateLastFiscalPeriod);
+ }
+
+ //1-date not on a fiscal period
+ if (financialTransactionDate.before(beginDateFirstFiscalPeriod) || financialTransactionDate.after(endDateLastFiscalPeriod)){
+ if (financialTransactionDate.before(beginDateFirstFiscalPeriod)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Date de la transaction avant (antérieure) la date de début du premier exercice");
}
-
- if (financialTransactionDate.after(endDateLastFiscalPeriod)) {
- if (log.isDebugEnabled()) {
- log.debug("Date de la transaction après (postérieure) la date de fin du dernier exercice");
- }
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.dateaftererror"));
+ throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.datebeforeerror");
+ }
+
+ if (financialTransactionDate.after(endDateLastFiscalPeriod)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Date de la transaction après (postérieure) la date de fin du dernier exercice");
}
- }else{ //date on a fiscal period (and consequently on a financial), now test if financial is open
-
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
- FinancialPeriod financialPeriodOld = financialPeriodTopiaDao.findByDate(financialTransactionOld.getTransactionDate());
-
- //2. check old financial period locked
- if (financialPeriodOld.isLocked()) {
- if (log.isDebugEnabled()) {
- log.debug("Periode (Old) financière bloquée");
- }
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.financialtransactionblocked"));
+ throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.dateaftererror");
+ }
+ }else{ //date on a fiscal period (and consequently on a financial), now test if financial is open
+
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
+ FinancialPeriod financialPeriodOld = financialPeriodTopiaDao.findByDate(financialTransactionOld.getTransactionDate());
+
+ //2. check old financial period locked
+ if (financialPeriodOld.isLocked()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Periode (Old) financière bloquée");
}
-
- //3. check new financial period locked
- if (financialPeriod.isLocked()) {
- if (log.isDebugEnabled()) {
- log.debug("Periode (New) financière bloquée");
- }
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.financialnewdateblocked"));
+ throw new FinancialTransactionException(financialTransactionOld, "lima-business.defaultaccountingrules.financialtransactionblocked");
+ }
+
+ //3. check new financial period locked
+ if (financialPeriod.isLocked()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Periode (New) financière bloquée");
}
+ throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.financialnewdateblocked");
}
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't check financial transaction", ex);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,8 +29,10 @@
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaBusinessException;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.InvalidAccountNumberException;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
+import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.EntryBook;
@@ -39,10 +41,7 @@
import org.chorem.lima.entity.FinancialTransactionTopiaDao;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
-import org.chorem.lima.entity.Account;
-
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -63,7 +62,7 @@
* Règles de vérification de la création du PCG, appliquées à la comptabilité française.
*/
@Override
- public void createAccountRules(Account account) throws LimaException {
+ public void createAccountRules(Account account) throws InvalidAccountNumberException {
super.createAccountRules(account);
String accountNumber = account.getAccountNumber();
@@ -76,28 +75,25 @@
// Check root account starts with 1 to 8
if (accountNumber.length() >= 1 && !accountNumber.substring(0, 1).matches("[1-8]")) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.accountstartnumbererror",
- account.getAccountNumber()));
+ throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.franceaccountingrules.accountstartnumbererror");
}
}
@Override
- public void updateAccountRules(Account account) throws LimaException {
+ public void updateAccountRules(Account account) throws InvalidAccountNumberException {
super.updateAccountRules(account);
String accountNumber = account.getAccountNumber();
// Check if the number account is type numeric
if (!StringUtils.isNumeric(account.getAccountNumber())) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.accountnumbernotnumeric",
- account.getAccountNumber()));
+ throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.franceaccountingrules.accountnumbernotnumeric");
}
// Check root account starts with 1 to 8
if (accountNumber.length() >= 1 && !accountNumber.substring(0, 1).matches("[1-8]")) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.accountstartnumbererror",
- account.getAccountNumber()));
+ throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.franceaccountingrules.accountstartnumbererror");
}
}
@@ -115,61 +111,58 @@
* Pas plus de deux exercices fiscaux ne peuvent-être ouvert en même temps
*/
@Override
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
super.createFiscalPeriodRules(fiscalPeriod);
List<FinancialPeriod> financialPeriods = new ArrayList<FinancialPeriod>();
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- //Checks if is not the first fiscalperiod to create
- if (fiscalPeriodTopiaDao.count() != 0) {
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FiscalPeriod lastFiscalPeriod = fiscalPeriodTopiaDao.getLastFiscalPeriod();
+ //Checks if is not the first fiscalperiod to create
+ if (fiscalPeriodTopiaDao.count() != 0) {
- //check the new fiscal period adjoining the last
- Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
- dateLastFiscalPeriod = DateUtils.
- addDays(dateLastFiscalPeriod, 1);
- dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
- Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
-
- if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.newfiscalperiodadjoiningerror"));
- }
+ FiscalPeriod lastFiscalPeriod = fiscalPeriodTopiaDao.getLastFiscalPeriod();
- //We can create a new fiscal period meantime the last fiscal period was not locked
- //But not the ante periodfiscal
- int unblockedFiscalPeriod =
- fiscalPeriodTopiaDao.findAllByLocked(false).size();
- if (unblockedFiscalPeriod > 1) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.antefiscalperiodnotblocked"));
- }
+ //check the new fiscal period adjoining the last
+ Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
+ dateLastFiscalPeriod = DateUtils.
+ addDays(dateLastFiscalPeriod, 1);
+ dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
+ Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
+
+ if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.newfiscalperiodadjoiningerror");
}
- // FinancialPeriods of 1 month are created
- Date endDate = fiscalPeriod.getEndDate();
- Date loopDate = fiscalPeriod.getBeginDate();
- while (loopDate.before(endDate)) {
- FinancialPeriod financialPeriod = new FinancialPeriodImpl();
- //important for fiscalperiod created from import, it can be locked, so financialperiods must be locked
- financialPeriod.setLocked(fiscalPeriod.isLocked());
- financialPeriod.setBeginDate(loopDate);
- loopDate = DateUtils.addMonths(loopDate, 1);
- loopDate = DateUtils.truncate(loopDate, Calendar.MONTH);
- loopDate = DateUtils.addMilliseconds(loopDate, -1);
- if (loopDate.after(endDate)) {
- financialPeriod.setEndDate(endDate);
- } else {
- financialPeriod.setEndDate(loopDate);
- }
- //create it
- financialPeriods.add(financialPeriod);
+ //We can create a new fiscal period meantime the last fiscal period was not locked
+ //But not the ante periodfiscal
+ int unblockedFiscalPeriod =
+ fiscalPeriodTopiaDao.findAllByLocked(false).size();
+ if (unblockedFiscalPeriod > 1) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.antefiscalperiodnotblocked");
+ }
+ }
- //loop incremente
- loopDate = DateUtils.addMilliseconds(loopDate, 1);
+ // FinancialPeriods of 1 month are created
+ Date endDate = fiscalPeriod.getEndDate();
+ Date loopDate = fiscalPeriod.getBeginDate();
+ while (loopDate.before(endDate)) {
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ //important for fiscalperiod created from import, it can be locked, so financialperiods must be locked
+ financialPeriod.setLocked(fiscalPeriod.isLocked());
+ financialPeriod.setBeginDate(loopDate);
+ loopDate = DateUtils.addMonths(loopDate, 1);
+ loopDate = DateUtils.truncate(loopDate, Calendar.MONTH);
+ loopDate = DateUtils.addMilliseconds(loopDate, -1);
+ if (loopDate.after(endDate)) {
+ financialPeriod.setEndDate(endDate);
+ } else {
+ financialPeriod.setEndDate(loopDate);
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ //create it
+ financialPeriods.add(financialPeriod);
+
+ //loop incremente
+ loopDate = DateUtils.addMilliseconds(loopDate, 1);
}
return financialPeriods;
}
@@ -180,19 +173,15 @@
* On ne peut pas clore la dernière periode comptable ouverte.
*/
@Override
- public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FiscalPeriod oldestUnBlockedFiscalPeriod =
- fiscalPeriodTopiaDao.getLastUnlockedFiscalPeriod();
+ FiscalPeriod oldestUnBlockedFiscalPeriod =
+ fiscalPeriodTopiaDao.getLastUnlockedFiscalPeriod();
- //Check if the fiscal period to block is the oldest
- if (oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked"));
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ //Check if the fiscal period to block is the oldest
+ if (oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked");
}
}
@@ -202,19 +191,14 @@
* On ne peut supprimer qu'une periode comptable ouverte vide.
*/
@Override
- public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaBusinessException {
+ public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
- try {
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
-
- //Check if the fiscal period to delete is empty
- if (financialTransactionTopiaDao.findAllByDates(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()).size() != 0) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.fiscalperiodnotempty"));
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
- }
+ //Check if the fiscal period to delete is empty
+ if (financialTransactionTopiaDao.findAllByDates(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()).size() != 0) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.fiscalperiodnotempty");
+ }
}
/**
@@ -233,48 +217,42 @@
* qu'il reste des ClosedPeriodicEntryBook non clos ?
*/
@Override
- public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
+ public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException {
super.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
FinancialPeriod financialPeriod = closedPeriodicEntryBook.getFinancialPeriod();
- try {
+ // Get all closedperiod between for the period and entrybook
+ Date endDate = closedPeriodicEntryBook.getFinancialPeriod().getBeginDate();
+ // FIXME echatellier 20120502 c'est pas un hack ca ?
+ // un period peut ne pas durer un mois
+ endDate = DateUtils.addMonths(endDate, -1);
- // Get all closedperiod between for the period and entrybook
- Date endDate = closedPeriodicEntryBook.getFinancialPeriod().getBeginDate();
- // FIXME echatellier 20120502 c'est pas un hack ca ?
- // un period peut ne pas durer un mois
- endDate = DateUtils.addMonths(endDate, -1);
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ //search fiscalperiod have financialperiod
+ FiscalPeriod fiscalPeriod = fiscalPeriodTopiaDao.findByFinancialPeriod(financialPeriod);
+ Date beginDate = fiscalPeriod.getBeginDate();
+ // FIXME echatellier 20120502 quels est la rapport entre beginDate
+ // et endDate ? il ne provienent pas du même endroit
+ EntryBook entryBook = closedPeriodicEntryBook.getEntryBook();
- //search fiscalperiod have financialperiod
- FiscalPeriod fiscalPeriod = fiscalPeriodTopiaDao.findByFinancialPeriod(financialPeriod);
- Date beginDate = fiscalPeriod.getBeginDate();
- // FIXME echatellier 20120502 quels est la rapport entre beginDate
- // et endDate ? il ne provienent pas du même endroit
- EntryBook entryBook = closedPeriodicEntryBook.getEntryBook();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
+ closedPeriodicEntryBookTopiaDao.findAllByEntryBookAndDates(entryBook, beginDate, endDate);
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
- closedPeriodicEntryBookTopiaDao.findAllByEntryBookAndDates(entryBook, beginDate, endDate);
+ // FIXME echatellier 20120504 juste un count suffit
+ int nbClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size();
- // FIXME echatellier 20120504 juste un count suffit
- int nbClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size();
+ // Get all closed between for the period, entrybook and are blocked
+ closedPeriodicEntryBooks = closedPeriodicEntryBookTopiaDao.findAllByEntryBookAndDatesLocked(entryBook, beginDate, endDate);
+ int nbBlockedClosedPeriodicEntryBooks =
+ closedPeriodicEntryBooks.size();
- // Get all closed between for the period, entrybook and are blocked
- closedPeriodicEntryBooks = closedPeriodicEntryBookTopiaDao.findAllByEntryBookAndDatesLocked(entryBook, beginDate, endDate);
- int nbBlockedClosedPeriodicEntryBooks =
- closedPeriodicEntryBooks.size();
-
- //Check if the fiscal period to block is the oldest
- if (nbClosedPeriodicEntryBooks != nbBlockedClosedPeriodicEntryBooks) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook"));
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ //Check if the fiscal period to block is the oldest
+ if (nbClosedPeriodicEntryBooks != nbBlockedClosedPeriodicEntryBooks) {
+ throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook");
}
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,30 +25,29 @@
package org.chorem.lima.business.ejb;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
-import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang.StringUtils;
+import org.chorem.lima.business.AccountException;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.AlreadyExistAccountException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.UsedAccountException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
/**
* Permet d'implémenter le Plan Comptable Général.
* Un compte ne peut être supprimé si il contient des écritures comptables.
@@ -63,15 +62,9 @@
public class AccountServiceImpl extends AbstractLimaService implements AccountService {
@Override
- public long getAccountCount() throws LimaException {
- long result;
-
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- result = AccountTopiaDao.count();
- } catch (TopiaException ex) {
- throw new LimaException("Can't count", ex);
- }
+ public long getAccountCount() {
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ long result = AccountTopiaDao.count();
return result;
}
@@ -83,66 +76,48 @@
* @throws LimaException
*/
@Override
- public Account createAccount(Account account) throws LimaException {
+ public Account createAccount(Account account) throws AccountException {
// check rules before create the account
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
accountingRules.createAccountRules(account);
- Account result;
+ // force uppercase account number
+ account.setAccountNumber(account.getAccountNumber().toUpperCase().trim());
- try {
- // force uppercase account number
- account.setAccountNumber(account.getAccountNumber().toUpperCase().trim());
+ // check if account number already exist
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- // check if account number already exist
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
-
- if (AccountTopiaDao.existByNaturalId(account.getAccountNumber())) {
- throw new LimaBusinessException(
- t("lima-business.account.accountalreardyexist",
- account.getAccountNumber()));
- }
-
- //create it
- result = AccountTopiaDao.create(account);
- } catch (TopiaException ex) {
- throw new LimaException("Can't create account", ex);
+ if (AccountTopiaDao.existByNaturalId(account.getAccountNumber())) {
+ throw new AlreadyExistAccountException(account.getAccountNumber(), "lima-business.account.accountalreardyexist");
}
+
+ //create it
+ Account result = AccountTopiaDao.create(account);
return result;
}
@Override
- public Account getMasterAccount(String accountNumber) throws LimaException {
+ public Account getMasterAccount(String accountNumber) {
Account account = null;
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- while (account == null && accountNumber.length() > 1) {
+ while (account == null && accountNumber.length() > 1) {
- accountNumber = accountNumber.substring(0);
- account = AccountTopiaDao.forAccountNumberEquals(accountNumber).findUniqueOrNull();
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't get master account", ex);
+ accountNumber = accountNumber.substring(0);
+ account = AccountTopiaDao.forAccountNumberEquals(accountNumber).findUniqueOrNull();
}
return account;
}
/** Permet d'obtenir un compte suivant son numero */
@Override
- public Account getAccountByNumber(String accountNumber) throws LimaException {
+ public Account getAccountByNumber(String accountNumber) {
- Account account;
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- account = AccountTopiaDao.forAccountNumberEquals(accountNumber).findUniqueOrNull();
- } catch (Exception ex) {
- throw new LimaException("Can't get master account", ex);
- }
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ Account account = AccountTopiaDao.forAccountNumberEquals(accountNumber).findUniqueOrNull();
return account;
}
@@ -150,18 +125,11 @@
/** Permet d'obtenir tous les comptes. */
@Override
- public List<Account> getAllAccounts() throws LimaException {
+ public List<Account> getAllAccounts() {
- List<Account> accountsList;
-
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- accountsList = AccountTopiaDao.findAll();
- Collections.sort(accountsList, new AccountComparator());
-
- } catch (Exception ex) {
- throw new LimaException("Can't get all accounts", ex);
- }
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ List<Account> accountsList = AccountTopiaDao.findAll();
+ Collections.sort(accountsList, new AccountComparator());
return accountsList;
}
@@ -169,17 +137,11 @@
/** Permet d'obtenir tout les comptes feuilles */
@Override
- public List<Account> getAllLeafAccounts() throws LimaException {
+ public List<Account> getAllLeafAccounts() {
- List<Account> accountsList;
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ List<Account> accountsList = AccountTopiaDao.findAllLeafAccounts();
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- accountsList = AccountTopiaDao.findAllLeafAccounts();
- } catch (Exception ex) {
- throw new LimaException("Can't get all leaf accounts", ex);
- }
-
return accountsList;
}
@@ -187,16 +149,10 @@
* @see org.chorem.lima.business.api.AccountService#getAllSubAccounts(org.chorem.lima.entity.Account)
*/
@Override
- public List<Account> getAllSubAccounts(Account account)
- throws LimaException {
- List<Account> accountsList;
+ public List<Account> getAllSubAccounts(Account account) {
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- accountsList = AccountTopiaDao.findAllSubAccounts(account);
- } catch (Exception ex) {
- throw new LimaException("Can't get all sub accounts", ex);
- }
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ List<Account> accountsList = AccountTopiaDao.findAllSubAccounts(account);
return accountsList;
}
@@ -211,23 +167,17 @@
* @throws LimaException
*/
@Override
- public void removeAccount(Account account) throws LimaException {
+ public void removeAccount(Account account) throws UsedAccountException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- try {
+ // Check rules for account if have entries
+ accountingRules.removeAccountRules(account);
- // Check rules for account if have entries
- accountingRules.removeAccountRules(account);
-
- // remove account
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- Account accountToDelete = AccountTopiaDao.findByTopiaId(account.getTopiaId());
- AccountTopiaDao.delete(accountToDelete);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't remove account", ex);
- }
+ // remove account
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ Account accountToDelete = AccountTopiaDao.findByTopiaId(account.getTopiaId());
+ AccountTopiaDao.delete(accountToDelete);
}
/**
@@ -240,26 +190,20 @@
* @throws LimaException
*/
@Override
- public Account updateAccount(Account account) throws LimaException {
+ public Account updateAccount(Account account) throws InvalidAccountNumberException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- Account result;
- try {
- // DAO
- AccountTopiaDao accountDao = getDaoHelper().getAccountDao();
- accountingRules.updateAccountRules(account);
- result = accountDao.update(account);
+ // DAO
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ accountingRules.updateAccountRules(account);
+ Account result = AccountTopiaDao.update(account);
- } catch (Exception ex) {
- throw new LimaException("Can't update account", ex);
- }
-
return result;
}
@Override
- public List<Account> stringToListAccounts(String selectedAccounts) throws TopiaException {
+ public List<Account> stringToListAccounts(String selectedAccounts) {
Set<Account> accounts = new HashSet<Account>();
if (selectedAccounts != null) {
AccountTopiaDao accountDao = getDaoHelper().getAccountDao();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,13 +24,11 @@
* #L%
*/
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.ClosedPeriodicEntryBookService;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.Remote;
import javax.ejb.Stateless;
@@ -45,13 +43,10 @@
public class ClosedPeriodicEntryBookServiceImpl extends AbstractLimaService implements ClosedPeriodicEntryBookService {
@Override
public ClosedPeriodicEntryBook getByEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) {
- ClosedPeriodicEntryBook result;
- try {
- ClosedPeriodicEntryBookTopiaDao accountTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- result = accountTopiaDao.findByEntryBookAndFinancialPeriod(entryBook, financialPeriod);
- } catch (TopiaException e) {
- throw new LimaException("Can't find closed period entry book", e);
- }
+
+ ClosedPeriodicEntryBookTopiaDao accountTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ ClosedPeriodicEntryBook result = accountTopiaDao.findByEntryBookAndFinancialPeriod(entryBook, financialPeriod);
+
return result;
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -31,13 +31,13 @@
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.examples.fdf.SetField;
import org.apache.pdfbox.pdmodel.PDDocument;
+import org.chorem.lima.LimaTechnicalException;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.FinancialStatementAmounts;
import org.chorem.lima.beans.GeneralEntryBooksDatas;
import org.chorem.lima.beans.GeneralEntryBooksDatasImpl;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.DocumentService;
import org.chorem.lima.business.api.FinancialStatementService;
import org.chorem.lima.business.api.IdentityService;
@@ -56,7 +56,6 @@
import org.chorem.lima.entity.FinancialPeriodTopiaDao;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.VatStatement;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.EJB;
import javax.ejb.Remote;
@@ -111,7 +110,7 @@
@Override
public String createFinancialStatementsDocuments(Date beginDate,
- Date endDate) throws LimaException {
+ Date endDate) {
List<FinancialStatementAmounts> financialStatementAmounts =
financialStatementService.financialStatementReport(beginDate, endDate);
@@ -244,7 +243,7 @@
"</html>";
} catch (Exception ex) {
- log.error("Can't create document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
return financialReport;
}
@@ -252,7 +251,7 @@
//############## Ledger ##############
@Override
public String createLedgerDocuments(Date beginDate,
- Date endDate) throws LimaException {
+ Date endDate) {
List<Object> list = new ArrayList<Object>();
String ledgerReport = constructHtmlHeader(t("lima-business.document.ledger"));
@@ -381,7 +380,7 @@
ledgerReport += "</tbody></table></body>\n</html>";
} catch (Exception ex) {
- log.error("Can't create document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
}
return ledgerReport;
@@ -389,7 +388,7 @@
@Override
public String createEntryBooksDocuments(Date beginDate,
- Date endDate) throws LimaException {
+ Date endDate) {
String entryBookReport;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMMM yyyy");
try {
@@ -478,7 +477,7 @@
entryBookReport += "</body>\n</html>";
}
} catch (Exception ex) {
- throw new LimaException("Can't create document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
return entryBookReport;
@@ -488,7 +487,7 @@
@Override
public String createBalanceDocuments(Date beginDate,
- Date endDate) throws LimaException {
+ Date endDate) {
BalanceTrial balanceTrial =
reportService.generateBalanceTrial(beginDate, endDate, null, false, true);
@@ -554,7 +553,7 @@
balanceReport += "</body>\n</html>";
} catch (Exception ex) {
- log.error("Can't create document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
}
@@ -566,7 +565,7 @@
@Override
public String createGeneralEntryBooksDocuments(Date beginDate,
- Date endDate) throws LimaException {
+ Date endDate) {
String entryBookReport;
try {
@@ -707,7 +706,7 @@
"</body>\n</html>";
}
} catch (Exception ex) {
- throw new LimaException("Can't generate document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
return entryBookReport;
}
@@ -717,7 +716,7 @@
@Override
public void createVatDocuments(Date beginDate,
Date endDate,
- String autocomplete) throws LimaException {
+ String autocomplete) {
String filePath = path + File.separator
+ DocumentsEnum.VAT.getFileName() + ".pdf";
@@ -736,14 +735,14 @@
reportsStream = DocumentServiceImpl.class
.getResourceAsStream("/reports/vat_form_fr.pdf");
if (reportsStream == null) {
- throw new LimaException("Could not find such file "
+ throw new LimaTechnicalException("Could not find such file "
+ "/reports/vat_form_fr.pdf");
}
} else {
try {
reportsStream = new FileInputStream(filePathDefault);
} catch (FileNotFoundException eee) {
- throw new LimaException("Could not find such file "
+ throw new LimaTechnicalException("Could not find such file "
+ filePathDefault, eee);
}
}
@@ -785,12 +784,12 @@
doc.close();
} catch (Exception ex) {
- throw new LimaException("Can't create document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
}
@Override
- public String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException {
+ public String createAccountDocument(Date beginDate, Date endDate, String account) {
String accountReport = null;
@@ -856,11 +855,9 @@
accountReport += "</html>";
- }catch (TopiaException e) {
- log.error("Can't find object", e);
}
catch (Exception e) {
- throw new LimaException("Can't create document", e);
+ throw new LimaTechnicalException("Can't create document", e);
}
return accountReport;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,23 +26,20 @@
package org.chorem.lima.business.ejb;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.EntryBookException;
import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
+import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookTopiaDao;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
-
import java.util.List;
import static org.nuiton.i18n.I18n.t;
@@ -59,140 +56,106 @@
public class EntryBookServiceImpl extends AbstractLimaService implements EntryBookService {
@Override
- public EntryBook createEntryBook(EntryBook entryBook)
- throws LimaException {
+ public EntryBook createEntryBook(EntryBook entryBook) {
- EntryBook result = null;
- try {
+ // check if entrybook with is name already exist
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ EntryBook result = entryBookTopiaDao.forCodeEquals(entryBook.getCode()).findUniqueOrNull();
+ if (result != null) {
+ log.error(
+ t("lima-business.entrybook.entrybookalreadyexist",
+ entryBook.getCode()));
+ } else {
+ // creation du EntryBook
+ result = entryBookTopiaDao.create(entryBook);
- // check if entrybook with is name already exist
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- result = entryBookTopiaDao.forCodeEquals(entryBook.getCode()).findUniqueOrNull();
- if (result != null) {
- log.error(
- t("lima-business.entrybook.entrybookalreadyexist",
- entryBook.getCode()));
- } else {
- // creation du EntryBook
- result = entryBookTopiaDao.create(entryBook);
+ //create ClosedPeriodicEntryBook for all unblocked financial period
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
+ getDaoHelper().getClosedPeriodicEntryBookDao();
+ FinancialPeriodTopiaDao financialPeriodTopiaDao =
+ getDaoHelper().getFinancialPeriodDao();
+ // for all unblocked financialperiod
+ List<FinancialPeriod> financialPeriods = financialPeriodTopiaDao.forProperties(FinancialPeriod.PROPERTY_LOCKED, true).findAll();
+ for (FinancialPeriod financialPeriod : financialPeriods) {
- //create ClosedPeriodicEntryBook for all unblocked financial period
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
- getDaoHelper().getClosedPeriodicEntryBookDao();
- FinancialPeriodTopiaDao financialPeriodTopiaDao =
- getDaoHelper().getFinancialPeriodDao();
- // for all unblocked financialperiod
- List<FinancialPeriod> financialPeriods = financialPeriodTopiaDao.forProperties(FinancialPeriod.PROPERTY_LOCKED, true).findAll();
- for (FinancialPeriod financialPeriod : financialPeriods) {
-
- //new closed periodic entrybook
- ClosedPeriodicEntryBook closedPeriodicEntryBook =
- new ClosedPeriodicEntryBookImpl();
- // set entrybook
- closedPeriodicEntryBook.setEntryBook(entryBook);
- // set financial period
- closedPeriodicEntryBook.setFinancialPeriod(financialPeriod);
- // create it
- closedPeriodicEntryBookTopiaDao.create(closedPeriodicEntryBook);
- }
+ //new closed periodic entrybook
+ ClosedPeriodicEntryBook closedPeriodicEntryBook =
+ new ClosedPeriodicEntryBookImpl();
+ // set entrybook
+ closedPeriodicEntryBook.setEntryBook(entryBook);
+ // set financial period
+ closedPeriodicEntryBook.setFinancialPeriod(financialPeriod);
+ // create it
+ closedPeriodicEntryBookTopiaDao.create(closedPeriodicEntryBook);
}
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't create entry book", ex);
}
return result;
}
@Override
- public List<EntryBook> getAllEntryBooks() throws LimaException {
+ public List<EntryBook> getAllEntryBooks() {
- List<EntryBook> entryBooksList;
+ // check if entrybook with is name already exist
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ List<EntryBook> entryBooksList = entryBookTopiaDao.findAll();
- try {
- // check if entrybook with is name already exist
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- entryBooksList = entryBookTopiaDao.findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't get entry books", ex);
- }
-
return entryBooksList;
}
@Override
- public EntryBook updateEntryBook(EntryBook entryBook) throws LimaException {
+ public EntryBook updateEntryBook(EntryBook entryBook) {
- EntryBook result;
- try {
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ // creation du EntryBook
+ EntryBook result = entryBookTopiaDao.update(entryBook);
- // creation du EntryBook
- result = entryBookTopiaDao.update(entryBook);
-
- } catch (Exception ex) {
- throw new LimaException("Can't update entry book", ex);
- }
-
return result;
}
@Override
- public void removeEntryBook(EntryBook entryBook) throws LimaException {
+ public void removeEntryBook(EntryBook entryBook) throws EntryBookException {
// check rule
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
accountingRules.removeEntryBookRules(entryBook);
- try {
+ // re-attach to current transaction
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ EntryBook localEntryBook = entryBookTopiaDao.findByTopiaId(entryBook.getTopiaId());
- // re-attach to current transaction
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- EntryBook localEntryBook = entryBookTopiaDao.findByTopiaId(entryBook.getTopiaId());
-
- // delete all ClosedPeriodicEntryBook from this EntryBook
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
- getDaoHelper().getClosedPeriodicEntryBookDao();
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
- closedPeriodicEntryBookTopiaDao.findAllByEntryBook(localEntryBook);
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBooks) {
- if (log.isDebugEnabled()) {
- log.debug("Deleting closed " + closedPeriodicEntryBook.getTopiaId());
- }
-
- // fix : ObjectDeletedException: deleted object would be re-saved by cascade
- closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
- closedPeriodicEntryBook.getFinancialPeriod().removeEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBook);
-
- closedPeriodicEntryBookTopiaDao.delete(closedPeriodicEntryBook);
+ // delete all ClosedPeriodicEntryBook from this EntryBook
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
+ getDaoHelper().getClosedPeriodicEntryBookDao();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
+ closedPeriodicEntryBookTopiaDao.findAllByEntryBook(localEntryBook);
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBooks) {
+ if (log.isDebugEnabled()) {
+ log.debug("Deleting closed " + closedPeriodicEntryBook.getTopiaId());
}
- // delete entry book
- entryBookTopiaDao.delete(localEntryBook);
+ // fix : ObjectDeletedException: deleted object would be re-saved by cascade
+ closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ closedPeriodicEntryBook.getFinancialPeriod().removeEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBook);
- } catch (Exception ex) {
- throw new LimaException("Can't remove entry book", ex);
+ closedPeriodicEntryBookTopiaDao.delete(closedPeriodicEntryBook);
}
+
+ // delete entry book
+ entryBookTopiaDao.delete(localEntryBook);
}
/*
* @see org.chorem.lima.business.ejbinterface.EntryBookService#getEntryBookByCode(java.lang.String)
*/
@Override
- public EntryBook getEntryBookByCode(String code) throws LimaException {
+ public EntryBook getEntryBookByCode(String code) {
- EntryBook entryBook;
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- try {
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ // creation du EntryBook
+ EntryBook entryBook = entryBookTopiaDao.forCodeEquals(code).findUniqueOrNull();
- // creation du EntryBook
- entryBook = entryBookTopiaDao.forCodeEquals(code).findUniqueOrNull();
-
- } catch (Exception ex) {
- throw new LimaException("Can't get entry book", ex);
- }
-
return entryBook;
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,16 +24,13 @@
* #L%
*/
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.EntryService;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
-import java.util.Collection;
/**
* Created by davidcosse on 17/01/14.
@@ -45,13 +42,10 @@
@Override
public Entry createEntry(Entry entry) {
- Entry result;
- try {
- EntryTopiaDao entryDao = getDaoHelper().getEntryDao();
- result = entryDao.create(entry);
- } catch (TopiaException e) {
- throw new LimaException("Can't create entry", e);
- }
+
+ EntryTopiaDao entryDao = getDaoHelper().getEntryDao();
+ Entry result = entryDao.create(entry);
+
return result;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -28,6 +28,7 @@
import au.com.bytecode.opencsv.CSVWriter;
import org.apache.commons.lang3.StringUtils;
import org.chorem.lima.FinancialStatementWayEnum;
+import org.chorem.lima.LimaTechnicalException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.ExportService;
@@ -50,14 +51,12 @@
import org.chorem.lima.entity.IdentityTopiaDao;
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
-
import java.io.IOException;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
@@ -93,7 +92,7 @@
* 01/01/2013,AN,101,Capital,1,0,100000.00,C
*/
@Override
- public String exportEntriesAsEBP() throws LimaException {
+ public String exportEntriesAsEBP() {
SimpleDateFormat epbDateFormat = new SimpleDateFormat(DATE_PATTERN);
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -171,8 +170,8 @@
}
// Write cache in string
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -192,7 +191,7 @@
* 411DUPOND,DUPOND,,21 rue du bois, 78120, Rambouillet, France,,0135698475,0135698475
*/
@Override
- public String exportAccountsAsEBP() throws LimaException {
+ public String exportAccountsAsEBP() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -222,8 +221,8 @@
// Write cache in string
csvWriter.flush();
csvWriter.close();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -238,7 +237,7 @@
}
@Override
- public String exportEntryBooksAsEBP() throws LimaException {
+ public String exportEntryBooksAsEBP() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -270,8 +269,8 @@
// Write cache in string
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -290,7 +289,7 @@
/** Export integrality of database in CSV */
@Override
- public String exportAsCSV() throws LimaException {
+ public String exportAsCSV() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -305,8 +304,8 @@
exportIdentityAsCSV(csvWriter);
// Write cache in string
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -323,7 +322,7 @@
/** Remote methode call from UI. */
@Override
- public String exportFinancialStatementChartAsCSV() throws LimaException {
+ public String exportFinancialStatementChartAsCSV() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -333,8 +332,9 @@
exportFinancialStatementChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -358,52 +358,48 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportFinancialStatementChartAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[12];
- // Get all Financialstatements
- FinancialStatementTopiaDao financialStatementTopiaDao =
- getDaoHelper().getFinancialStatementDao();
+ public void exportFinancialStatementChartAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[12];
+ // Get all Financialstatements
+ FinancialStatementTopiaDao financialStatementTopiaDao =
+ getDaoHelper().getFinancialStatementDao();
- List<FinancialStatement> listFinancialStatements =
- financialStatementTopiaDao.findAllOrderedByCreateDate();
+ List<FinancialStatement> listFinancialStatements =
+ financialStatementTopiaDao.findAllOrderedByCreateDate();
- // For all Financialstatements
- for (FinancialStatement financialStatement : listFinancialStatements) {
- nextLine[0] = ImportExportEntityEnum.FINANCIALSTATEMENT.getLabel();
- nextLine[1] = financialStatement.getLabel();
- nextLine[2] = Boolean.toString(
- financialStatement.isHeader());
- nextLine[3] = financialStatement.getAccounts();
- nextLine[4] = financialStatement.getDebitAccounts();
- nextLine[5] = financialStatement.getCreditAccounts();
- nextLine[6] = financialStatement.
- getProvisionDeprecationAccounts();
- nextLine[7] = Boolean.toString(
- financialStatement.isSubAmount());
- nextLine[8] = Boolean.toString(
- financialStatement.isHeaderAmount());
- FinancialStatement masterFinancialStatement =
- financialStatement.getMasterFinancialStatement();
- String masterFinancialStatementString = masterFinancialStatement == null ? "" : StringUtils.remove(masterFinancialStatement.getLabel(), ";");
- nextLine[9] = masterFinancialStatementString;
- FinancialStatementWayEnum financialStatementWayEnum = financialStatement.getWay();
- String financialStatementWay = "";
- if (financialStatementWayEnum != null) {
- financialStatementWay = financialStatementWayEnum.name();
- }
- nextLine[10] = financialStatementWay;
- // Add line in file
- csvWriter.writeNext(nextLine);
+ // For all Financialstatements
+ for (FinancialStatement financialStatement : listFinancialStatements) {
+ nextLine[0] = ImportExportEntityEnum.FINANCIALSTATEMENT.getLabel();
+ nextLine[1] = financialStatement.getLabel();
+ nextLine[2] = Boolean.toString(
+ financialStatement.isHeader());
+ nextLine[3] = financialStatement.getAccounts();
+ nextLine[4] = financialStatement.getDebitAccounts();
+ nextLine[5] = financialStatement.getCreditAccounts();
+ nextLine[6] = financialStatement.
+ getProvisionDeprecationAccounts();
+ nextLine[7] = Boolean.toString(
+ financialStatement.isSubAmount());
+ nextLine[8] = Boolean.toString(
+ financialStatement.isHeaderAmount());
+ FinancialStatement masterFinancialStatement =
+ financialStatement.getMasterFinancialStatement();
+ String masterFinancialStatementString = masterFinancialStatement == null ? "" : StringUtils.remove(masterFinancialStatement.getLabel(), ";");
+ nextLine[9] = masterFinancialStatementString;
+ FinancialStatementWayEnum financialStatementWayEnum = financialStatement.getWay();
+ String financialStatementWay = "";
+ if (financialStatementWayEnum != null) {
+ financialStatementWay = financialStatementWayEnum.name();
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ nextLine[10] = financialStatementWay;
+ // Add line in file
+ csvWriter.writeNext(nextLine);
}
}
/** Remote method call from UI. */
@Override
- public String exportVatStatementChartAsCSV() throws LimaException {
+ public String exportVatStatementChartAsCSV() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -413,8 +409,8 @@
exportVatStatementChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -437,43 +433,39 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportVatStatementChartAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[6];
- // Get all Vatstatements
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ public void exportVatStatementChartAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[6];
+ // Get all Vatstatements
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- List<VatStatement> listVatStatements =
- vatStatementTopiaDao.findAllOrderedByCreateDate();
+ List<VatStatement> listVatStatements =
+ vatStatementTopiaDao.findAllOrderedByCreateDate();
- // For all Vatstatements
- for (VatStatement vatStatement : listVatStatements) {
- nextLine[0] = ImportExportEntityEnum.VATSTATEMENT.getLabel();
- nextLine[1] = vatStatement.getBoxName();
- nextLine[2] = vatStatement.getLabel();
- nextLine[3] = Boolean.toString(
- vatStatement.isHeader());
- nextLine[4] = vatStatement.getAccounts();
- VatStatement masterVatStatement =
- vatStatement.getMasterVatStatement();
- String masterVatStatementString = "";
- if (masterVatStatement != null) {
- masterVatStatementString =
- masterVatStatement.getLabel();
- }
- nextLine[5] = masterVatStatementString;
-
- csvWriter.writeNext(nextLine);
+ // For all Vatstatements
+ for (VatStatement vatStatement : listVatStatements) {
+ nextLine[0] = ImportExportEntityEnum.VATSTATEMENT.getLabel();
+ nextLine[1] = vatStatement.getBoxName();
+ nextLine[2] = vatStatement.getLabel();
+ nextLine[3] = Boolean.toString(
+ vatStatement.isHeader());
+ nextLine[4] = vatStatement.getAccounts();
+ VatStatement masterVatStatement =
+ vatStatement.getMasterVatStatement();
+ String masterVatStatementString = "";
+ if (masterVatStatement != null) {
+ masterVatStatementString =
+ masterVatStatement.getLabel();
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ nextLine[5] = masterVatStatementString;
+
+ csvWriter.writeNext(nextLine);
}
}
/** Remote methode call from UI. */
@Override
- public String exportEntryBookChartAsCSV() throws LimaException {
+ public String exportEntryBookChartAsCSV() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -483,8 +475,8 @@
exportEntryBookChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -506,29 +498,26 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportEntryBookChartAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[3];
- // Get all entrybook
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- List<EntryBook> listEntryBook = entryBookTopiaDao.findAll();
- // For all EntryBook
- for (EntryBook entryBook : listEntryBook) {
- nextLine[0] = ImportExportEntityEnum.ENTRYBOOK.getLabel();
- nextLine[1] = entryBook.getCode();
- nextLine[2] = StringUtils.remove(entryBook.getLabel(), ";");
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ public void exportEntryBookChartAsCSV(CSVWriter csvWriter) {
+
+ String[] nextLine = new String[3];
+ // Get all entrybook
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ List<EntryBook> listEntryBook = entryBookTopiaDao.findAll();
+ // For all EntryBook
+ for (EntryBook entryBook : listEntryBook) {
+ nextLine[0] = ImportExportEntityEnum.ENTRYBOOK.getLabel();
+ nextLine[1] = entryBook.getCode();
+ nextLine[2] = StringUtils.remove(entryBook.getLabel(), ";");
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
}
}
/** Remote methode call from UI. */
@Override
- public String exportAccountsChartAsCSV() throws LimaException {
+ public String exportAccountsChartAsCSV() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -537,8 +526,8 @@
exportAccountsChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -560,25 +549,21 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportAccountsChartAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[6];
- // Récupère tous les comptes
- AccountTopiaDao accountTopiaDao =
- getDaoHelper().getAccountDao();
- List<Account> listAccount = accountTopiaDao.findAll();
- // Pour tous les comptes
- for (Account account : listAccount) {
- nextLine[0] = ImportExportEntityEnum.ACCOUNT.getLabel();
- nextLine[1] = account.getAccountNumber();
- nextLine[2] = StringUtils.remove(account.getLabel(), ";");
- nextLine[3] = account.getThirdParty();
+ public void exportAccountsChartAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[6];
+ // Récupère tous les comptes
+ AccountTopiaDao accountTopiaDao =
+ getDaoHelper().getAccountDao();
+ List<Account> listAccount = accountTopiaDao.findAll();
+ // Pour tous les comptes
+ for (Account account : listAccount) {
+ nextLine[0] = ImportExportEntityEnum.ACCOUNT.getLabel();
+ nextLine[1] = account.getAccountNumber();
+ nextLine[2] = StringUtils.remove(account.getLabel(), ";");
+ nextLine[3] = account.getThirdParty();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
}
}
@@ -591,48 +576,45 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportFinancialTransactionsAndEntriesAsCSV(CSVWriter csvWriter) throws LimaException {
+ public void exportFinancialTransactionsAndEntriesAsCSV(CSVWriter csvWriter) {
int numTransaction = 0;
// Get all financialtransactions
- try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao =
- getDaoHelper().getFinancialTransactionDao();
- List<FinancialTransaction> listFinancialTransaction =
- financialTransactionTopiaDao.findAll();
- // For all financialTransaction
- for (FinancialTransaction financialTransaction : listFinancialTransaction) {
- String[] nextLine = new String[8];
- nextLine[0] = ImportExportEntityEnum.FINANCIALTRANSACTION.getLabel();
+
+ FinancialTransactionTopiaDao financialTransactionTopiaDao =
+ getDaoHelper().getFinancialTransactionDao();
+ List<FinancialTransaction> listFinancialTransaction =
+ financialTransactionTopiaDao.findAll();
+ // For all financialTransaction
+ for (FinancialTransaction financialTransaction : listFinancialTransaction) {
+ String[] nextLine = new String[8];
+ nextLine[0] = ImportExportEntityEnum.FINANCIALTRANSACTION.getLabel();
+ nextLine[1] = String.valueOf(numTransaction);
+ nextLine[2] = SDATEFORMAT.format(financialTransaction.getTransactionDate());
+ nextLine[3] = financialTransaction.getAmountDebit().toString();
+ nextLine[4] = financialTransaction.getAmountCredit().toString();
+ EntryBook entryBook = financialTransaction.getEntryBook();
+ if (entryBook != null) {
+ nextLine[5] = entryBook.getCode();
+ }
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+
+ nextLine = new String[10];
+ for (Entry entry : financialTransaction.getEntry()) {
+ nextLine[0] = ImportExportEntityEnum.ENTRY.getLabel();
nextLine[1] = String.valueOf(numTransaction);
- nextLine[2] = SDATEFORMAT.format(financialTransaction.getTransactionDate());
- nextLine[3] = financialTransaction.getAmountDebit().toString();
- nextLine[4] = financialTransaction.getAmountCredit().toString();
- EntryBook entryBook = financialTransaction.getEntryBook();
- if (entryBook != null) {
- nextLine[5] = entryBook.getCode();
- }
+ nextLine[2] = entry.getDescription();
+ nextLine[3] = entry.getAmount().toString();
+ nextLine[4] = Boolean.toString(entry.isDebit());
+ nextLine[5] = entry.getLettering();
+ nextLine[6] = entry.getDetail();
+ nextLine[7] = entry.getVoucher();
+ nextLine[8] = entry.getPosition();
+ nextLine[9] = entry.getAccount().getAccountNumber();
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
-
- nextLine = new String[10];
- for (Entry entry : financialTransaction.getEntry()) {
- nextLine[0] = ImportExportEntityEnum.ENTRY.getLabel();
- nextLine[1] = String.valueOf(numTransaction);
- nextLine[2] = entry.getDescription();
- nextLine[3] = entry.getAmount().toString();
- nextLine[4] = Boolean.toString(entry.isDebit());
- nextLine[5] = entry.getLettering();
- nextLine[6] = entry.getDetail();
- nextLine[7] = entry.getVoucher();
- nextLine[8] = entry.getPosition();
- nextLine[9] = entry.getAccount().getAccountNumber();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- numTransaction++;
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ numTransaction++;
}
}
@@ -644,25 +626,21 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportFiscalPeriodAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[4];
- // Get all fiscalperiod
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao =
- getDaoHelper().getFiscalPeriodDao();
- List<FiscalPeriod> listFiscalPeriod =
- fiscalPeriodTopiaDao.findAll();
- // For all Entry
- for (FiscalPeriod fiscalPeriod : listFiscalPeriod) {
- nextLine[0] = ImportExportEntityEnum.FISCALPERIOD.getLabel();
- nextLine[1] = SDATEFORMAT.format(fiscalPeriod.getBeginDate());
- nextLine[2] = SDATEFORMAT.format(fiscalPeriod.getEndDate());
- nextLine[3] = Boolean.toString(fiscalPeriod.isLocked());
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ public void exportFiscalPeriodAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[4];
+ // Get all fiscalperiod
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao =
+ getDaoHelper().getFiscalPeriodDao();
+ List<FiscalPeriod> listFiscalPeriod =
+ fiscalPeriodTopiaDao.findAll();
+ // For all Entry
+ for (FiscalPeriod fiscalPeriod : listFiscalPeriod) {
+ nextLine[0] = ImportExportEntityEnum.FISCALPERIOD.getLabel();
+ nextLine[1] = SDATEFORMAT.format(fiscalPeriod.getBeginDate());
+ nextLine[2] = SDATEFORMAT.format(fiscalPeriod.getEndDate());
+ nextLine[3] = Boolean.toString(fiscalPeriod.isLocked());
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
}
}
@@ -673,60 +651,52 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportClosedPeriodicEntryBooksAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[5];
- // Get all fiscalperiod
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
- getDaoHelper().getClosedPeriodicEntryBookDao();
- List<ClosedPeriodicEntryBook> listClosedPeriodicEntryBook =
- closedPeriodicEntryBookTopiaDao.findAll();
- // For all Entry
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) {
- nextLine[0] = ImportExportEntityEnum.CLOSEDPERIODICENTRYBOOK.getLabel();
- nextLine[1] = Boolean.toString(
- closedPeriodicEntryBook.isLocked());
- nextLine[2] =
- SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod().
- getBeginDate());
- nextLine[3] =
- SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod().
- getEndDate());
- nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ public void exportClosedPeriodicEntryBooksAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[5];
+ // Get all fiscalperiod
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
+ getDaoHelper().getClosedPeriodicEntryBookDao();
+ List<ClosedPeriodicEntryBook> listClosedPeriodicEntryBook =
+ closedPeriodicEntryBookTopiaDao.findAll();
+ // For all Entry
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) {
+ nextLine[0] = ImportExportEntityEnum.CLOSEDPERIODICENTRYBOOK.getLabel();
+ nextLine[1] = Boolean.toString(
+ closedPeriodicEntryBook.isLocked());
+ nextLine[2] =
+ SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod().
+ getBeginDate());
+ nextLine[3] =
+ SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod().
+ getEndDate());
+ nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
}
}
- public void exportIdentityAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[12];
- // Get identity
- IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
- List<Identity> identities = identityTopiaDao.findAll();
- if (identities.size() != 0) {
+ public void exportIdentityAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[12];
+ // Get identity
+ IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
+ List<Identity> identities = identityTopiaDao.findAll();
+ if (identities.size() != 0) {
- Identity identity = identities.get(0);
- nextLine[0] = ImportExportEntityEnum.IDENTITY.getLabel();
- nextLine[1] = identity.getName();
- nextLine[2] = identity.getDescription();
- nextLine[3] = identity.getAddress();
- nextLine[4] = identity.getAddress2();
- nextLine[5] = identity.getCity();
- nextLine[6] = identity.getPhoneNumber();
- nextLine[7] = identity.getEmail();
- nextLine[8] = identity.getZipCode();
- nextLine[9] = identity.getVatNumber();
- nextLine[10] = identity.getClassificationCode();
- nextLine[11] = identity.getBusinessNumber();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ Identity identity = identities.get(0);
+ nextLine[0] = ImportExportEntityEnum.IDENTITY.getLabel();
+ nextLine[1] = identity.getName();
+ nextLine[2] = identity.getDescription();
+ nextLine[3] = identity.getAddress();
+ nextLine[4] = identity.getAddress2();
+ nextLine[5] = identity.getCity();
+ nextLine[6] = identity.getPhoneNumber();
+ nextLine[7] = identity.getEmail();
+ nextLine[8] = identity.getZipCode();
+ nextLine[9] = identity.getVatNumber();
+ nextLine[10] = identity.getClassificationCode();
+ nextLine[11] = identity.getBusinessNumber();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
}
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,28 +25,22 @@
package org.chorem.lima.business.ejb;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.FinancialPeriodService;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
-import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryBookTopiaDao;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.util.Date;
+import java.util.List;
+
/**
* Gestion des périodes intermédiaires durant l'exercice.
* Chaque timeSpan sera fixe, et devra correspondre à un mois complet.
@@ -60,119 +54,79 @@
/** @return all financial period */
@Override
- public List<FinancialPeriod> getAllFinancialPeriods() throws LimaException {
+ public List<FinancialPeriod> getAllFinancialPeriods() {
- List<FinancialPeriod> result;
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ List<FinancialPeriod> result = financialPeriodTopiaDao.findAllOrderByBeginDate();
- try {
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- result = financialPeriodTopiaDao.findAllOrderByBeginDate();
- } catch (Exception ex) {
- throw new LimaException("Can't get periods", ex);
- }
-
return result;
}
/** @return all unblocked financial period */
@Override
- public List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException {
+ public List<FinancialPeriod> getUnblockedFinancialPeriods() {
- List<FinancialPeriod> result;
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ List<FinancialPeriod>result = financialPeriodTopiaDao.findAllUnlockedOrderByBeginDate();
- try {
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- result = financialPeriodTopiaDao.findAllUnlockedOrderByBeginDate();
- } catch (Exception ex) {
- throw new LimaException("Can't create period", ex);
- }
-
return result;
}
/** @return all financial period from a fiscal period */
@Override
- public List<FinancialPeriod> getFinancialPeriods(Date beginDate, Date endDate) throws LimaException {
+ public List<FinancialPeriod> getFinancialPeriods(Date beginDate, Date endDate) {
- List<FinancialPeriod> result;
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ List<FinancialPeriod> result = financialPeriodTopiaDao.findByDates(beginDate, endDate);
- try {
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- result = financialPeriodTopiaDao.findByDates(beginDate, endDate);
- } catch (Exception ex) {
- throw new LimaException("Can't get period", ex);
- }
-
return result;
}
- public FinancialPeriod getFinancialPeriodByNaturalIds(Date beginDate, Date endDate) throws LimaException {
+ public FinancialPeriod getFinancialPeriodByNaturalIds(Date beginDate, Date endDate) {
- FinancialPeriod result;
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ FinancialPeriod result = financialPeriodTopiaDao.findByNaturalId(beginDate, endDate);
- try {
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- result = financialPeriodTopiaDao.findByNaturalId(beginDate, endDate);
- } catch (Exception ex) {
- throw new LimaException("Can't get period", ex);
- }
-
return result;
}
@Override
- public ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
+ public ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
ClosedPeriodicEntryBook result;
- try {
- // check rules before create the account
- accountingRules.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
+ // check rules before create the account
+ accountingRules.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
- getDaoHelper().getClosedPeriodicEntryBookDao();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
+ getDaoHelper().getClosedPeriodicEntryBookDao();
- // reload object in current transaction
- result = closedPeriodicEntryBookTopiaDao.findByTopiaId(
- closedPeriodicEntryBook.getTopiaId());
+ // reload object in current transaction
+ result = closedPeriodicEntryBookTopiaDao.findByTopiaId(
+ closedPeriodicEntryBook.getTopiaId());
- result.setLocked(true);
- result = closedPeriodicEntryBookTopiaDao.update(result);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't block period", ex);
- }
+ result.setLocked(true);
+ result = closedPeriodicEntryBookTopiaDao.update(result);
return result;
}
@Override
public ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook,
- FinancialPeriod financialPeriod) throws LimaException {
- ClosedPeriodicEntryBook closedPeriodicEntryBook;
+ FinancialPeriod financialPeriod) {
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- try {
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- closedPeriodicEntryBook = closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(entryBook, financialPeriod);
- } catch (Exception ex) {
- throw new LimaException("Can't get closed periodic", ex);
- }
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(entryBook, financialPeriod);
return closedPeriodicEntryBook;
}
@Override
- public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException {
+ public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() {
- List<ClosedPeriodicEntryBook> result;
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ List<ClosedPeriodicEntryBook> result = closedPeriodicEntryBookTopiaDao.findAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
- try {
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- result = closedPeriodicEntryBookTopiaDao.findAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
- } catch (Exception ex) {
- throw new LimaException("Can't get closed periodics", ex);
- }
-
return result;
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,19 +25,6 @@
package org.chorem.lima.business.ejb;
-import static org.nuiton.i18n.I18n.t;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -57,8 +44,19 @@
import org.chorem.lima.entity.AccountTopiaDao;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import static org.nuiton.i18n.I18n.t;
+
@Stateless
@Remote(FinancialStatementService.class)
@TransactionAttribute
@@ -74,86 +72,70 @@
@Override
public void createFinancialStatement(FinancialStatement masterFinancialStatement,
- FinancialStatement financialStatement) throws LimaException {
+ FinancialStatement financialStatement) {
- try {
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ financialStatementTopiaDao.create(financialStatement);
- financialStatementTopiaDao.create(financialStatement);
+ FinancialStatement masterfinancialStatementUpdate = null;
+ if (masterFinancialStatement != null) {
+ masterfinancialStatementUpdate = financialStatementTopiaDao.forLabelEquals(masterFinancialStatement.getLabel()).findAnyOrNull();
+ }
- FinancialStatement masterfinancialStatementUpdate = null;
- if (masterFinancialStatement != null) {
- masterfinancialStatementUpdate = financialStatementTopiaDao.forLabelEquals(masterFinancialStatement.getLabel()).findAnyOrNull();
- }
-
- // check if parent account exist;
- if (masterfinancialStatementUpdate != null) {
- masterfinancialStatementUpdate.addSubFinancialStatements(financialStatement);
- financialStatementTopiaDao.update(masterfinancialStatementUpdate);
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't create financial statement", ex);
+ // check if parent account exist;
+ if (masterfinancialStatementUpdate != null) {
+ masterfinancialStatementUpdate.addSubFinancialStatements(financialStatement);
+ financialStatementTopiaDao.update(masterfinancialStatementUpdate);
}
}
@Override
- public void removeFinancialStatement(FinancialStatement financialStatement) throws LimaException {
+ public void removeFinancialStatement(FinancialStatement financialStatement) {
- try {
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- // remove financialstatement
- FinancialStatement financialStatementToDelete =
- financialStatementTopiaDao.findByTopiaId(
- financialStatement.getTopiaId());
- financialStatementTopiaDao.delete(financialStatementToDelete);
+ // remove financialstatement
+ FinancialStatement financialStatementToDelete =
+ financialStatementTopiaDao.findByTopiaId(
+ financialStatement.getTopiaId());
+ financialStatementTopiaDao.delete(financialStatementToDelete);
- //get all subFinancialStatement
- List<FinancialStatement> financialStatements =
- getAllChildrenFinancialStatement(financialStatement,
- new ArrayList<FinancialStatement>());
+ //get all subFinancialStatement
+ List<FinancialStatement> financialStatements =
+ getAllChildrenFinancialStatement(financialStatement,
+ new ArrayList<FinancialStatement>());
- //if FinancialStatement have subFinancialStatement
- if (financialStatements.size() > 0) {
- for (FinancialStatement subFinancialStatement : financialStatements) {
- FinancialStatement subFinancialStatementToDelete =
- financialStatementTopiaDao.findByTopiaId(
- subFinancialStatement.getTopiaId());
- financialStatementTopiaDao.delete(subFinancialStatementToDelete);
- }
+ //if FinancialStatement have subFinancialStatement
+ if (financialStatements.size() > 0) {
+ for (FinancialStatement subFinancialStatement : financialStatements) {
+ FinancialStatement subFinancialStatementToDelete =
+ financialStatementTopiaDao.findByTopiaId(
+ subFinancialStatement.getTopiaId());
+ financialStatementTopiaDao.delete(subFinancialStatementToDelete);
}
-
- } catch (Exception ex) {
- throw new LimaException("Can't remove financial statement", ex);
}
}
@Override
- public void removeAllFinancialStatement() throws LimaException {
+ public void removeAllFinancialStatement() {
for (FinancialStatement financialStatement : getChildrenFinancialStatement(null)) {
removeFinancialStatement(financialStatement);
}
}
@Override
- public List<FinancialStatement> getAllFinancialStatements() throws LimaException {
- List<FinancialStatement> financialStatements;
+ public List<FinancialStatement> getAllFinancialStatements() {
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ List<FinancialStatement> financialStatements = financialStatementTopiaDao.findAll();
- try {
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- financialStatements = financialStatementTopiaDao.findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't get financial statements", ex);
- }
return financialStatements;
}
@Override
public List<FinancialStatement> getAllChildrenFinancialStatement(FinancialStatement financialStatement,
- List<FinancialStatement> result) throws LimaException {
+ List<FinancialStatement> result) {
List<FinancialStatement> childFinancialStatements =
getChildrenFinancialStatement(financialStatement);
for (FinancialStatement childFinancialStatement : childFinancialStatements) {
@@ -164,31 +146,23 @@
}
@Override
- public List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement masterFinancialStatement) throws LimaException {
- List<FinancialStatement> financialStatements;
+ public List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement masterFinancialStatement) {
- try {
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- financialStatements = financialStatementTopiaDao.findChildrenFinancialStatement(masterFinancialStatement);
- } catch (Exception ex) {
- throw new LimaException("Can't get childreen statements", ex);
- }
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ List<FinancialStatement> financialStatements = financialStatementTopiaDao.findChildrenFinancialStatement(masterFinancialStatement);
+
return financialStatements;
}
@Override
- public void updateFinancialStatement(FinancialStatement financialStatement) throws LimaException {
+ public void updateFinancialStatement(FinancialStatement financialStatement) {
- try {
- // TopiaDao
- FinancialStatementTopiaDao financialStatementHeaderTopiaDao = getDaoHelper().getFinancialStatementDao();
- //update
- financialStatementHeaderTopiaDao.update(financialStatement);
+ // TopiaDao
+ FinancialStatementTopiaDao financialStatementHeaderTopiaDao = getDaoHelper().getFinancialStatementDao();
+ //update
+ financialStatementHeaderTopiaDao.update(financialStatement);
- } catch (Exception ex) {
- throw new LimaException("Can't update financial statement", ex);
- }
}
@@ -197,18 +171,11 @@
*/
@Override
public List<FinancialStatementAmounts> financialStatementReport(Date selectedBeginDate,
- Date selectedEndDate) throws LimaException {
- List<FinancialStatementAmounts> result;
+ Date selectedEndDate) {
+ //create list form tree
+ List<FinancialStatementAmounts> result = financialStatementReport(null, selectedBeginDate,
+ selectedEndDate, new FinancialStatementDatasImpl()).getListResult();
- try {
-
- //create list form tree
- result = financialStatementReport(null, selectedBeginDate,
- selectedEndDate, new FinancialStatementDatasImpl()).getListResult();
-
- } catch (Exception ex) {
- throw new LimaException("Can't generate report", ex);
- }
return result;
}
@@ -225,7 +192,7 @@
protected FinancialStatementDatas financialStatementReport(FinancialStatement financialStatement,
Date selectedBeginDate,
Date selectedEndDate,
- FinancialStatementDatas result) throws LimaException {
+ FinancialStatementDatas result) {
List<FinancialStatement> financialStatements = getChildrenFinancialStatement(financialStatement);
@@ -332,7 +299,7 @@
*/
protected FinancialStatementAmounts financialStatementAmounts(FinancialStatement financialStatement,
Date selectedBeginDate,
- Date selectedEndDate) throws LimaException {
+ Date selectedEndDate) {
FinancialStatementAmounts financialStatementAmounts =
new FinancialStatementAmountsImpl();
BigDecimal amount = new BigDecimal(0);
@@ -406,121 +373,106 @@
protected Amounts amountFromAccountList(String accountsNumberList,
Date selectedBeginDate,
- Date selectedEndDate) throws LimaException {
+ Date selectedEndDate) {
Amounts amounts = new AmountsImpl();
BigDecimal debit = new BigDecimal(0);
BigDecimal credit = new BigDecimal(0);
Boolean substract = false;
- try {
- AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
- //Remove Spaces
- String result = StringUtils.deleteWhitespace(accountsNumberList);
- StringTokenizer stQuote = new StringTokenizer(result, "-");
- while (stQuote.hasMoreTokens()) {
- String s = stQuote.nextToken();
- //List<Account> accountsList = accountTopiaDao.stringToListAccounts(s, false);
- List<Account> accountsList = accountService.stringToListAccounts(s);
- BigDecimal debitTemp = new BigDecimal(0);
- BigDecimal creditTemp = new BigDecimal(0);
- for (Account account : accountsList) {
- ReportsDatas reportsDatas = reportService.
- generateAccountsReports(
- account,
- true,
- selectedBeginDate, selectedEndDate);
- if (reportsDatas.getSoldeDebit()) {
- debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
- } else {
- creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
- }
+
+ AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
+ //Remove Spaces
+ String result = StringUtils.deleteWhitespace(accountsNumberList);
+ StringTokenizer stQuote = new StringTokenizer(result, "-");
+ while (stQuote.hasMoreTokens()) {
+ String s = stQuote.nextToken();
+ //List<Account> accountsList = accountTopiaDao.stringToListAccounts(s, false);
+ List<Account> accountsList = accountService.stringToListAccounts(s);
+ BigDecimal debitTemp = new BigDecimal(0);
+ BigDecimal creditTemp = new BigDecimal(0);
+ for (Account account : accountsList) {
+ ReportsDatas reportsDatas = reportService.
+ generateAccountsReports(
+ account,
+ true,
+ selectedBeginDate, selectedEndDate);
+ if (reportsDatas.getSoldeDebit()) {
+ debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
+ } else {
+ creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
}
- if (!substract) {
- debit = debitTemp;
- credit = creditTemp;
- }
- //compte(s) précédé du signe -
- else {
- debit = debit.subtract(debitTemp);
- credit = credit.subtract(creditTemp);
- }
- substract = true;
}
- amounts.setCredit(credit);
- amounts.setDebit(debit);
- } catch (TopiaException ex) {
- throw new LimaException("Can't get accounts from list", ex);
+ if (!substract) {
+ debit = debitTemp;
+ credit = creditTemp;
+ }
+ //compte(s) précédé du signe -
+ else {
+ debit = debit.subtract(debitTemp);
+ credit = credit.subtract(creditTemp);
+ }
+ substract = true;
}
+ amounts.setCredit(credit);
+ amounts.setDebit(debit);
return amounts;
}
@Override
- public String checkFinancialStatementChart() throws LimaException {
+ public String checkFinancialStatementChart() {
StringBuilder result =
new StringBuilder(t("lima-business.financialstatement.check.warn"));
- try {
+ AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ List<Account> accountsList = accountTopiaDao.findAllLeafAccounts();
- List<Account> accountsList = accountTopiaDao.findAllLeafAccounts();
+ List<FinancialStatement> financialStatementsList =
+ financialStatementTopiaDao.findAll();
- List<FinancialStatement> financialStatementsList =
- financialStatementTopiaDao.findAll();
+ for (FinancialStatement financialStatement : financialStatementsList) {
- for (FinancialStatement financialStatement : financialStatementsList) {
+ accountsList.removeAll(
+ accountService.stringToListAccounts(
+ financialStatement.getAccounts()));
- accountsList.removeAll(
- accountService.stringToListAccounts(
- financialStatement.getAccounts()));
+ accountsList.removeAll(
+ accountService.stringToListAccounts(
+ financialStatement.getCreditAccounts()));
- accountsList.removeAll(
- accountService.stringToListAccounts(
- financialStatement.getCreditAccounts()));
+ accountsList.removeAll(
+ accountService.stringToListAccounts(
+ financialStatement.getDebitAccounts()));
- accountsList.removeAll(
- accountService.stringToListAccounts(
- financialStatement.getDebitAccounts()));
+ accountsList.removeAll(
+ accountService.stringToListAccounts(
+ financialStatement.getProvisionDeprecationAccounts()));
+ }
- accountsList.removeAll(
- accountService.stringToListAccounts(
- financialStatement.getProvisionDeprecationAccounts()));
- }
+ for (Account account : accountsList) {
- for (Account account : accountsList) {
-
- result.append(t("lima-business.financialstatement.check.nothing",
- account.getAccountNumber(), account.getLabel()));
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't check financial statement", ex);
+ result.append(t("lima-business.financialstatement.check.nothing",
+ account.getAccountNumber(), account.getLabel()));
}
+
return result.toString();
}
@Override
- public boolean checkFinancialStatementExist(String label) throws LimaException {
- boolean result;
- try {
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- result = financialStatementTopiaDao.forProperties(FinancialStatement.PROPERTY_LABEL, label).exists();
- } catch (TopiaException e) {
- throw new LimaException("Can't check financial statement", e);
- }
+ public boolean checkFinancialStatementExist(String label) {
+
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ boolean result = financialStatementTopiaDao.forProperties(FinancialStatement.PROPERTY_LABEL, label).exists();
+
return result;
}
@Override
- public FinancialStatement getFinancialStatementByLabel(String label) throws LimaException {
- FinancialStatement result;
- try {
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- result = financialStatementTopiaDao.findByLabel(label);
- } catch (TopiaException e) {
- throw new LimaException("Can't find financial statement", e);
- }
+ public FinancialStatement getFinancialStatementByLabel(String label) {
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ FinancialStatement result = financialStatementTopiaDao.findByLabel(label);
+
return result;
}
}
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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -35,6 +35,8 @@
import org.chorem.lima.beans.FinancialTransactionCondition;
import org.chorem.lima.beans.LetteringFilter;
import org.chorem.lima.business.AccountingRules;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
@@ -43,13 +45,12 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryTopiaDao;
import org.chorem.lima.entity.EntryImpl;
+import org.chorem.lima.entity.EntryTopiaDao;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionTopiaDao;
import org.chorem.lima.entity.FiscalPeriod;
-import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -98,22 +99,17 @@
protected static final Log log = LogFactory.getLog(FinancialTransactionServiceImpl.class);
@Override
- public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction)
- throws LimaException {
- FinancialTransaction result;
+ public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException {
+
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- try {
- //check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction);
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction);
- FinancialTransactionTopiaDao financialtransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransactionTopiaDao financialtransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- result = financialtransactionTopiaDao.create(financialtransaction);
+ FinancialTransaction result = financialtransactionTopiaDao.create(financialtransaction);
- } catch (TopiaException ex) {
- throw new LimaException("Can't create financial transaction", ex);
- }
return result;
}
@@ -122,15 +118,11 @@
*/
@Override
public List<FinancialTransaction> getAllFinancialTransactions(
- Date beginDate, Date endDate) throws LimaException {
- List<FinancialTransaction> financialTransactions;
+ Date beginDate, Date endDate) {
- try {
- FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- financialTransactions = transactionTopiaDao.findAllByDates(beginDate, endDate);
- } catch (Exception ex) {
- throw new LimaException("Can't get financial transactions", ex);
- }
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ List<FinancialTransaction> financialTransactions = transactionTopiaDao.findAllByDates(beginDate, endDate);
+
return financialTransactions;
}
@@ -138,20 +130,14 @@
* and increment them
* */
@Override
- public String getNextLetters() throws LimaException {
- String lastActualLetters;
- String nextLetters;
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ public String getNextLetters() {
- List<String> letters = new ArrayList<String>(entryTopiaDao.findLetters());
- lastActualLetters = findLastLetter(letters);
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- } catch (Exception ex) {
- throw new LimaException("Can't get new letters", ex);
- }
+ List<String> letters = new ArrayList<String>(entryTopiaDao.findLetters());
+ String lastActualLetters = findLastLetter(letters);
- nextLetters = lettersAfter(lastActualLetters);
+ String nextLetters = lettersAfter(lastActualLetters);
return nextLetters;
}
@@ -185,22 +171,17 @@
}
@Override
- public List<String> getAllLetters() throws LimaException {
- List<String> letters;
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ public List<String> getAllLetters() {
- letters = new ArrayList<String>(entryTopiaDao.findLetters());
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- } catch (Exception ex) {
- throw new LimaException("Can't get all letters", ex);
- }
+ List<String> letters = new ArrayList<String>(entryTopiaDao.findLetters());
return letters;
}
@Override
- public Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws LimaException{
+ public Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws FinancialTransactionException {
Entry newSameAccountEntry = null;
Entry newCostOrProductEntry = null;
@@ -337,7 +318,7 @@
*/
@Override
public List<FinancialTransaction> getAllFinancialTransactions(
- FinancialPeriod period) throws LimaException {
+ FinancialPeriod period) {
return getAllFinancialTransactions(period, null);
}
@@ -346,15 +327,10 @@
*/
@Override
public List<FinancialTransaction> getAllFinancialTransactions(
- FiscalPeriod period) throws LimaException {
- List<FinancialTransaction> financialTransactions;
+ FiscalPeriod period) {
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ List<FinancialTransaction> financialTransactions = transactionTopiaDao.findAllByDates(period.getBeginDate(), period.getEndDate());
- try {
- FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- financialTransactions = transactionTopiaDao.findAllByDates(period.getBeginDate(), period.getEndDate());
- } catch (Exception ex) {
- throw new LimaException("Can't get financial transactions", ex);
- }
return financialTransactions;
}
@@ -362,24 +338,20 @@
* Return the list of all financial transaction of a financial period and an entrybook.
*/
@Override
- public List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod financialPeriod, EntryBook entryBook) throws LimaException {
+ public List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod financialPeriod, EntryBook entryBook) {
List<FinancialTransaction> financialTransactions;
- try {
- FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- if (entryBook != null) {
- financialTransactions = transactionTopiaDao.findAllByDates(financialPeriod.getBeginDate(),
- financialPeriod.getEndDate(), entryBook);
- } else {
- financialTransactions = transactionTopiaDao.findAllByDates(financialPeriod.getBeginDate(),
- financialPeriod.getEndDate());
- }
-
- } catch (Exception ex) {
- throw new LimaException("Can't get financial transactions", ex);
+ if (entryBook != null) {
+ financialTransactions = transactionTopiaDao.findAllByDates(financialPeriod.getBeginDate(),
+ financialPeriod.getEndDate(), entryBook);
+ } else {
+ financialTransactions = transactionTopiaDao.findAllByDates(financialPeriod.getBeginDate(),
+ financialPeriod.getEndDate());
}
+
return financialTransactions;
}
@@ -387,31 +359,26 @@
* Get unbalanced financialtransaction from selected fiscalperiod.
*/
@Override
- public List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) throws LimaException {
+ public List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) {
- List<FinancialTransaction> result;
//List<FinancialTransaction> checkedResult = new ArrayList<FinancialTransaction>();
- try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- result = financialTransactionTopiaDao.getAllIncorrectTransaction(fiscalPeriod.getBeginDate(),
- fiscalPeriod.getEndDate(), null);
- /*for (FinancialTransaction fTransaction : result) {
- BigDecimal credit = fTransaction.getAmountCredit();
- BigDecimal debit = fTransaction.getAmountDebit();
- credit = credit.setScale(optionsService.getScale(),
- BigDecimal.ROUND_HALF_UP);
- debit = debit.setScale(optionsService.getScale(),
- BigDecimal.ROUND_HALF_UP);
- if (credit.equals(debit)) {
- checkedResult.add(fTransaction);
- }
- }*/
+ List<FinancialTransaction> result = financialTransactionTopiaDao.getAllIncorrectTransaction(fiscalPeriod.getBeginDate(),
+ fiscalPeriod.getEndDate(), null);
+ /*for (FinancialTransaction fTransaction : result) {
+ BigDecimal credit = fTransaction.getAmountCredit();
+ BigDecimal debit = fTransaction.getAmountDebit();
+ credit = credit.setScale(optionsService.getScale(),
+ BigDecimal.ROUND_HALF_UP);
+ debit = debit.setScale(optionsService.getScale(),
+ BigDecimal.ROUND_HALF_UP);
+ if (credit.equals(debit)) {
+ checkedResult.add(fTransaction);
+ }
+ }*/
- } catch (Exception ex) {
- throw new LimaException("Can't get financial transactions", ex);
- }
return result;
}
@@ -423,50 +390,35 @@
* @throws LimaException
*/
@Override
- public List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod) throws LimaException {
- List<FinancialTransaction> result;
- try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ public List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod) {
- result = financialTransactionTopiaDao.getAllBalancedTransaction(fiscalPeriod.getBeginDate(),
- fiscalPeriod.getEndDate(), null);
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- } catch (TopiaException ex) {
- throw new LimaException("Can't get financial transactions", ex);
- }
+ List<FinancialTransaction> result = financialTransactionTopiaDao.getAllBalancedTransaction(fiscalPeriod.getBeginDate(),
+ fiscalPeriod.getEndDate(), null);
+
return result;
}
@Override
- public List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter) throws LimaException {
- List<Entry> entries;
+ public List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter) {
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- entries = entryTopiaDao.findAllEntryByFilter(filter);
- } catch (Exception ex) {
- throw new LimaException("Can't get entries", ex);
- }
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ List<Entry> entries = entryTopiaDao.findAllEntryByFilter(filter);
- if (log.isInfoEnabled()) {
- log.info("Entries size : " + entries.size());
- }
+ if (log.isInfoEnabled()) {
+ log.info("Entries size : " + entries.size());
+ }
- return entries;
+ return entries;
}
@Override
- public Entry getLastEntry(FinancialTransaction financialTransaction) throws LimaException {
- Entry lastEntry;
+ public Entry getLastEntry(FinancialTransaction financialTransaction) {
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- lastEntry = entryTopiaDao.getLastEntry(financialTransaction);
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ Entry lastEntry = entryTopiaDao.getLastEntry(financialTransaction);
- } catch (Exception ex) {
- throw new LimaException("Can't get entries", ex);
- }
-
return lastEntry;
}
@@ -474,26 +426,22 @@
* Method used by update entry and remove entry for update amounts.
*/
@Override
- public void updateFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
+ public void updateFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- try {
+ //FIXME mallon 22/06/2012 : Revoir l'utilisation du rattachement à la session et celle des deux objets 'financialTransactionOld'
+ //et 'financialTransaction'
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransaction financialTransactionOld = transactionTopiaDao.findByTopiaId(financialTransaction.getTopiaId());
- //FIXME mallon 22/06/2012 : Revoir l'utilisation du rattachement à la session et celle des deux objets 'financialTransactionOld'
- //et 'financialTransaction'
- FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- FinancialTransaction financialTransactionOld = transactionTopiaDao.findByTopiaId(financialTransaction.getTopiaId());
+ accountingRules.updateFinancialTransactionDateRules(financialTransaction, financialTransactionOld);
- accountingRules.updateFinancialTransactionDateRules(financialTransaction, financialTransactionOld);
+ financialTransactionOld.setEntryBook(financialTransaction.getEntryBook());
+ financialTransactionOld.setTransactionDate(financialTransaction.getTransactionDate());
- financialTransactionOld.setEntryBook(financialTransaction.getEntryBook());
- financialTransactionOld.setTransactionDate(financialTransaction.getTransactionDate());
+ transactionTopiaDao.update(financialTransactionOld);
- transactionTopiaDao.update(financialTransactionOld);
- } catch (TopiaException ex) {
- throw new LimaException("Can't update financial transaction", ex);
- }
}
/**
@@ -501,46 +449,35 @@
* call accounting rules
*/
@Override
- public void removeFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
+ public void removeFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException {
// check if the financial period is blocked
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialTransaction);
- try {
-
- FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- FinancialTransaction financialTransactionOld = transactionTopiaDao.findByTopiaId(financialTransaction.getTopiaId());
- transactionTopiaDao.delete(financialTransactionOld);
-
- } catch (Exception ex) {
- throw new LimaException("Can't remove financial transaction", ex);
- }
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransaction financialTransactionOld = transactionTopiaDao.findByTopiaId(financialTransaction.getTopiaId());
+ transactionTopiaDao.delete(financialTransactionOld);
}
@Override
- public FinancialTransaction getFinancialTransactionWithId(String id) throws LimaException {
+ public FinancialTransaction getFinancialTransactionWithId(String id) {
FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
FinancialTransaction result = transactionTopiaDao.findByTopiaId(id);
return result;
}
@Override
- public Entry createEntry(Entry entry) throws LimaException {
+ public Entry createEntry(Entry entry) throws FinancialTransactionException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- Entry newEntry;
- try {
- //check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
- entry.getFinancialTransaction());
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
+ entry.getFinancialTransaction());
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- newEntry = entryTopiaDao.create(entry);
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ Entry newEntry = entryTopiaDao.create(entry);
- } catch (TopiaException ex) {
- throw new LimaException("Can't create entry", ex);
- }
return newEntry;
}
@@ -548,71 +485,55 @@
* update entry, calculate amount of the financial transaction.
*/
@Override
- public void updateEntry(Entry entry) throws LimaException {
+ public void updateEntry(Entry entry) throws EntryException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- Entry entryOld = entryTopiaDao.findByTopiaId(entry.getTopiaId());
+ Entry entryOld = entryTopiaDao.findByTopiaId(entry.getTopiaId());
- //check rules
- accountingRules.updateEntryRules(entry, entryOld);
+ //check rules
+ accountingRules.updateEntryRules(entry, entryOld);
- final Binder<Entry, Entry> binder = BinderFactory.newBinder(Entry.class, Entry.class);
- binder.copyExcluding(entry, entryOld, Entry.PROPERTY_TOPIA_ID, Entry.PROPERTY_TOPIA_CREATE_DATE);
- //update entry
- entryTopiaDao.update(entryOld);
+ final Binder<Entry, Entry> binder = BinderFactory.newBinder(Entry.class, Entry.class);
+ binder.copyExcluding(entry, entryOld, Entry.PROPERTY_TOPIA_ID, Entry.PROPERTY_TOPIA_CREATE_DATE);
+ //update entry
+ entryTopiaDao.update(entryOld);
- } catch (Exception ex) {
- throw new LimaException("Can't update entry", ex);
- }
}
/**
* Remove entry, update amounts for the financial transaction.
*/
@Override
- public void removeEntry(Entry entry) throws LimaException {
+ public void removeEntry(Entry entry) throws FinancialTransactionException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- try {
- FinancialTransaction financialTransaction = entry.getFinancialTransaction();
+ FinancialTransaction financialTransaction = entry.getFinancialTransaction();
- //check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialTransaction);
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialTransaction);
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- Entry entryOld = entryTopiaDao.findByTopiaId(entry.getTopiaId());
- entryOld.getFinancialTransaction().removeEntry(entryOld);
- entryTopiaDao.delete(entryOld);
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ Entry entryOld = entryTopiaDao.findByTopiaId(entry.getTopiaId());
+ entryOld.getFinancialTransaction().removeEntry(entryOld);
+ entryTopiaDao.delete(entryOld);
- } catch (TopiaException ex) {
- throw new LimaException("Can't remove entry", ex);
- }
}
@Override
- public List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionCondition financialTransactionCondition) throws LimaException {
- List<FinancialTransaction> result;
+ public List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionCondition financialTransactionCondition) {
FilterGenerator generator = new FilterGenerator();
financialTransactionCondition.accept(generator);
FinancialTransactionFilter filter = generator.getFilter();
+ // next on financial transaction dao
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ List<FinancialTransaction> result = financialTransactionTopiaDao.searchFinancialTransaction(filter);
- try {
- // next on financial transaction dao
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- result = financialTransactionTopiaDao.searchFinancialTransaction(filter);
-
-
- } catch (Exception ex) {
- throw new LimaException("Can't search financial transaction", ex);
- }
-
if (log.isDebugEnabled()) {
log.debug("Size of results list : " + result.size());
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,10 +29,11 @@
import org.apache.commons.lang3.time.DateUtils;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.business.AccountException;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
@@ -53,10 +54,8 @@
import org.chorem.lima.entity.FinancialPeriodTopiaDao;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionImpl;
-import org.chorem.lima.entity.FinancialTransactionTopiaDao;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.EJB;
import javax.ejb.Remote;
@@ -100,60 +99,53 @@
protected FinancialTransactionService financialTransactionService;
@Override
- public FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
+ public FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
- FiscalPeriod result;
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ // fix begin date at midnight and end date at 23:59:59.999
+ Date beginDate = fiscalPeriod.getBeginDate();
+ beginDate = DateUtils.truncate(beginDate, Calendar.DATE);
+ Date endDate = fiscalPeriod.getEndDate();
+ endDate = DateUtils.addDays(endDate, 1);
+ endDate = DateUtils.truncate(endDate, Calendar.DATE);
+ endDate = DateUtils.addMilliseconds(endDate, -1);
+ fiscalPeriod.setBeginDate(beginDate);
+ fiscalPeriod.setEndDate(endDate);
- // fix begin date at midnight and end date at 23:59:59.999
- Date beginDate = fiscalPeriod.getBeginDate();
- beginDate = DateUtils.truncate(beginDate, Calendar.DATE);
- Date endDate = fiscalPeriod.getEndDate();
- endDate = DateUtils.addDays(endDate, 1);
- endDate = DateUtils.truncate(endDate, Calendar.DATE);
- endDate = DateUtils.addMilliseconds(endDate, -1);
- fiscalPeriod.setBeginDate(beginDate);
- fiscalPeriod.setEndDate(endDate);
+ //check rules before create the account
+ List<FinancialPeriod> financialPeriods = accountingRules.createFiscalPeriodRules(fiscalPeriod);
- //check rules before create the account
- List<FinancialPeriod> financialPeriods = accountingRules.createFiscalPeriodRules(fiscalPeriod);
+ // create
+ fiscalPeriod.addAllFinancialPeriod(financialPeriods);
- // create
- fiscalPeriod.addAllFinancialPeriod(financialPeriods);
+ //create all financial period
+ for (FinancialPeriod financialPeriod : financialPeriods) {
- //create all financial period
- for (FinancialPeriod financialPeriod : financialPeriods) {
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = Lists.newArrayList();
+ //create ClosedPeriodicEntryBook for all entrybook
+ for (EntryBook entryBook : entryBookTopiaDao.findAll()) {
+ //new closed periodic entrybook
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl();
+ // set entrybook
+ closedPeriodicEntryBook.setEntryBook(entryBook);
+ // set financial period
+ closedPeriodicEntryBook.setFinancialPeriod(financialPeriod);
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = Lists.newArrayList();
- //create ClosedPeriodicEntryBook for all entrybook
- for (EntryBook entryBook : entryBookTopiaDao.findAll()) {
- //new closed periodic entrybook
- ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl();
- // set entrybook
- closedPeriodicEntryBook.setEntryBook(entryBook);
- // set financial period
- closedPeriodicEntryBook.setFinancialPeriod(financialPeriod);
-
- closedPeriodicEntryBooks.add(closedPeriodicEntryBook);
- }
- financialPeriod.addAllEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBooks);
-
+ closedPeriodicEntryBooks.add(closedPeriodicEntryBook);
}
+ financialPeriod.addAllEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBooks);
- result = fiscalPeriodTopiaDao.create(fiscalPeriod);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't create period", ex);
}
+ FiscalPeriod result = fiscalPeriodTopiaDao.create(fiscalPeriod);
+
return result;
}
@@ -161,18 +153,11 @@
* return all fiscal period.
*/
@Override
- public List<FiscalPeriod> getAllFiscalPeriods() throws LimaException {
+ public List<FiscalPeriod> getAllFiscalPeriods() {
- List<FiscalPeriod> result;
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ List<FiscalPeriod> result = fiscalPeriodTopiaDao.findAll();
- try {
-
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- result = fiscalPeriodTopiaDao.findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't get periods", ex);
- }
-
return result;
}
@@ -180,52 +165,32 @@
* return all blocked fiscal periods.
*/
@Override
- public List<FiscalPeriod> getAllBlockedFiscalPeriods() throws LimaException {
+ public List<FiscalPeriod> getAllBlockedFiscalPeriods() {
- List<FiscalPeriod> result;
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ List<FiscalPeriod> result = fiscalPeriodTopiaDao.forLockedEquals(true).findAll();
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- result = fiscalPeriodTopiaDao.forLockedEquals(true).findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't create period", ex);
- }
-
return result;
}
/** return all unblocked fiscal periods */
@Override
- public List<FiscalPeriod> getAllUnblockedFiscalPeriods() throws LimaException {
+ public List<FiscalPeriod> getAllUnblockedFiscalPeriods() {
- List<FiscalPeriod> result;
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ List<FiscalPeriod> result = fiscalPeriodTopiaDao.forLockedEquals(false).findAll();
- try {
-
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- result = fiscalPeriodTopiaDao.forLockedEquals(false).findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't get periods", ex);
- }
-
return result;
}
@Override
- public FiscalPeriod getLastFiscalPeriod() throws LimaException {
- FiscalPeriod result;
+ public FiscalPeriod getLastFiscalPeriod() {
- try {
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ //get the last fiscal period
+ FiscalPeriod result = fiscalPeriodTopiaDao.getLastFiscalPeriod();
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- //get the last fiscal period
- result = fiscalPeriodTopiaDao.getLastFiscalPeriod();
-
- } catch (Exception ex) {
- throw new LimaException("Can't get period", ex);
- }
-
return result;
}
@@ -235,43 +200,36 @@
* check localized rules before block it
*/
@Override
- public FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
+ public FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- FiscalPeriod result;
- try {
+ if (fiscalPeriod.isLocked()) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.fiscalperiod.fiscalperiodalreadyblocked");
+ }
+ //check rules
+ accountingRules.blockFiscalPeriodRules(fiscalPeriod);
- if (fiscalPeriod.isLocked()) {
- throw new LimaBusinessException(t("lima-business.fiscalperiod.fiscalperiodalreadyblocked"));
- }
- //check rules
- accountingRules.blockFiscalPeriodRules(fiscalPeriod);
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ // Get the old fiscal period instance for no object conflict
+ FiscalPeriod oldFiscalPeriod =
+ fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
- // Get the old fiscal period instance for no object conflict
- FiscalPeriod oldFiscalPeriod =
- fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
-
- // lock fiscalperiod
- oldFiscalPeriod.setLocked(true);
- // locked all financialperiod of the fiscalperiod
- for (FinancialPeriod financialPeriod : oldFiscalPeriod.getFinancialPeriod()) {
- financialPeriod.setLocked(true);
- }
-
- result = fiscalPeriodTopiaDao.update(oldFiscalPeriod);
-
- } catch (Exception ex) {
- throw new LimaException("Can't block period", ex);
+ // lock fiscalperiod
+ oldFiscalPeriod.setLocked(true);
+ // locked all financialperiod of the fiscalperiod
+ for (FinancialPeriod financialPeriod : oldFiscalPeriod.getFinancialPeriod()) {
+ financialPeriod.setLocked(true);
}
+ FiscalPeriod result = fiscalPeriodTopiaDao.update(oldFiscalPeriod);
+
return result;
}
@Override
- public boolean isRetainedEarnings(FiscalPeriod fiscalPeriod) throws LimaException{
+ public boolean isRetainedEarnings(FiscalPeriod fiscalPeriod) {
boolean found = false;
List<FinancialTransaction> financialTransactionsList =
financialTransactionService.getAllFinancialTransactions(
@@ -296,43 +254,32 @@
}
@Override
- public FiscalPeriod updateEndDate(FiscalPeriod fiscalPeriod) throws LimaException {
+ public FiscalPeriod updateEndDate(FiscalPeriod fiscalPeriod) {
- FiscalPeriod result;
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ String topiaId = fiscalPeriod.getTopiaId();
+ FiscalPeriod fiscalPeriodOld = fiscalPeriodTopiaDao.findByTopiaId(topiaId);
- String topiaId = fiscalPeriod.getTopiaId();
- FiscalPeriod fiscalPeriodOld = fiscalPeriodTopiaDao.findByTopiaId(topiaId);
+ Date endDate = fiscalPeriod.getEndDate();
+ fiscalPeriodOld.setEndDate(endDate);
- Date endDate = fiscalPeriod.getEndDate();
- fiscalPeriodOld.setEndDate(endDate);
+ FiscalPeriod result = fiscalPeriodTopiaDao.update(fiscalPeriodOld);
- result = fiscalPeriodTopiaDao.update(fiscalPeriodOld);
-
- } catch (TopiaException e) {
- throw new LimaException("Can't update period", e);
- }
-
return result;
}
@Override
public FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
- boolean retainedEarnings) throws LimaException {
+ boolean retainedEarnings) throws AccountException, FinancialTransactionException, FiscalPeriodException {
if (entryBook != null && retainedEarnings) {
// re-attach entities to current session
- FiscalPeriod localFiscalPeriod;
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- localFiscalPeriod = fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
- } catch (TopiaException ex) {
- throw new LimaException("Can't find fiscal period", ex);
- }
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ FiscalPeriod localFiscalPeriod = fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
+
//if entrybook isn't found
//then create it
if (!entryBook.isPersisted()) {
@@ -406,7 +353,7 @@
}
}
if (beginfinancialPeriod == null) {
- throw new LimaBusinessException(t("lima-business.fiscalperiod.newfinancialperioderror"));
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.fiscalperiod.newfinancialperioderror");
}
//holds entries of all closing transactions
@@ -496,43 +443,30 @@
* check localized rules before delete it
*/
@Override
- public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod)
- throws LimaException {
+ public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ //get entities with TopiaDao
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- try {
- try {
- //get entities with TopiaDao
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ // re-attach entities to current session
+ FiscalPeriod localFiscalPeriod = fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
- // re-attach entities to current session
- FiscalPeriod localFiscalPeriod = fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
+ //check rules
+ accountingRules.deleteFiscalPeriodRules(localFiscalPeriod);
- //check rules
- accountingRules.deleteFiscalPeriodRules(localFiscalPeriod);
+ //all "ClosedPeriodicEntryBooks" for the fiscal period
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookTopiaDaoList = closedPeriodicEntryBookTopiaDao.findAllClosedPeriodicEntryBooksFromFiscalPeriod(localFiscalPeriod);
- //all "ClosedPeriodicEntryBooks" for the fiscal period
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBookTopiaDaoList = closedPeriodicEntryBookTopiaDao.findAllClosedPeriodicEntryBooksFromFiscalPeriod(localFiscalPeriod);
-
- //delete closedPeriodicEntryBook before fiscal period
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookTopiaDaoList) {
- // fix : ObjectDeletedException: deleted object would be re-saved by cascade (Need to delete association between entryBook and financial period via closedPeriodEntityBook)
- closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
- closedPeriodicEntryBookTopiaDao.delete(closedPeriodicEntryBook);
- }
-
- fiscalPeriodTopiaDao.delete(localFiscalPeriod);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't find fiscal period", ex);
- }
-
- } catch (Exception ex) {
- throw new LimaException("Can't delete period", ex);
+ //delete closedPeriodicEntryBook before fiscal period
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookTopiaDaoList) {
+ // fix : ObjectDeletedException: deleted object would be re-saved by cascade (Need to delete association between entryBook and financial period via closedPeriodEntityBook)
+ closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ closedPeriodicEntryBookTopiaDao.delete(closedPeriodicEntryBook);
}
+ fiscalPeriodTopiaDao.delete(localFiscalPeriod);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,29 +25,6 @@
package org.chorem.lima.business.ejb;
-import static org.nuiton.i18n.I18n.t;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@@ -55,7 +32,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.DocumentService;
import org.chorem.lima.business.api.HttpServerService;
@@ -69,6 +45,28 @@
import org.nuiton.util.FileUtil;
import org.nuiton.util.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+
@Stateless
@Remote(HttpServerService.class)
@TransactionAttribute
@@ -215,8 +213,6 @@
autocomplete);
break;
}
- } catch (LimaException eeeLE) {
- log.error("Can't call document service for create html document", eeeLE);
} catch (ParseException eeePE) {
log.error("Can't parse date", eeePE);
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,53 +25,40 @@
package org.chorem.lima.business.ejb;
-import java.util.List;
+import org.chorem.lima.business.api.IdentityService;
+import org.chorem.lima.entity.Identity;
+import org.chorem.lima.entity.IdentityTopiaDao;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
+import java.util.List;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.api.IdentityService;
-import org.chorem.lima.entity.Identity;
-import org.chorem.lima.entity.IdentityTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
-
@Stateless
@Remote(IdentityService.class)
@TransactionAttribute
public class IdentityServiceImpl extends AbstractLimaService implements IdentityService {
@Override
- public Identity getIdentity()
- throws LimaException {
+ public Identity getIdentity() {
Identity identity = null;
- try {
- IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
- List<Identity> identities = identityTopiaDao.findAll();
- if (identities.size() != 0) {
- identity = identities.get(0);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't get identity", ex);
+ IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
+ List<Identity> identities = identityTopiaDao.findAll();
+ if (identities.size() != 0) {
+ identity = identities.get(0);
}
return identity;
}
@Override
- public void updateIdentity(Identity identity) throws LimaException {
- try {
- IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
- List<Identity> identities = identityTopiaDao.findAll();
- if (identities.size() != 0) {
- identityTopiaDao.delete(identities.get(0));
- }
- identityTopiaDao.create(identity);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't update identity", ex);
+ public void updateIdentity(Identity identity) {
+ IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
+ List<Identity> identities = identityTopiaDao.findAll();
+ if (identities.size() != 0) {
+ identityTopiaDao.delete(identities.get(0));
}
+ identityTopiaDao.create(identity);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,31 +25,9 @@
package org.chorem.lima.business.ejb;
-import static org.nuiton.i18n.I18n.t;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
+import au.com.bytecode.opencsv.CSVReader;
+import au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy;
+import au.com.bytecode.opencsv.bean.CsvToBean;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -72,9 +50,11 @@
import org.chorem.lima.beans.FinancialTransactionImportImpl;
import org.chorem.lima.beans.VatStatementImport;
import org.chorem.lima.beans.VatStatementImportImpl;
-import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.ImportEbpException;
import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ClosedPeriodicEntryBookService;
import org.chorem.lima.business.api.EntryBookService;
@@ -86,6 +66,7 @@
import org.chorem.lima.business.api.IdentityService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.business.api.VatStatementService;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.EntryEBPComparator;
import org.chorem.lima.business.utils.FiscalPeriodComparator;
@@ -110,10 +91,30 @@
import org.chorem.lima.entity.VatStatementImpl;
import org.nuiton.topia.persistence.TopiaException;
-import au.com.bytecode.opencsv.CSVReader;
-import au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy;
-import au.com.bytecode.opencsv.bean.CsvToBean;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import static org.nuiton.i18n.I18n.t;
+
/**
* Import export service.
* Currently import and export as CSV and EBP.
@@ -176,10 +177,10 @@
// ################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################
@Override
- public String importEntriesFromEbp(String datas) throws LimaException {
+ public String importEntriesFromEbp(String datas) throws ImportEbpException{
if (datas.isEmpty()) {
- throw new LimaBusinessException(t("lima-business.import.ebpnoentry"));
+ throw new ImportEbpException(t("lima-business.import.ebpnoentry"));
}
// use for logs
@@ -219,7 +220,7 @@
headEntry.add(EntryEBP.PROPERTY_CREDIT);
headEntry.add(EntryEBP.PROPERTY_LETTRE);
if (!Arrays.asList(strat.getColumnMapping()).containsAll(headEntry)) {
- throw new LimaBusinessException(
+ throw new ImportEbpException(
t("lima-business.import.ebpnoheader"));
}
@@ -236,7 +237,7 @@
// There are no valid fiscalPeriods -> exception
int nbFiscalPeriods = fiscalPeriods.size();
if (nbFiscalPeriods == 0) {
- throw new LimaBusinessException(
+ throw new ImportEbpException(
t("lima-business.import.nofiscalperiodopen"));
}
@@ -270,7 +271,7 @@
// if account not exist not export -> exception
else if (account == null) {
//// TODO DCossé 28/05/14 this message is not displayed on user's error window.
- throw new LimaBusinessException(t(
+ throw new ImportEbpException(t(
"lima-business.import.ebpmissingaccount",
entryEBP.getCompte()));
}
@@ -354,8 +355,12 @@
log.info("Imported form EBP : " + list.size() + " entries in "
+ (after - before) + " ms");
}
- } catch (Exception ex) {
- throw new LimaException("Can't import", ex);
+ } catch (ParseException e) {
+ throw new ImportEbpException("Can't import ", e);
+ } catch (IOException e) {
+ throw new ImportEbpException("Can't import ", e);
+ } catch (FinancialTransactionException e) {
+ throw new ImportEbpException("Can't import ", e);
} finally {
if (csvReader != null) {
try {
@@ -369,7 +374,7 @@
}
@Override
- public String importAccountsChartFromEbp(String datas) throws LimaException {
+ public String importAccountsChartFromEbp(String datas) throws ImportEbpException{
long before = System.currentTimeMillis();
List<Account> accounts = accountService.getAllAccounts();
if (accounts == null) {
@@ -417,7 +422,7 @@
line = csvReader.readNext();
}
} else {
- throw new LimaBusinessException(
+ throw new ImportEbpException(
t("lima-business.import.noaccount"));
}
@@ -427,8 +432,10 @@
+ (after - before) + " ms");
}
- } catch (Exception ex) {
- throw new LimaException("Can't import", ex);
+ } catch (AccountException e) {
+ throw new ImportEbpException("Can't import", e);
+ } catch (IOException e) {
+ throw new ImportEbpException("Can't import", e);
} finally {
if (csvReader != null) {
try {
@@ -442,7 +449,7 @@
}
@Override
- public String importEntryBookFromEbp(String datas) throws LimaException {
+ public String importEntryBookFromEbp(String datas) throws ImportEbpException{
long before = System.currentTimeMillis();
List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
@@ -473,7 +480,7 @@
// check if file have a good header
if (entryBookCodeIndex == null || entryBookLabelIndex == null) {
- throw new LimaBusinessException(
+ throw new ImportEbpException(
t("lima-business.import.noaccount"));
}
@@ -500,8 +507,8 @@
log.info("Imported form EBP : " + count + " accounts in " + (after-before) + " ms");
}
- } catch (Exception ex) {
- throw new LimaException("Can't import", ex);
+ } catch (IOException e) {
+ throw new ImportEbpException("Can't import", e);
} finally {
if (csvReader != null) {
try {
@@ -520,7 +527,7 @@
/** Remote methode to call all entities import from UI */
@Override
- public String importAllAsCSV(String datas) throws LimaException {
+ public String importAllAsCSV(String datas) throws ImportEbpException {
StringBuilder result = new StringBuilder();
Map<String, List<FinancialStatementImport>> financialStatements =
@@ -600,8 +607,8 @@
result.append(createFinancialTransactionsAndEntries(
financialTransactions, entries));
- } catch (Exception ex) {
- throw new LimaException("Can't import", ex);
+ } catch (IOException e) {
+ throw new ImportEbpException("Can't import", e);
} finally {
if (csvReader != null) {
try {
@@ -620,8 +627,7 @@
*/
@Override
public String importAsCSV(String datas,
- ImportExportEntityEnum importExportEntityEnum)
- throws LimaException {
+ ImportExportEntityEnum importExportEntityEnum) throws ImportEbpException {
StringBuilder result = new StringBuilder();
// FinancialStatements
@@ -707,8 +713,8 @@
break;
}
- } catch (Exception ex) {
- throw new LimaException("Can't import", ex);
+ } catch (IOException e) {
+ throw new ImportEbpException("Can't import", e);
} finally {
if (csvReader != null) {
try {
@@ -724,7 +730,7 @@
@Override
public String importAsPDF(String datas,
ImportExportEntityEnum importExportEntityEnum,
- boolean setMode) throws LimaException {
+ boolean setMode) {
StringBuilder result = new StringBuilder();
@@ -786,15 +792,13 @@
*
* @param nextLine The line to import
* @return Success or error message
- * @throws LimaException If the line format is invalid
- * @throws TopiaException
+ * @throws ImportEbpException If the line format is invalid
*/
- protected String importAccountsChartsCSV(String[] nextLine)
- throws LimaException, TopiaException {
+ protected String importAccountsChartsCSV(String[] nextLine) throws ImportEbpException{
// Check line format
if (nextLine.length < 3
|| ! nextLine[0].equals(ImportExportEntityEnum.ACCOUNT.getLabel())) {
- throw new LimaException(t("lima-business.import.lineformatmismatch"));
+ throw new ImportEbpException(t("lima-business.import.lineformatmismatch"));
}
StringBuilder result = new StringBuilder();
@@ -812,7 +816,11 @@
account.setThirdParty(thirdParty);
}
- accountService.createAccount(account);
+ try {
+ accountService.createAccount(account);
+ } catch (AccountException e) {
+ result.append(t("lima-business.import.accountalreadyexist", accountNumber));
+ }
result.append(t("lima-business.import.accountadded",
account.getAccountNumber(),
account.getLabel()));
@@ -830,26 +838,28 @@
* @param nextLine
* @param fiscalPeriods
* @return
- * @throws ParseException
- * @throws TopiaException
+ * @throws ParseException
*/
protected String importFiscalPeriodCSV(String[] nextLine,
- List<FiscalPeriod> fiscalPeriods)
- throws ParseException, TopiaException {
+ List<FiscalPeriod> fiscalPeriods) {
StringBuilder result = new StringBuilder();
- FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
- Date beginDate = SDATEFORMAT.parse(nextLine[1]);
- fiscalPeriod.setBeginDate(beginDate);
- Date endDate = SDATEFORMAT.parse(nextLine[2]);
- fiscalPeriod.setEndDate(endDate);
- fiscalPeriod.setLocked(Boolean.parseBoolean(nextLine[3]));
+ try {
+ FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
+ Date beginDate = SDATEFORMAT.parse(nextLine[1]);
+ fiscalPeriod.setBeginDate(beginDate);
+ Date endDate = SDATEFORMAT.parse(nextLine[2]);
+ fiscalPeriod.setEndDate(endDate);
+ fiscalPeriod.setLocked(Boolean.parseBoolean(nextLine[3]));
- // if not exist, skip
- if (financialPeriodService.getFinancialPeriods(beginDate, endDate) == null) {
- fiscalPeriods.add(fiscalPeriod);
- } else {
- result.append(t("lima-business.import.fiscalperiodalreadyexist", beginDate, endDate));
+ // if not exist, skip
+ if (financialPeriodService.getFinancialPeriods(beginDate, endDate) == null) {
+ fiscalPeriods.add(fiscalPeriod);
+ } else {
+ result.append(t("lima-business.import.fiscalperiodalreadyexist", beginDate, endDate));
+ }
+ } catch (ParseException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
}
return result.toString();
@@ -860,10 +870,8 @@
*
* @param nextLine
* @return
- * @throws TopiaException
- * @throws LimaException
*/
- protected String importEntryBooksChartCSV(String[] nextLine) throws TopiaException, LimaException {
+ protected String importEntryBooksChartCSV(String[] nextLine) {
StringBuilder result = new StringBuilder();
EntryBook entryBook = new EntryBookImpl();
@@ -888,10 +896,9 @@
*
* @param nextLine
* @param closedPeriodicEntryBooks
- * @throws LimaException
*/
protected void importClosedPeriodicEntryBookCSV(String[] nextLine,
- List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks) throws LimaException {
+ List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks) {
String locked = nextLine[1];
String beginDate = nextLine[2];
String endDate = nextLine[3];
@@ -918,11 +925,9 @@
* @param nextLine
* @param financialStatements
* @return
- * @throws LimaException
- * @throws TopiaException
*/
protected String importFinancialsStatementChartCSV(String[] nextLine,
- Map<String, List<FinancialStatementImport>> financialStatements) throws LimaException, TopiaException {
+ Map<String, List<FinancialStatementImport>> financialStatements) {
StringBuilder result = new StringBuilder();
String label = StringUtils.trimToNull(nextLine[1]);
@@ -976,11 +981,9 @@
* @param nextLine
* @param vatStatements
* @return
- * @throws LimaException
- * @throws TopiaException
*/
protected String importVatStatementChartCSV(String[] nextLine,
- Map<String, List<VatStatementImport>> vatStatements) throws LimaException, TopiaException {
+ Map<String, List<VatStatementImport>> vatStatements) {
StringBuilder result = new StringBuilder();
@@ -1022,10 +1025,9 @@
*
* @param nextLine
* @param financialTransactions
- * @throws LimaException
*/
protected void importFinancialTransactionsCSV(String[] nextLine,
- Map<Integer, FinancialTransactionImport> financialTransactions) throws LimaException {
+ Map<Integer, FinancialTransactionImport> financialTransactions) {
int num = new Integer(nextLine[1]);
FinancialTransactionImport financialTransactionImport = new FinancialTransactionImportImpl();
financialTransactionImport.setDate(nextLine[2]);
@@ -1042,10 +1044,9 @@
*
* @param nextLine
* @param entries
- * @throws LimaException
*/
protected void importEntriesCSV(String[] nextLine,
- Map<Integer, List<EntryImport>> entries) throws LimaException {
+ Map<Integer, List<EntryImport>> entries) {
int num = new Integer(nextLine[1]);
EntryImport entryImport = new EntryImportImpl();
@@ -1075,7 +1076,7 @@
* @deprecated do only one method import without bean use (and remove beans)
*/
@Deprecated
- protected String createFinancialStatements(Map<String, List<FinancialStatementImport>> financialStatements) throws LimaException, TopiaException {
+ protected String createFinancialStatements(Map<String, List<FinancialStatementImport>> financialStatements) {
StringBuilder result = new StringBuilder();
while (financialStatements.size() > 0) {
@@ -1155,7 +1156,7 @@
* @deprecated do only one method import without bean use (and remove beans)
*/
@Deprecated
- protected String createVatStatements(Map<String, List<VatStatementImport>> vatStatements) throws LimaException, TopiaException {
+ protected String createVatStatements(Map<String, List<VatStatementImport>> vatStatements) {
StringBuilder result = new StringBuilder();
@@ -1221,8 +1222,8 @@
result.append(t("lima-business.import.fiscalperiodadded",
fiscalPeriod.getBeginDate(),
fiscalPeriod.getEndDate()));
- } catch (LimaException eee) {
- result.append(t("lima-business.common.failed", eee.getMessage()));
+ } catch (FiscalPeriodException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
}
}
return result.toString();
@@ -1235,31 +1236,34 @@
*/
@Deprecated
protected String updateClosedPeriodicEntryBooks(
- List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks) throws LimaException, ParseException, TopiaException {
+ List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks) {
StringBuilder result = new StringBuilder();
for (ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport : closedPeriodicEntryBooks) {
// update closedPeriodicEntryBook
- Date beginDateFinancialPeriod = SDATEFORMAT
- .parse(closedPeriodicEntryBookImport
- .getBeginDateFinancialPeriod());
- Date endDateFinancialPeriod = SDATEFORMAT
- .parse(closedPeriodicEntryBookImport
- .getEndDateFinancialPeriod());
- FinancialPeriod financialPeriod = financialPeriodService.getFinancialPeriodByNaturalIds(beginDateFinancialPeriod, endDateFinancialPeriod);
+ try {
+ Date beginDateFinancialPeriod = SDATEFORMAT
+ .parse(closedPeriodicEntryBookImport
+ .getBeginDateFinancialPeriod());
+ Date endDateFinancialPeriod = SDATEFORMAT
+ .parse(closedPeriodicEntryBookImport
+ .getEndDateFinancialPeriod());
+ FinancialPeriod financialPeriod = financialPeriodService.getFinancialPeriodByNaturalIds(beginDateFinancialPeriod, endDateFinancialPeriod);
- String codeEntryBook = closedPeriodicEntryBookImport
- .getCodeEntryBook();
- EntryBook entryBook = entryBookService.getEntryBookByCode(codeEntryBook);
- ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookService.getByEntryBookAndFinancialPeriod(entryBook,
- financialPeriod);
- try {
+ String codeEntryBook = closedPeriodicEntryBookImport
+ .getCodeEntryBook();
+ EntryBook entryBook = entryBookService.getEntryBookByCode(codeEntryBook);
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookService.getByEntryBookAndFinancialPeriod(entryBook,
+ financialPeriod);
+
financialPeriodService
.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
result.append(t("lima-business.import.closedperiodicentrybookupdated",
beginDateFinancialPeriod, endDateFinancialPeriod, codeEntryBook));
- } catch (LimaException eee) {
- result.append(t("lima-business.common.failed", eee));
+ } catch (ParseException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
+ } catch (ClosedPeriodicEntryBookException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
}
}
@@ -1267,52 +1271,60 @@
}
/**
- * @throws ParseException
- * @throws TopiaException
* @deprecated do only one method import without bean use (and remove beans)
*/
@Deprecated
protected String createFinancialTransactionsAndEntries(
Map<Integer, FinancialTransactionImport> financialTransactions,
- Map<Integer, List<EntryImport>> entries)
- throws LimaException, ParseException, TopiaException {
+ Map<Integer, List<EntryImport>> entries) {
+ StringBuilder result = new StringBuilder();
+
for (Map.Entry<Integer, FinancialTransactionImport> map : financialTransactions
.entrySet()) {
- FinancialTransactionImport financialTransactionImport = map
- .getValue();
- FinancialTransaction financialTransaction = new FinancialTransactionImpl();
- Date dateFinancialTransaction = SDATEFORMAT
- .parse(financialTransactionImport.getDate());
- financialTransaction
- .setTransactionDate(dateFinancialTransaction);
+ try {
+ FinancialTransactionImport financialTransactionImport = map
+ .getValue();
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ Date dateFinancialTransaction = null;
- EntryBook entryBook = entryBookService.getEntryBookByCode(financialTransactionImport
- .getCodeEntryBook());
- financialTransaction.setEntryBook(entryBook);
+ dateFinancialTransaction = SDATEFORMAT
+ .parse(financialTransactionImport.getDate());
+ financialTransaction
+ .setTransactionDate(dateFinancialTransaction);
- financialTransactionService.createFinancialTransaction(financialTransaction);
+ EntryBook entryBook = entryBookService.getEntryBookByCode(financialTransactionImport
+ .getCodeEntryBook());
+ financialTransaction.setEntryBook(entryBook);
- List<EntryImport> entryImports = entries.get(map.getKey());
- for (EntryImport entryImport : entryImports) {
- Entry entry = new EntryImpl();
- Account account = accountService.getAccountByNumber(entryImport.getAccount());
- entry.setAccount(account);
- entry.setDescription(StringUtils.trimToNull(entryImport.getDescription()));
- entry.setAmount(new BigDecimal(entryImport.getAmount()));
- entry.setDebit(Boolean.parseBoolean(entryImport.getDebit()));
- entry.setLettering(StringUtils.trimToNull(entryImport.getLettering()));
- entry.setDetail(StringUtils.trimToNull(entryImport.getDetail()));
- entry.setVoucher(StringUtils.trimToNull(entryImport.getVoucher()));
- entry.setPosition(StringUtils.trimToNull(entryImport.getPosition()));
- entryService.createEntry(entry);
- financialTransaction.addEntry(entry);
+ financialTransactionService.createFinancialTransaction(financialTransaction);
+
+ List<EntryImport> entryImports = entries.get(map.getKey());
+ for (EntryImport entryImport : entryImports) {
+ Entry entry = new EntryImpl();
+ Account account = accountService.getAccountByNumber(entryImport.getAccount());
+ entry.setAccount(account);
+ entry.setDescription(StringUtils.trimToNull(entryImport.getDescription()));
+ entry.setAmount(new BigDecimal(entryImport.getAmount()));
+ entry.setDebit(Boolean.parseBoolean(entryImport.getDebit()));
+ entry.setLettering(StringUtils.trimToNull(entryImport.getLettering()));
+ entry.setDetail(StringUtils.trimToNull(entryImport.getDetail()));
+ entry.setVoucher(StringUtils.trimToNull(entryImport.getVoucher()));
+ entry.setPosition(StringUtils.trimToNull(entryImport.getPosition()));
+ entryService.createEntry(entry);
+ financialTransaction.addEntry(entry);
+ }
+ } catch (ParseException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
+ } catch (FinancialTransactionException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
}
+
}
- return "";
+ return result.toString();
}
- protected String importIdentity(String[] nextLine) throws LimaException {
+ protected String importIdentity(String[] nextLine) {
StringBuilder result = new StringBuilder();
Identity identity = new IdentityImpl();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,9 +26,10 @@
package org.chorem.lima.business.ejb;
import com.google.common.collect.Lists;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.LimaTechnicalException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialTransactionService;
@@ -49,9 +50,7 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
import org.nuiton.csv.Export;
-import org.apache.commons.codec.binary.Base64;
-
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.Stateless;
@@ -59,13 +58,13 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import static org.nuiton.i18n.I18n.t;
-
/**
* CSV import export service.
*
@@ -91,7 +90,7 @@
private FinancialTransactionService financialTransactionService;
@Override
- public String exportAllAsCSV(String charset) throws LimaException {
+ public String exportAllAsCSV(String charset) {
ByteArrayOutputStream rstBao = new ByteArrayOutputStream();
ZipOutputStream export = null;
try {
@@ -119,7 +118,7 @@
export.flush();
} catch (Exception e) {
- throw new LimaException("Can't export All",e);
+ throw new LimaTechnicalException(e);
} finally {
IOUtils.closeQuietly(export);
}
@@ -140,14 +139,18 @@
}
@Override
- public String exportAccountsStream(String charset) throws LimaException {
+ public String exportAccountsStream(String charset) {
String result;
try {
File file = exportAccountsFile(charset);
FileInputStream inputStream = new FileInputStream(file);
result = IOUtils.toString(inputStream);
- } catch (Exception ex) {
- throw new LimaException("Can't export accounts", ex);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
+ } catch (Exception e) {
+ throw new LimaTechnicalException(e);
}
return result;
}
@@ -166,14 +169,18 @@
@Override
- public String exportEntryBooksStream(String charset) throws LimaException {
+ public String exportEntryBooksStream(String charset) {
String result;
try {
File file = exportEntryBooksFile(charset);
FileInputStream inputStream = new FileInputStream(file);
result = IOUtils.toString(inputStream);
- } catch (Exception ex) {
- throw new LimaException("Can't export entry books", ex);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
+ } catch (Exception e) {
+ throw new LimaTechnicalException(e);
}
return result;
}
@@ -192,14 +199,18 @@
}
@Override
- public String exportFiscalPeriodsStream(String charset) throws LimaException {
+ public String exportFiscalPeriodsStream(String charset) {
String result;
try {
File file = exportFiscalPeriodFile(charset);
FileInputStream inputStream = new FileInputStream(file);
result = IOUtils.toString(inputStream);
- } catch (Exception ex) {
- throw new LimaException("Can't export financial transactions", ex);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
+ } catch (Exception e) {
+ throw new LimaTechnicalException(e);
}
return result;
}
@@ -220,14 +231,18 @@
}
@Override
- public String exportFinancialTransactionsAsStream(String charset) throws LimaException {
+ public String exportFinancialTransactionsAsStream(String charset) {
String result;
try {
File file = exportFinancialTransactionsFile(charset);
FileInputStream inputStream = new FileInputStream(file);
result = IOUtils.toString(inputStream);
- } catch (Exception ex) {
- throw new LimaException("Can't export financial transactions", ex);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
+ } catch (Exception e) {
+ throw new LimaTechnicalException(e);
}
return result;
}
@@ -244,14 +259,18 @@
}
@Override
- public String exportEntriesAsCSV(String charset) throws LimaException {
+ public String exportEntriesAsCSV(String charset) {
String result;
try {
File file = exportEntriesFile(charset);
FileInputStream inputStream = new FileInputStream(file);
result = IOUtils.toString(inputStream);
- } catch (Exception ex) {
- throw new LimaException("Can't export financial transactions", ex);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
+ } catch (Exception e) {
+ throw new LimaTechnicalException(e);
}
return result;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -6,7 +6,7 @@
import com.google.common.collect.Maps;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.LimaTechnicalException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialTransactionService;
@@ -35,7 +35,9 @@
import javax.ejb.TransactionAttribute;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.List;
@@ -60,7 +62,7 @@
private FinancialTransactionService financialTransactionService;
@Override
- public void importAccountAsCSV(String contents) throws LimaException {
+ public void importAccountAsCSV(String contents) {
InputStream contentStream = IOUtils.toInputStream(contents);
try {
@@ -84,7 +86,7 @@
}
@Override
- public void importEntryBooksAsCSV(String contents) throws LimaException {
+ public void importEntryBooksAsCSV(String contents) {
InputStream contentStream = IOUtils.toInputStream(contents);
try {
ImportModel<EntryBook> model = new EntryBookModel();
@@ -98,7 +100,7 @@
}
@Override
- public void importFiscalPeriodsAsCSV(String contents) throws LimaException {
+ public void importFiscalPeriodsAsCSV(String contents) {
InputStream contentStream = IOUtils.toInputStream(contents);
try {
ImportModel<FiscalPeriod> model = new FiscalPeriodModel();
@@ -112,7 +114,7 @@
}
@Override
- public void importFinancialTransactionsAsCSV(String contents) throws LimaException {
+ public void importFinancialTransactionsAsCSV(String contents) {
// import and save FinancialTransactions
InputStream contentStream = IOUtils.toInputStream(contents);
try {
@@ -134,7 +136,7 @@
};
@Override
- public void importEntriesAsCSV(String contents) throws LimaException {
+ public void importEntriesAsCSV(String contents) {
// import and save entries
InputStream contentStream = IOUtils.toInputStream(contents);
try {
@@ -165,7 +167,7 @@
}
@Override
- public void importAllAsCSV(String zippedBase64Str) throws LimaException {
+ public void importAllAsCSV(String zippedBase64Str) {
ZipInputStream zipInputStream = null;
InputStream transactionsStream = null, entryBooksStream = null, fiscalPeriodsStream = null, entriesStream = null, accountsStream = null;
@@ -225,8 +227,10 @@
String accountsStreamString = IOUtils.toString(accountsStream);
importAccountAsCSV(accountsStreamString);
- } catch (Exception e) {
- throw new LimaException("Could not import", e);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
IOUtils.closeQuietly(zipInputStream);
IOUtils.closeQuietly(transactionsStream);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -80,49 +80,44 @@
*/
@Override
public ReportsDatas generateAccountsReports(Account account, Boolean thirdPartAccountsMode,
- Date beginDate, Date endDate) throws LimaException {
- ReportsDatas reportsDatas;
+ Date beginDate, Date endDate) {
- try {
- BigDecimal credit = new BigDecimal(0);
- BigDecimal debit = new BigDecimal(0);
- BigDecimal solde = new BigDecimal(0);
- List<Entry> entries = new ArrayList<Entry>();
+ BigDecimal credit = new BigDecimal(0);
+ BigDecimal debit = new BigDecimal(0);
+ BigDecimal solde = new BigDecimal(0);
+ List<Entry> entries = new ArrayList<Entry>();
- reportsDatas = generateSubAccountReports(account,
+ ReportsDatas reportsDatas = generateSubAccountReports(account,
+ beginDate, endDate);
+ debit = debit.add(reportsDatas.getAmountDebit());
+ credit = credit.add(reportsDatas.getAmountCredit());
+ entries.addAll(reportsDatas.getListEntry());
+
+ //Get allsubaccounts and thirdParts accounts
+ List<Account> accounts = accountService.getAllSubAccounts(account);
+
+ for (Account subAccount : accounts) {
+ reportsDatas = generateSubAccountReports(subAccount,
beginDate, endDate);
debit = debit.add(reportsDatas.getAmountDebit());
credit = credit.add(reportsDatas.getAmountCredit());
entries.addAll(reportsDatas.getListEntry());
+ }
- //Get allsubaccounts and thirdParts accounts
- List<Account> accounts = accountService.getAllSubAccounts(account);
+ //solde = debit - credit
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
- for (Account subAccount : accounts) {
- reportsDatas = generateSubAccountReports(subAccount,
- beginDate, endDate);
- debit = debit.add(reportsDatas.getAmountDebit());
- credit = credit.add(reportsDatas.getAmountCredit());
- entries.addAll(reportsDatas.getListEntry());
- }
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ reportsDatas.setSoldeDebit(true);
+ }
+ solde = solde.abs();
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
- //solde = debit - credit
- solde = solde.add(debit);
- solde = solde.subtract(credit);
+ reportsDatas.setListEntry(entries);
- if (solde.compareTo(BigDecimal.ZERO) == 1) {
- reportsDatas.setSoldeDebit(true);
- }
- solde = solde.abs();
- reportsDatas.setAmountCredit(credit);
- reportsDatas.setAmountDebit(debit);
- reportsDatas.setAmountSolde(solde);
-
- reportsDatas.setListEntry(entries);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't generate report", ex);
- }
return reportsDatas;
}
@@ -134,11 +129,9 @@
* @param beginDate
* @param endDate
* @return
- * @throws LimaException
- * @throws TopiaException
*/
protected ReportsDatas generateSubAccountReports(Account account,
- Date beginDate, Date endDate) throws TopiaException {
+ Date beginDate, Date endDate) {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
@@ -189,7 +182,7 @@
* @throws TopiaException
*/
public ReportsDatas generateSubAccountBalance(Account account,
- Date beginDate, Date endDate, Boolean getEntries) throws LimaException, TopiaException {
+ Date beginDate, Date endDate, Boolean getEntries) {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
@@ -243,48 +236,44 @@
*/
@Override
public ReportsDatas generateEntryBooksReports(EntryBook entryBook,
- Date beginDate, Date endDate) throws LimaException {
+ Date beginDate, Date endDate) {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
// Get all entries with a topia query
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- List<Entry> entries = entryTopiaDao.findAllEntryOfBalancedTransaction(entryBook, beginDate, endDate);
- reportsDatas.setListEntry(entries);
-
- List<Object[]> results = entryTopiaDao.getDebitCreditOfBalancedTransaction(entryBook, beginDate, endDate);
- int nbAmount = results.size();
- if (nbAmount == 2) {
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ List<Entry> entries = entryTopiaDao.findAllEntryOfBalancedTransaction(entryBook, beginDate, endDate);
+ reportsDatas.setListEntry(entries);
+
+ List<Object[]> results = entryTopiaDao.getDebitCreditOfBalancedTransaction(entryBook, beginDate, endDate);
+ int nbAmount = results.size();
+ if (nbAmount == 2) {
+ debit = (BigDecimal) results.get(0)[1];
+ credit = (BigDecimal) results.get(1)[1];
+ }
+ if (nbAmount == 1) {
+ if ((Boolean) results.get(0)[0]) {
debit = (BigDecimal) results.get(0)[1];
- credit = (BigDecimal) results.get(1)[1];
+ } else {
+ credit = (BigDecimal) results.get(0)[1];
}
- if (nbAmount == 1) {
- if ((Boolean) results.get(0)[0]) {
- debit = (BigDecimal) results.get(0)[1];
- } else {
- credit = (BigDecimal) results.get(0)[1];
- }
- }
+ }
- // set the amounts and solde
- //solde = debit - credit;
- solde = solde.add(debit);
- solde = solde.subtract(credit);
- if (solde.compareTo(BigDecimal.ZERO) == 1) {
- reportsDatas.setSoldeDebit(true);
- }
- solde = solde.abs();
-
- reportsDatas.setAmountCredit(credit);
- reportsDatas.setAmountDebit(debit);
- reportsDatas.setAmountSolde(solde);
- } catch (TopiaException ex) {
- throw new LimaException("Can't generate report", ex);
+ // set the amounts and solde
+ //solde = debit - credit;
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ reportsDatas.setSoldeDebit(true);
}
+ solde = solde.abs();
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+
return reportsDatas;
}
@@ -304,74 +293,69 @@
Date endDate,
String selectedAccounts,
Boolean getEntries,
- Boolean movementedFilter) throws LimaException {
+ Boolean movementedFilter) {
BalanceTrial balanceTrial = new BalanceTrialImpl();
balanceTrial.setReportsDatas(new ArrayList<ReportsDatas>());
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
- try {
+ AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
+ //for each account create a balance sheet with a ReportsDatas
- AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
- //for each account create a balance sheet with a ReportsDatas
+ List<Account> accounts;
- List<Account> accounts;
+ //Remove Spaces
+ // TODO DCossé 12/06/14 selectedAccounts is allways NULL
+ String result = StringUtils.deleteWhitespace(selectedAccounts);
+ //if no filter account
+ if (result == null || result.equals("")) {
+ accounts = accountTopiaDao.findAll();
+ }
+ //build list account from selectedAccounts
+ else {
+ accounts = accountService.stringToListAccounts(result);
+ }
- //Remove Spaces
- // TODO DCossé 12/06/14 selectedAccounts is allways NULL
- String result = StringUtils.deleteWhitespace(selectedAccounts);
- //if no filter account
- if (result == null || result.equals("")) {
- accounts = accountTopiaDao.findAll();
- }
- //build list account from selectedAccounts
- else {
- accounts = accountService.stringToListAccounts(result);
- }
+ Collections.sort(accounts, new AccountComparator());
- Collections.sort(accounts, new AccountComparator());
-
- for (Account account : accounts) {
- ReportsDatas reportsDatas =
- generateSubAccountBalance(account, beginDate,
- endDate, getEntries);
- reportsDatas.setAccount(account);
- BigDecimal amount = reportsDatas.getAmountSolde();
- if (amount == null) {
- amount = new BigDecimal(0);
- }
- if (movementedFilter) {
- if (!reportsDatas.getAmountCredit().equals(BigDecimal.ZERO)
- || !reportsDatas.getAmountDebit().equals(BigDecimal.ZERO)) {
- // add balance sheet to balance trial
- balanceTrial.addReportsDatas(reportsDatas);
- }
- } else {
+ for (Account account : accounts) {
+ ReportsDatas reportsDatas =
+ generateSubAccountBalance(account, beginDate,
+ endDate, getEntries);
+ reportsDatas.setAccount(account);
+ BigDecimal amount = reportsDatas.getAmountSolde();
+ if (amount == null) {
+ amount = new BigDecimal(0);
+ }
+ if (movementedFilter) {
+ if (!reportsDatas.getAmountCredit().equals(BigDecimal.ZERO)
+ || !reportsDatas.getAmountDebit().equals(BigDecimal.ZERO)) {
// add balance sheet to balance trial
balanceTrial.addReportsDatas(reportsDatas);
}
+ } else {
+ // add balance sheet to balance trial
+ balanceTrial.addReportsDatas(reportsDatas);
+ }
- if (reportsDatas.getSoldeDebit()) {
- debit = debit.add(amount);
- } else {
- credit = credit.add(amount);
- }
+ if (reportsDatas.getSoldeDebit()) {
+ debit = debit.add(amount);
+ } else {
+ credit = credit.add(amount);
}
- // set the amounts and solde
- //solde = debit - credit;
- solde = solde.add(debit);
- solde = solde.subtract(credit);
- if (solde.compareTo(BigDecimal.ZERO) == 1) {
- balanceTrial.setSoldeDebit(true);
- }
- solde = solde.abs();
- balanceTrial.setAmountCredit(credit);
- balanceTrial.setAmountDebit(debit);
- balanceTrial.setAmountSolde(solde);
- } catch (Exception ex) {
- throw new LimaException("Can't generate report", ex);
}
+ // set the amounts and solde
+ //solde = debit - credit;
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ balanceTrial.setSoldeDebit(true);
+ }
+ solde = solde.abs();
+ balanceTrial.setAmountCredit(credit);
+ balanceTrial.setAmountDebit(debit);
+ balanceTrial.setAmountSolde(solde);
return balanceTrial;
}
@@ -387,7 +371,7 @@
public BalanceTrial generateLedger(Date beginDate,
Date endDate,
String selectedAccounts,
- Boolean movementedFilter) throws LimaException {
+ Boolean movementedFilter) {
return generateBalanceTrial(beginDate, endDate, selectedAccounts, true, movementedFilter);
}
@@ -398,30 +382,26 @@
* @throws LimaException, TopiaException
*/
@Override
- public List<Object> generateVat(FiscalPeriod fiscalPeriod) throws LimaException {
+ public List<Object> generateVat(FiscalPeriod fiscalPeriod) {
List<Object> list = new ArrayList<Object>();
- try {
- //lists all accounts
- AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
- List<Account> accountsList;
- //gets all financial periods from the fiscal period
- List<FinancialPeriod> financialPeriod = financialPeriodService.getFinancialPeriods(
- fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate());
- for (FinancialPeriod fp : financialPeriod) {
- list.add(fp);
- accountsList = accountTopiaDao.findAll();
- for (Account account : accountsList) {
- //VAT accounts start only with number 44
- //FIXME echatellier 44 is hardcoded and depends on
- //french rule ?
- if (account.getAccountNumber().startsWith("44")) {
- list.add(generateBalanceTrial(fp.getBeginDate(), fp.getEndDate(), account.getAccountNumber(), true, false));
- }
+ //lists all accounts
+ AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
+ List<Account> accountsList;
+ //gets all financial periods from the fiscal period
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getFinancialPeriods(
+ fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate());
+ for (FinancialPeriod fp : financialPeriod) {
+ list.add(fp);
+ accountsList = accountTopiaDao.findAll();
+ for (Account account : accountsList) {
+ //VAT accounts start only with number 44
+ //FIXME echatellier 44 is hardcoded and depends on
+ //french rule ?
+ if (account.getAccountNumber().startsWith("44")) {
+ list.add(generateBalanceTrial(fp.getBeginDate(), fp.getEndDate(), account.getAccountNumber(), true, false));
}
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't generate report", ex);
}
return list;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,16 +24,6 @@
*/
package org.chorem.lima.business.ejb;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.beans.VatStatementAmounts;
import org.chorem.lima.beans.VatStatementAmountsImpl;
@@ -46,8 +36,16 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
/**
* Permet d'implémenter le plan de la déclaration de TVA
*
@@ -66,47 +64,38 @@
@Override
public void createVatStatement(VatStatement masterVatStatement,
- VatStatement vatStatement) throws LimaException {
+ VatStatement vatStatement) {
- try {
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- vatStatementTopiaDao.create(vatStatement);
+ vatStatementTopiaDao.create(vatStatement);
- VatStatement mastervatStatementUpdate = null;
- if (masterVatStatement != null) {
- mastervatStatementUpdate = vatStatementTopiaDao.forLabelEquals(masterVatStatement.getLabel()).findUniqueOrNull();
- }
+ VatStatement mastervatStatementUpdate = null;
+ if (masterVatStatement != null) {
+ mastervatStatementUpdate = vatStatementTopiaDao.forLabelEquals(masterVatStatement.getLabel()).findUniqueOrNull();
+ }
- // check if parent account exist;
- if (mastervatStatementUpdate != null) {
- mastervatStatementUpdate.addSubVatStatements(vatStatement);
- vatStatementTopiaDao.update(mastervatStatementUpdate);
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't create vat statement", ex);
+ // check if parent account exist;
+ if (mastervatStatementUpdate != null) {
+ mastervatStatementUpdate.addSubVatStatements(vatStatement);
+ vatStatementTopiaDao.update(mastervatStatementUpdate);
}
}
@Override
- public List<VatStatement> getAllVatStatements() throws LimaException {
+ public List<VatStatement> getAllVatStatements() {
- List<VatStatement> vatStatements;
- try {
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- vatStatements = vatStatementTopiaDao.findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't get vat statements", ex);
- }
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ List<VatStatement> vatStatements = vatStatementTopiaDao.findAll();
+
return vatStatements;
}
@Override
public List<VatStatement> getAllChildrenVatStatement(
- VatStatement vatStatement, List<VatStatement> result) throws LimaException {
+ VatStatement vatStatement, List<VatStatement> result) {
List<VatStatement> childVatStatements =
getChildrenVatStatement(vatStatement);
@@ -119,132 +108,67 @@
}
@Override
- public List<VatStatement> getChildrenVatStatement(VatStatement masterVatStatement) throws LimaException {
+ public List<VatStatement> getChildrenVatStatement(VatStatement masterVatStatement) {
- List<VatStatement> vatStatements;
- try {
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ List<VatStatement> vatStatements = vatStatementTopiaDao.getChildrenVatStatement(masterVatStatement);
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- vatStatements = vatStatementTopiaDao.getChildrenVatStatement(masterVatStatement);
- } catch (TopiaException ex) {
- throw new LimaException("Can't get vat statements", ex);
- }
return vatStatements;
}
@Override
- public void updateVatStatement(VatStatement vatStatement) throws LimaException {
+ public void updateVatStatement(VatStatement vatStatement) {
- try {
- // TopiaDao
- VatStatementTopiaDao vatStatementHeaderTopiaDao = getDaoHelper().getVatStatementDao();
- //update
- vatStatementHeaderTopiaDao.update(vatStatement);
- } catch (TopiaException ex) {
- throw new LimaException("Can't update vat statement", ex);
- }
+ // TopiaDao
+ VatStatementTopiaDao vatStatementHeaderTopiaDao = getDaoHelper().getVatStatementDao();
+ //update
+ vatStatementHeaderTopiaDao.update(vatStatement);
+
}
- /* TODO echatellier 20120510 unused function
- public Amounts amountFromAccountList(String accountsNumberList,
- Date selectedBeginDate,
- Date selectedEndDate,
- TopiaContext topiaContext) throws LimaException {
- Amounts amounts = new AmountsImpl();
- BigDecimal debit = new BigDecimal(0);
- BigDecimal credit = new BigDecimal(0);
- Boolean substract = false;
- try {
- AccountTopiaDao accountTopiaDao = LimaCallaoTopiaDaoHelper.getAccountTopiaDao(topiaContext);
- //Remove Spaces
- String result = StringUtils.deleteWhitespace(accountsNumberList);
- StringTokenizer stQuote = new StringTokenizer(result, ",");
- while (stQuote.hasMoreTokens()) {
- String s = stQuote.nextToken();
- List<Account> accountsList = accountTopiaDao.stringToListAccounts(s, false);
- BigDecimal debitTemp = new BigDecimal(0);
- BigDecimal creditTemp = new BigDecimal(0);
- for (Account account : accountsList) {
- ReportsDatas reportsDatas = reportServiceLocal.
- generateAccountReportsWithTransaction(account, true,
- selectedBeginDate, selectedEndDate, topiaContext);
- if (reportsDatas.getSoldeDebit()) {
- debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
- } else {
- creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
- }
- }
- if (!substract) {
- debit = debitTemp;
- credit = creditTemp;
- }
- //compte(s) précédé du signe -
- else {
- debit = debit.subtract(debitTemp);
- credit = credit.subtract(creditTemp);
- }
- substract = true;
- }
- amounts.setCredit(credit);
- amounts.setDebit(debit);
- } catch (TopiaException e) {
- doCatch(topiaContext, e);
- }
- return amounts;
- }*/
-
/**
* Gives the list of account numbers from a VatStatement.
*
* @param vatStatement
* @return accountNumbersList
- * @throws LimaException
*/
- protected String findAccountNumberByVatStatement(VatStatement vatStatement) throws LimaException {
+ protected String findAccountNumberByVatStatement(VatStatement vatStatement) {
String accountNumbersList = null;
- try {
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- VatStatement vatStatement2 = vatStatementTopiaDao.findVatStatementByLabel(vatStatement.getLabel());
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ VatStatement vatStatement2 = vatStatementTopiaDao.findVatStatementByLabel(vatStatement.getLabel());
- if (vatStatement2 != null) {
- accountNumbersList = vatStatement2.getAccounts();
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't find accountNumber by vatStatement", ex);
+ if (vatStatement2 != null) {
+ accountNumbersList = vatStatement2.getAccounts();
}
+
return accountNumbersList;
}
@Override
public VatStatementAmounts vatStatementAmounts(VatStatement vatStatement,
Date selectedBeginDate,
- Date selectedEndDate) throws LimaException {
+ Date selectedEndDate) {
VatStatementAmounts vatStatementAmounts = new VatStatementAmountsImpl();
BigDecimal debitTemp = new BigDecimal(0);
BigDecimal creditTemp = new BigDecimal(0);
- try {
+ String accountNumbersList = findAccountNumberByVatStatement(vatStatement);
- String accountNumbersList = findAccountNumberByVatStatement(vatStatement);
+ List<Account> accountsList = accountService.stringToListAccounts(accountNumbersList);
- List<Account> accountsList = accountService.stringToListAccounts(accountNumbersList);
-
- for (Account account : accountsList) {
- ReportsDatas reportsDatas = reportService.
- generateAccountsReports(account, true,
- selectedBeginDate, selectedEndDate);
- if (reportsDatas.getSoldeDebit()) {
- debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
- } else {
- creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
- }
+ for (Account account : accountsList) {
+ ReportsDatas reportsDatas = reportService.
+ generateAccountsReports(account, true,
+ selectedBeginDate, selectedEndDate);
+ if (reportsDatas.getSoldeDebit()) {
+ debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
+ } else {
+ creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
}
- } catch (TopiaException ex) {
- throw new LimaException("Error in vatStatementAmounts", ex);
}
//return debitTemp.subtract(creditTemp).abs();
vatStatementAmounts.setAmount(debitTemp.subtract(creditTemp).abs());
@@ -253,23 +177,16 @@
}
@Override
- public VatStatement findVatStatementByLabel(String label) throws LimaException {
+ public VatStatement findVatStatementByLabel(String label) {
- VatStatement vatStatement;
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ VatStatement vatStatement = vatStatementTopiaDao.findVatStatementByLabel(label);
- try {
-
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- vatStatement = vatStatementTopiaDao.findVatStatementByLabel(label);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't find vatstatement", ex);
- }
return vatStatement;
}
/** remote methode to get list of financial statement */
- public List<VatStatementAmounts> vatStatementReport(Date beginDate, Date endDate) throws LimaException {
+ public List<VatStatementAmounts> vatStatementReport(Date beginDate, Date endDate) {
//create list form tree
VatStatementDatas vatStatementDatas = vatStatementReport(null, beginDate, endDate,
@@ -287,7 +204,7 @@
public VatStatementDatas vatStatementReport(VatStatement vatStatement,
Date selectedBeginDate,
Date selectedEndDate,
- VatStatementDatas result) throws LimaException {
+ VatStatementDatas result) {
List<VatStatement> vatStatements =
getChildrenVatStatement(vatStatement);
@@ -348,51 +265,43 @@
}
@Override
- public void removeVatStatement(VatStatement vatStatement) throws LimaException {
+ public void removeVatStatement(VatStatement vatStatement) {
- try {
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- // remove vatstatement
- VatStatement vatStatementToDelete =
- vatStatementTopiaDao.findByTopiaId(
- vatStatement.getTopiaId());
- vatStatementTopiaDao.delete(vatStatementToDelete);
+ // remove vatstatement
+ VatStatement vatStatementToDelete =
+ vatStatementTopiaDao.findByTopiaId(
+ vatStatement.getTopiaId());
+ vatStatementTopiaDao.delete(vatStatementToDelete);
- //get all subVatStatement
- List<VatStatement> vatStatements =
- getAllChildrenVatStatement(vatStatement,
- new ArrayList<VatStatement>());
+ //get all subVatStatement
+ List<VatStatement> vatStatements =
+ getAllChildrenVatStatement(vatStatement,
+ new ArrayList<VatStatement>());
- //if VatStatement have subVatStatement
- if (vatStatements.size() > 0) {
- for (VatStatement subVatStatement : vatStatements) {
- VatStatement subVatStatementToDelete =
- vatStatementTopiaDao.findByTopiaId(
- subVatStatement.getTopiaId());
- vatStatementTopiaDao.delete(subVatStatementToDelete);
- }
+ //if VatStatement have subVatStatement
+ if (vatStatements.size() > 0) {
+ for (VatStatement subVatStatement : vatStatements) {
+ VatStatement subVatStatementToDelete =
+ vatStatementTopiaDao.findByTopiaId(
+ subVatStatement.getTopiaId());
+ vatStatementTopiaDao.delete(subVatStatementToDelete);
}
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't remove vatstatement", ex);
}
- }
+}
@Override
- public boolean checkVatStatementExist(String label) throws LimaException {
- boolean result;
- try {
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- result = vatStatementTopiaDao.forProperties(VatStatement.PROPERTY_LABEL, label).exists();
- } catch (TopiaException e) {
- throw new LimaException("Can't check VAT statement", e);
- }
+ public boolean checkVatStatementExist(String label) {
+
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ boolean result = vatStatementTopiaDao.forProperties(VatStatement.PROPERTY_LABEL, label).exists();
+
return result;
}
@Override
- public void removeAllVatStatement() throws LimaException {
+ public void removeAllVatStatement() {
for (VatStatement vatStatement : getChildrenVatStatement(null)) {
removeVatStatement(vatStatement);
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,22 +24,18 @@
package org.chorem.lima.business.accountingrules;
import org.apache.commons.lang3.time.DateUtils;
-import org.chorem.lima.business.LimaBusinessException;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
import org.junit.Ignore;
-import org.nuiton.topia.persistence.TopiaException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import static org.nuiton.i18n.I18n.t;
-
/**
* Cette classe existe car les tests tourne 2 fois:
* - default
@@ -63,58 +59,54 @@
* Copier/coller de la methode france.
* Le probleme ici est que le default n'en creer aucune.
*/
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
super.createFiscalPeriodRules(fiscalPeriod);
List<FinancialPeriod> financialPeriods = new ArrayList<FinancialPeriod>();
- try {
- FiscalPeriodTopiaDao fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDao();
+ FiscalPeriodTopiaDao fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDao();
- //Checks if is not the first fiscalperiod to create
- if (fiscalPeriodDAO.count() != 0) {
+ //Checks if is not the first fiscalperiod to create
+ if (fiscalPeriodDAO.count() != 0) {
- FiscalPeriod lastFiscalPeriod = fiscalPeriodDAO.getLastFiscalPeriod();
+ FiscalPeriod lastFiscalPeriod = fiscalPeriodDAO.getLastFiscalPeriod();
- //check the new fiscal period adjoining the last
- Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
- dateLastFiscalPeriod = DateUtils.addDays(dateLastFiscalPeriod, 1);
- dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
- Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
- if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.newfiscalperiodadjoiningerror"));
- }
+ //check the new fiscal period adjoining the last
+ Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
+ dateLastFiscalPeriod = DateUtils.addDays(dateLastFiscalPeriod, 1);
+ dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
+ Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
+ if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.newfiscalperiodadjoiningerror");
+ }
- //We can create a new fiscal period meantime the last fiscal period was not locked
- //But not the ante periodfiscal
- int unblockedFiscalPeriod = fiscalPeriodDAO.forLockedEquals(false).findAll().size();
- if (unblockedFiscalPeriod > 1) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.antefiscalperiodnotblocked"));
- }
+ //We can create a new fiscal period meantime the last fiscal period was not locked
+ //But not the ante periodfiscal
+ int unblockedFiscalPeriod = fiscalPeriodDAO.forLockedEquals(false).findAll().size();
+ if (unblockedFiscalPeriod > 1) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.antefiscalperiodnotblocked");
}
+ }
- // FinancialPeriods of 1 month are created
- Date endDate = fiscalPeriod.getEndDate();
- Date loopDate = fiscalPeriod.getBeginDate();
- while (loopDate.before(endDate)) {
- FinancialPeriod financialPeriod = new FinancialPeriodImpl();
- //important for fiscalperiod created from import, it can be locked, so financialperiods must be locked
- financialPeriod.setLocked(fiscalPeriod.isLocked());
- financialPeriod.setBeginDate(loopDate);
- loopDate = DateUtils.addMonths(loopDate, 1);
- loopDate = DateUtils.truncate(loopDate, Calendar.MONTH);
- loopDate = DateUtils.addMilliseconds(loopDate, -1);
- if (loopDate.after(endDate)) {
- financialPeriod.setEndDate(endDate);
- } else {
- financialPeriod.setEndDate(loopDate);
- }
- //create it
- financialPeriods.add(financialPeriod);
- //financialPeriodService.createFinancialPeriodWithTransaction(financialPeriod, transaction);
- //loop incremente
- loopDate = DateUtils.addMilliseconds(loopDate, 1);
+ // FinancialPeriods of 1 month are created
+ Date endDate = fiscalPeriod.getEndDate();
+ Date loopDate = fiscalPeriod.getBeginDate();
+ while (loopDate.before(endDate)) {
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ //important for fiscalperiod created from import, it can be locked, so financialperiods must be locked
+ financialPeriod.setLocked(fiscalPeriod.isLocked());
+ financialPeriod.setBeginDate(loopDate);
+ loopDate = DateUtils.addMonths(loopDate, 1);
+ loopDate = DateUtils.truncate(loopDate, Calendar.MONTH);
+ loopDate = DateUtils.addMilliseconds(loopDate, -1);
+ if (loopDate.after(endDate)) {
+ financialPeriod.setEndDate(endDate);
+ } else {
+ financialPeriod.setEndDate(loopDate);
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ //create it
+ financialPeriods.add(financialPeriod);
+ //financialPeriodService.createFinancialPeriodWithTransaction(financialPeriod, transaction);
+ //loop incremente
+ loopDate = DateUtils.addMilliseconds(loopDate, 1);
}
return financialPeriods;
}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,23 @@
+package org.chorem.lima;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class LimaTechnicalException extends RuntimeException {
+
+ public LimaTechnicalException() {
+ }
+
+ public LimaTechnicalException(String message) {
+ super(message);
+ }
+
+ public LimaTechnicalException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public LimaTechnicalException(Throwable cause) {
+ super(cause);
+ }
+
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,23 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public abstract class AccountException extends LimaException {
+
+ protected String accountNumber;
+
+ public AccountException(String accountNumber, String message) {
+ super(message);
+ this.accountNumber = accountNumber;
+ }
+
+ public AccountException(String accountNumber, String message, Throwable cause) {
+ super(message, cause);
+ this.accountNumber = accountNumber;
+ }
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,14 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class AlreadyExistAccountException extends AccountException {
+ public AlreadyExistAccountException(String accountNumber, String message) {
+ super(accountNumber, message);
+ }
+
+ public AlreadyExistAccountException(String accountNumber, String message, Throwable cause) {
+ super(accountNumber, message, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,34 @@
+package org.chorem.lima.business.utils;
+
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class ClosedPeriodicEntryBookException extends LimaException {
+
+ protected ClosedPeriodicEntryBook closedPeriodicEntryBook;
+
+ public ClosedPeriodicEntryBookException(String message) {
+ super(message);
+ }
+
+ public ClosedPeriodicEntryBookException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ClosedPeriodicEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook, String message) {
+ super(message);
+ this.closedPeriodicEntryBook = closedPeriodicEntryBook;
+ }
+
+ public ClosedPeriodicEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook, String message, Throwable cause) {
+ super(message, cause);
+ this.closedPeriodicEntryBook = closedPeriodicEntryBook;
+ }
+
+ public ClosedPeriodicEntryBook getClosedPeriodicEntryBook() {
+ return closedPeriodicEntryBook;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,33 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.EntryBook;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class EntryBookException extends LimaException {
+
+ protected EntryBook entryBook;
+
+ public EntryBookException(String message) {
+ super(message);
+ }
+
+ public EntryBookException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EntryBookException(EntryBook entryBook, String message) {
+ super(message);
+ this.entryBook = entryBook;
+ }
+
+ public EntryBookException(EntryBook entryBook, String message, Throwable cause) {
+ super(message, cause);
+ this.entryBook = entryBook;
+ }
+
+ public EntryBook getEntryBook() {
+ return entryBook;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,33 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.Entry;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class EntryException extends LimaException {
+
+ protected Entry entry;
+
+ public EntryException(String message) {
+ super(message);
+ }
+
+ public EntryException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EntryException(Entry entry, String message) {
+ super(message);
+ this.entry = entry;
+ }
+
+ public EntryException(Entry entry, String message, Throwable cause) {
+ super(message, cause);
+ this.entry = entry;
+ }
+
+ public Entry getEntry() {
+ return entry;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,34 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FinancialTransaction;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FinancialTransactionException extends LimaException {
+
+ protected FinancialTransaction financialTransaction;
+
+ public FinancialTransactionException(String message) {
+ super(message);
+ }
+
+ public FinancialTransactionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public FinancialTransactionException(FinancialTransaction financialTransaction, String message) {
+ super(message);
+ this.financialTransaction = financialTransaction;
+ }
+
+ public FinancialTransactionException(FinancialTransaction financialTransaction, String message, Throwable cause) {
+ super(message, cause);
+ this.financialTransaction = financialTransaction;
+ }
+
+ public FinancialTransaction getFinancialTransaction() {
+ return financialTransaction;
+ }
+
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,33 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FiscalPeriod;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FiscalPeriodException extends LimaException {
+
+ protected FiscalPeriod fiscalPeriod;
+
+ public FiscalPeriodException(String message) {
+ super(message);
+ }
+
+ public FiscalPeriodException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public FiscalPeriodException(FiscalPeriod fiscalPeriod, String message) {
+ super(message);
+ this.fiscalPeriod = fiscalPeriod;
+ }
+
+ public FiscalPeriodException(FiscalPeriod fiscalPeriod, String message, Throwable cause) {
+ super(message, cause);
+ this.fiscalPeriod = fiscalPeriod;
+ }
+
+ public FiscalPeriod getFiscalPeriod() {
+ return fiscalPeriod;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,14 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class ImportEbpException extends LimaException {
+ public ImportEbpException(String message) {
+ super(message);
+ }
+
+ public ImportEbpException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,14 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class InvalidAccountNumberException extends AccountException {
+ public InvalidAccountNumberException(String accountNumber, String message) {
+ super(accountNumber, message);
+ }
+
+ public InvalidAccountNumberException(String accountNumber, String message, Throwable cause) {
+ super(accountNumber, message, cause);
+ }
+}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -37,7 +37,7 @@
* By : $Author$
*/
@ApplicationException
-public class LimaException extends RuntimeException {
+public class LimaException extends Exception {
/**
* serialVersionUID.
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,14 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class UsedAccountException extends AccountException {
+ public UsedAccountException(String accountNumber, String message) {
+ super(accountNumber, message);
+ }
+
+ public UsedAccountException(String accountNumber, String message, Throwable cause) {
+ super(accountNumber, message, cause);
+ }
+}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,9 +25,11 @@
package org.chorem.lima.business.api;
+import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.UsedAccountException;
import org.chorem.lima.entity.Account;
-import org.nuiton.topia.persistence.TopiaException;
import java.util.List;
@@ -48,7 +50,7 @@
* @return account count
* @throws LimaException technical exception
*/
- long getAccountCount() throws LimaException;
+ long getAccountCount();
/**
* Obtain the master account for the given account number.
@@ -61,9 +63,9 @@
* @return the master account number
* @throws LimaException if any pb while loading account
*/
- Account getMasterAccount(String accountNumber) throws LimaException;
+ Account getMasterAccount(String accountNumber);
- Account getAccountByNumber(String number) throws LimaException;
+ Account getAccountByNumber(String number);
/**
* Return all account ordered by account name.
@@ -71,9 +73,9 @@
* @return all account
* @throws LimaException
*/
- List<Account> getAllAccounts() throws LimaException;
+ List<Account> getAllAccounts();
- List<Account> getAllLeafAccounts() throws LimaException;
+ List<Account> getAllLeafAccounts();
/**
* Return all {@code account}-s subaccounts.
@@ -82,7 +84,7 @@
* @return sub accounts
* @throws LimaException
*/
- List<Account> getAllSubAccounts(Account account) throws LimaException;
+ List<Account> getAllSubAccounts(Account account);
/**
* Create new account. If {@code masterAccount} is not null, {@code account}
@@ -91,11 +93,11 @@
* @param account account
* @throws LimaException
*/
- Account createAccount(Account account) throws LimaException;
+ Account createAccount(Account account) throws AccountException;
- Account updateAccount(Account account) throws LimaException;
+ Account updateAccount(Account account) throws InvalidAccountNumberException;
- void removeAccount(Account account) throws LimaException;
+ void removeAccount(Account account) throws UsedAccountException;
- List<Account> stringToListAccounts(String selectedAccounts) throws TopiaException;
+ List<Account> stringToListAccounts(String selectedAccounts);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,9 +25,6 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.utils.FormatsEnum;
-
import java.util.Date;
/**
@@ -38,17 +35,17 @@
public interface DocumentService {
- String createFinancialStatementsDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createFinancialStatementsDocuments(Date beginDate, Date endDate);
- String createLedgerDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createLedgerDocuments(Date beginDate, Date endDate);
- String createBalanceDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createBalanceDocuments(Date beginDate, Date endDate);
- String createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createEntryBooksDocuments(Date beginDate, Date endDate);
- String createGeneralEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createGeneralEntryBooksDocuments(Date beginDate, Date endDate);
- void createVatDocuments(Date beginDate, Date endDate, String autocomplete) throws LimaException;
+ void createVatDocuments(Date beginDate, Date endDate, String autocomplete);
- String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException;
+ String createAccountDocument(Date beginDate, Date endDate, String account);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,6 +25,7 @@
package org.chorem.lima.business.api;
+import org.chorem.lima.business.EntryBookException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.EntryBook;
@@ -48,7 +49,7 @@
* @return
* @throws LimaException
*/
- EntryBook getEntryBookByCode(String code) throws LimaException;
+ EntryBook getEntryBookByCode(String code);
/**
* Get all entry book.
@@ -56,7 +57,7 @@
* @return all entrybook
* @throws LimaException
*/
- List<EntryBook> getAllEntryBooks() throws LimaException;
+ List<EntryBook> getAllEntryBooks();
/**
* Create new entry book.
@@ -64,7 +65,7 @@
* @param entryBook
* @throws LimaException
*/
- EntryBook createEntryBook(EntryBook entryBook) throws LimaException;
+ EntryBook createEntryBook(EntryBook entryBook);
/**
* Permet de modifier un journal.
@@ -72,7 +73,7 @@
* @param entryBook journal
* @throws LimaException
*/
- EntryBook updateEntryBook(EntryBook entryBook) throws LimaException;
+ EntryBook updateEntryBook(EntryBook entryBook);
/**
* Permet d'effacer un EntryBook dans la base de données.
@@ -81,7 +82,7 @@
* impossible de supprimer celui-ci.
*
* @param entryBook
- * @throws LimaException
+ * @throws EntryBookException
*/
- void removeEntryBook(EntryBook entryBook) throws LimaException;
+ void removeEntryBook(EntryBook entryBook) throws EntryBookException;
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -47,42 +47,42 @@
* @return export as byte array
* @throws LimaException
*/
- String exportAsCSV() throws LimaException;
+ String exportAsCSV();
/**
* export entrybook chart as CSV.
*/
- String exportEntryBookChartAsCSV() throws LimaException;
+ String exportEntryBookChartAsCSV();
/**
* export financialstatement chart as CSV.
*/
- String exportFinancialStatementChartAsCSV() throws LimaException;
+ String exportFinancialStatementChartAsCSV();
/**
* export vatstatement chart as CSV
*/
- String exportVatStatementChartAsCSV() throws LimaException;
+ String exportVatStatementChartAsCSV();
/**
* export accounts chart as CSV.
*/
- String exportAccountsChartAsCSV() throws LimaException;
+ String exportAccountsChartAsCSV();
/**
* export entries as EBP
*/
- String exportEntriesAsEBP() throws LimaException;
+ String exportEntriesAsEBP();
/**
* export accounts as EBP
*/
- String exportAccountsAsEBP() throws LimaException;
+ String exportAccountsAsEBP();
/**
* export entryBooks as EBP
* @return
* @throws LimaException
*/
- String exportEntryBooksAsEBP() throws LimaException;
+ String exportEntryBooksAsEBP();
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,15 +25,14 @@
package org.chorem.lima.business.api;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
+import java.util.Date;
+import java.util.List;
+
/**
* Financial period service.
*
@@ -46,19 +45,19 @@
public interface FinancialPeriodService {
- List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException;
+ List<FinancialPeriod> getUnblockedFinancialPeriods();
ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook,
- FinancialPeriod financialPeriod) throws LimaException;
+ FinancialPeriod financialPeriod);
- List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException;
+ List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
- ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException;
+ ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException;
- List<FinancialPeriod> getAllFinancialPeriods() throws LimaException;
+ List<FinancialPeriod> getAllFinancialPeriods();
List<FinancialPeriod> getFinancialPeriods(Date beginDate,
- Date endDate) throws LimaException;
+ Date endDate);
- FinancialPeriod getFinancialPeriodByNaturalIds(Date beginDate, Date endDate) throws LimaException;
+ FinancialPeriod getFinancialPeriodByNaturalIds(Date beginDate, Date endDate);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -36,25 +36,25 @@
void createFinancialStatement(FinancialStatement masterFinancialStatement,
- FinancialStatement financialStatement) throws LimaException;
+ FinancialStatement financialStatement);
- void updateFinancialStatement(FinancialStatement financialStatement) throws LimaException;
+ void updateFinancialStatement(FinancialStatement financialStatement);
- void removeFinancialStatement(FinancialStatement financialStatement) throws LimaException;
+ void removeFinancialStatement(FinancialStatement financialStatement);
- void removeAllFinancialStatement() throws LimaException;
+ void removeAllFinancialStatement();
- List<FinancialStatement> getAllFinancialStatements() throws LimaException;
+ List<FinancialStatement> getAllFinancialStatements();
- List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement financialStatement) throws LimaException;
+ List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement financialStatement);
List<FinancialStatement> getAllChildrenFinancialStatement(FinancialStatement financialStatement,
- List<FinancialStatement> financialStatements) throws LimaException;
+ List<FinancialStatement> financialStatements);
List<FinancialStatementAmounts> financialStatementReport(Date selectedBeginDate,
- Date selectedEndDate) throws LimaException;
+ Date selectedEndDate);
- String checkFinancialStatementChart() throws LimaException;
+ String checkFinancialStatementChart();
/**
* Check if Financial Statement exist according the label given as parameter.
@@ -62,7 +62,7 @@
* @return true if a statement with same label exist otherwise false.
* @throws LimaException
*/
- boolean checkFinancialStatementExist(String label) throws LimaException;
+ boolean checkFinancialStatementExist(String label);
- FinancialStatement getFinancialStatementByLabel(String label) throws LimaException;
+ FinancialStatement getFinancialStatementByLabel(String label);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,6 +27,8 @@
import org.chorem.lima.beans.FinancialTransactionCondition;
import org.chorem.lima.beans.LetteringFilter;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
@@ -50,44 +52,44 @@
public interface FinancialTransactionService {
- FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+ FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException;
- void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+ void updateFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException;
- void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+ void removeFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException;
- FinancialTransaction getFinancialTransactionWithId(String id) throws LimaException;
+ FinancialTransaction getFinancialTransactionWithId(String id);
- List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period);
- List<FinancialTransaction> getAllFinancialTransactions(Date beginDate, Date endDate) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactions(Date beginDate, Date endDate);
- List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period, EntryBook entryBook) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period, EntryBook entryBook);
- List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) throws LimaException;
+ List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod);
- List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod);
- List<FinancialTransaction> getAllFinancialTransactions(FiscalPeriod period) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactions(FiscalPeriod period);
- List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionCondition financialTransactionFilter) throws LimaException;
+ List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionCondition financialTransactionFilter);
- Entry createEntry(Entry entry) throws LimaException;
+ Entry createEntry(Entry entry) throws FinancialTransactionException;
- void updateEntry(Entry entry) throws LimaException;
+ void updateEntry(Entry entry) throws EntryException;
- void removeEntry(Entry entry) throws LimaException;
+ void removeEntry(Entry entry) throws FinancialTransactionException;
/** Find the last letter used
* and increment them
* @return a string representing the last letter
* */
- String getNextLetters() throws LimaException;
+ String getNextLetters();
/** Find all the letters used
* @return a list of string containing all the letters
* */
- List<String> getAllLetters() throws LimaException;
+ List<String> getAllLetters();
/**
* From to selected entries, create one with same account and
@@ -97,7 +99,7 @@
* @param SecondEntrySelected second entry selected
* @return table of the two new entries
* */
- Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws LimaException;
+ Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws FinancialTransactionException;
/**
* Retourne toutes les entrées d'une transaction
@@ -105,11 +107,11 @@
* @param filter filtre sur les entrees, selon le compte, les dates de debut et de fin, et le lettrage
* @throws LimaException
* */
- List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter) throws LimaException;
+ List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter);
/**
* Retourne la dernière entrée d'une transaction
* @param financialTransaction transaction sur laquelle la derniere entree est selectionnee
* */
- Entry getLastEntry(FinancialTransaction financialTransaction) throws LimaException;
+ Entry getLastEntry(FinancialTransaction financialTransaction);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,7 +25,9 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FiscalPeriod;
@@ -42,19 +44,19 @@
*/
public interface FiscalPeriodService {
- List<FiscalPeriod> getAllFiscalPeriods() throws LimaException;
+ List<FiscalPeriod> getAllFiscalPeriods();
- List<FiscalPeriod> getAllBlockedFiscalPeriods() throws LimaException;
+ List<FiscalPeriod> getAllBlockedFiscalPeriods();
- List<FiscalPeriod> getAllUnblockedFiscalPeriods() throws LimaException;
+ List<FiscalPeriod> getAllUnblockedFiscalPeriods();
- FiscalPeriod getLastFiscalPeriod() throws LimaException;
+ FiscalPeriod getLastFiscalPeriod();
- FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+ FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
- FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+ FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
- void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+ void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
/**
* Eventually add retained earnings on last unclosed fiscal period,
@@ -65,14 +67,14 @@
* @return fiscal period blocked
* */
FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
- boolean retainedEarnings) throws LimaException;
+ boolean retainedEarnings) throws AccountException, FinancialTransactionException, FiscalPeriodException;
/**
* Test if we have retained earnings on a fiscal period
* @param fiscalPeriod
* @return true if retained earnings are possible
* */
- boolean isRetainedEarnings(FiscalPeriod fiscalPeriod) throws LimaException;
+ boolean isRetainedEarnings(FiscalPeriod fiscalPeriod);
- FiscalPeriod updateEndDate(FiscalPeriod fiscalPeriod) throws LimaException;
+ FiscalPeriod updateEndDate(FiscalPeriod fiscalPeriod);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,13 +25,12 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Identity;
public interface IdentityService {
- Identity getIdentity() throws LimaException;
+ Identity getIdentity();
- void updateIdentity(Identity identity) throws LimaException;
+ void updateIdentity(Identity identity);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,6 +25,7 @@
package org.chorem.lima.business.api;
+import org.chorem.lima.business.ImportEbpException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.utils.ImportExportEntityEnum;
@@ -41,7 +42,7 @@
* @return result log
* @throws LimaException
*/
- String importAccountsChartFromEbp(String data) throws LimaException;
+ String importAccountsChartFromEbp(String data) throws ImportEbpException;
/**
* Import entry books as EBP import.
@@ -50,7 +51,7 @@
* @return
* @throws LimaException
*/
- String importEntryBookFromEbp(String datas) throws LimaException;
+ String importEntryBookFromEbp(String datas) throws ImportEbpException;
/**
* Import entries as EBP import.
@@ -59,7 +60,7 @@
* @return result log
* @throws LimaException
*/
- String importEntriesFromEbp(String data) throws LimaException;
+ String importEntriesFromEbp(String data) throws ImportEbpException;
/**
* Import data as lima CSV import.
@@ -70,7 +71,7 @@
* @return result log
* @throws LimaException
*/
- String importAllAsCSV(String data) throws LimaException;
+ String importAllAsCSV(String data) throws ImportEbpException;
/**
* Import content as CSV depending on import type.
@@ -81,7 +82,7 @@
* @throws LimaException
*/
String importAsCSV(String data,
- ImportExportEntityEnum importExportEntityEnum) throws LimaException;
+ ImportExportEntityEnum importExportEntityEnum) throws ImportEbpException;
/**
* @deprecated import file (local, can't be used in remote mode)
@@ -89,7 +90,7 @@
*/
String importAsPDF(String data,
ImportExportEntityEnum importExportEntityEnum,
- boolean saveMode) throws LimaException;
+ boolean saveMode);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,10 +25,6 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.LimaException;
-
-import java.io.File;
-
/**
* Import export service.
* <p/>
@@ -42,15 +38,15 @@
*/
public interface NewExportService {
- String exportAllAsCSV(String charset) throws LimaException;
+ String exportAllAsCSV(String charset);
- String exportAccountsStream(String charset) throws LimaException;
+ String exportAccountsStream(String charset);
- String exportEntryBooksStream(String charset) throws LimaException;
+ String exportEntryBooksStream(String charset);
- String exportFiscalPeriodsStream(String charset) throws LimaException;
+ String exportFiscalPeriodsStream(String charset);
- String exportFinancialTransactionsAsStream(String charset) throws LimaException;
+ String exportFinancialTransactionsAsStream(String charset);
- String exportEntriesAsCSV(String charset) throws LimaException;
+ String exportEntriesAsCSV(String charset);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -1,21 +1,19 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.LimaException;
-
/**
* Created by davidcosse on 03/06/14.
*/
public interface NewImportService {
- void importAccountAsCSV(String contents) throws LimaException;
+ void importAccountAsCSV(String contents);
- void importEntryBooksAsCSV(String contents) throws LimaException;
+ void importEntryBooksAsCSV(String contents);
- void importFiscalPeriodsAsCSV(String contents) throws LimaException;
+ void importFiscalPeriodsAsCSV(String contents);
- void importFinancialTransactionsAsCSV(String contents) throws LimaException;
+ void importFinancialTransactionsAsCSV(String contents);
- void importEntriesAsCSV(String contents) throws LimaException;
+ void importEntriesAsCSV(String contents);
- void importAllAsCSV(String zippedBase64Str) throws LimaException;
+ void importAllAsCSV(String zippedBase64Str);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -69,7 +69,7 @@
Date endDate,
String selectedAccounts,
Boolean getEntries,
- Boolean movementedFilter) throws LimaException;
+ Boolean movementedFilter);
/**
* Generation du grand-livre.
@@ -84,7 +84,7 @@
BalanceTrial generateLedger(Date beginDate,
Date endDate,
String selectedAccounts,
- Boolean movementedFilter) throws LimaException;
+ Boolean movementedFilter);
/**
@@ -100,7 +100,7 @@
ReportsDatas generateAccountsReports(Account account,
Boolean thirdPartAccountsMode,
Date beginDate,
- Date endDate) throws LimaException;
+ Date endDate);
/**
* Generation du rapports des journaux.
@@ -113,7 +113,7 @@
*/
ReportsDatas generateEntryBooksReports(EntryBook entryBook,
Date beginDate,
- Date endDate) throws LimaException;
+ Date endDate);
/**
* Generate VAT.
@@ -122,6 +122,6 @@
* @return
* @throws LimaException
*/
- List<Object> generateVat(FiscalPeriod fiscalPeriod) throws LimaException;
+ List<Object> generateVat(FiscalPeriod fiscalPeriod);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -34,29 +34,29 @@
public interface VatStatementService {
void createVatStatement(VatStatement masterVatStatement,
- VatStatement vatStatement) throws LimaException;
+ VatStatement vatStatement);
- List<VatStatement> getAllVatStatements() throws LimaException;
+ List<VatStatement> getAllVatStatements();
List<VatStatement> getAllChildrenVatStatement(VatStatement vatStatement,
- List<VatStatement> result) throws LimaException;
+ List<VatStatement> result);
- List<VatStatement> getChildrenVatStatement(VatStatement masterVatStatement) throws LimaException;
+ List<VatStatement> getChildrenVatStatement(VatStatement masterVatStatement);
- void updateVatStatement(VatStatement vatStatement) throws LimaException;
+ void updateVatStatement(VatStatement vatStatement);
VatStatementAmounts vatStatementAmounts(VatStatement vatStatement,
Date selectedBeginDate,
- Date selectedEndDate) throws LimaException;
+ Date selectedEndDate);
- VatStatement findVatStatementByLabel(String label) throws LimaException;
+ VatStatement findVatStatementByLabel(String label);
List<VatStatementAmounts> vatStatementReport(Date beginDate,
- Date endDate) throws LimaException;
+ Date endDate);
- void removeAllVatStatement() throws LimaException;
+ void removeAllVatStatement();
- void removeVatStatement(VatStatement vatStatement) throws LimaException;
+ void removeVatStatement(VatStatement vatStatement);
/**
* Check if VAT Statement exist according the label given as parameter.
@@ -64,7 +64,7 @@
* @return true if a VAT statement with same label exist otherwise false.
* @throws LimaException
*/
- boolean checkVatStatementExist(String label) throws LimaException;
+ boolean checkVatStatementExist(String label);
}
\ No newline at end of file
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -39,9 +39,8 @@
* Retourne tous les comptes qui n'ont pas eux meme de sous compte.
*
* @return leaf accounts
- * @throws TopiaException
*/
- public List<Account> findAllLeafAccounts() throws TopiaException {
+ public List<Account> findAllLeafAccounts() {
// FIXME echatellier 20120413 la requete ne fonctionne pas
// et retourne vide
/*String query = "FROM " + Account.class.getName() + " a WHERE a NOT IN (" +
@@ -71,7 +70,7 @@
* par son numero, cela revient a avoir un compte par son numero.
*/
@Deprecated
- public Account findLeafAccountByNumber(String number) throws TopiaException {
+ public Account findLeafAccountByNumber(String number) {
return forAccountNumberEquals(number).findUniqueOrNull();
}
@@ -81,10 +80,9 @@
* @param accountNumberLow min account number
* @param accountNumberHigh max account number
* @return account list
- * @throws TopiaException
*/
public List<Account> findIntervalAccountByNumber(String accountNumberLow,
- String accountNumberHigh) throws TopiaException {
+ String accountNumberHigh) {
HqlAndParametersBuilder<Account> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(Account.PROPERTY_ACCOUNT_NUMBER, accountNumberLow);
builder.addLowerOrEquals(Account.PROPERTY_ACCOUNT_NUMBER, accountNumberHigh);
@@ -97,9 +95,8 @@
*
* @param account parent account
* @return
- * @throws TopiaException
*/
- public List<Account> findAllSubAccounts(Account account) throws TopiaException {
+ public List<Account> findAllSubAccounts(Account account) {
HqlAndParametersBuilder<Account> builder = newHqlAndParametersBuilder();
builder.addLike(Account.PROPERTY_ACCOUNT_NUMBER, account.getAccountNumber() + "_%");
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,7 +26,6 @@
package org.chorem.lima.entity;
import org.nuiton.topia.persistence.HqlAndParametersBuilder;
-import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.topia.persistence.TopiaQueryBuilderAddCriteriaOrRunQueryStep;
import java.util.Date;
@@ -44,9 +43,8 @@
*
* @param entryBook entry book property
* @return ClosedPeriodicEntryBook list
- * @throws TopiaException
*/
- public List<ClosedPeriodicEntryBook> findAllByEntryBook(EntryBook entryBook) throws TopiaException {
+ public List<ClosedPeriodicEntryBook> findAllByEntryBook(EntryBook entryBook) {
return forProperties(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, entryBook).findAll();
}
@@ -56,11 +54,9 @@
* @param entryBook
* @param financialPeriod
* @return ClosedPeriodicEntryBook
- * @throws TopiaException
*/
public ClosedPeriodicEntryBook findByEntryBookAndFinancialPeriod(
- EntryBook entryBook, FinancialPeriod financialPeriod)
- throws TopiaException {
+ EntryBook entryBook, FinancialPeriod financialPeriod) {
TopiaQueryBuilderAddCriteriaOrRunQueryStep<ClosedPeriodicEntryBook> queryStep = newQueryBuilder();
@@ -72,7 +68,7 @@
queryStep = queryStep.addEquals(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod);
}
- ClosedPeriodicEntryBook closedPeriodicEntryBook = queryStep.findFirstOrNull();
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = queryStep.findAnyOrNull();
return closedPeriodicEntryBook;
}
@@ -84,10 +80,9 @@
* @param beginDate begin date
* @param endDate end date
* @return all ClosedPeriodicEntryBook between begin and end
- * @throws TopiaException
*/
public List<ClosedPeriodicEntryBook> findAllByDates(Date beginDate,
- Date endDate) throws TopiaException {
+ Date endDate) {
HqlAndParametersBuilder<ClosedPeriodicEntryBook> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(PROPERTY_BEGIN_DATE, beginDate);
@@ -106,10 +101,9 @@
* @param beginDate begin date
* @param endDate end date
* @return all ClosedPeriodicEntryBook between begin and end
- * @throws TopiaException
*/
public List<ClosedPeriodicEntryBook> findAllByEntryBookAndDates(EntryBook entryBook,
- Date beginDate, Date endDate) throws TopiaException {
+ Date beginDate, Date endDate) {
HqlAndParametersBuilder<ClosedPeriodicEntryBook> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(PROPERTY_BEGIN_DATE, beginDate);
@@ -128,10 +122,9 @@
* @param beginDate begin date
* @param endDate end date
* @return all ClosedPeriodicEntryBook between begin and end
- * @throws TopiaException
*/
public List<ClosedPeriodicEntryBook> findAllByEntryBookAndDatesLocked(EntryBook entryBook,
- Date beginDate, Date endDate) throws TopiaException {
+ Date beginDate, Date endDate) {
HqlAndParametersBuilder<ClosedPeriodicEntryBook> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(PROPERTY_BEGIN_DATE, beginDate);
@@ -147,9 +140,8 @@
* Retourne les ClosedPeriodicEntryBook de toutes les exercices encore ouverts.
*
* @return les ClosedPeriodicEntryBook
- * @throws TopiaException
*/
- public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws TopiaException {
+ public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() {
List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
forEquals(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD + "." + FinancialPeriod.PROPERTY_LOCKED, false)
@@ -163,9 +155,8 @@
* Retourne les ClosedPeriodicEntryBook d'un exercice ouvert.
*
* @return les ClosedPeriodicEntryBook
- * @throws TopiaException
*/
- public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromFiscalPeriod(FiscalPeriod fiscalPeriod) throws TopiaException {
+ public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromFiscalPeriod(FiscalPeriod fiscalPeriod) {
List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
forEquals(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, fiscalPeriod)
.setOrderByArguments(PROPERTY_BEGIN_DATE)
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,7 +26,6 @@
package org.chorem.lima.entity;
import org.nuiton.topia.persistence.HqlAndParametersBuilder;
-import org.nuiton.topia.persistence.TopiaException;
import java.util.Date;
import java.util.List;
@@ -39,9 +38,8 @@
*
* @param date period middle date
* @return FinancialPeriod for {@code date}
- * @throws TopiaException
*/
- public FinancialPeriod findByDate(Date date) throws TopiaException {
+ public FinancialPeriod findByDate(Date date) {
HqlAndParametersBuilder<FinancialPeriod> builder = newHqlAndParametersBuilder();
builder.addLowerOrEquals(FinancialPeriod.PROPERTY_BEGIN_DATE, date);
@@ -57,9 +55,8 @@
* @param beginDate period begin date
* @param endDate period end date
* @return FinancialPeriod for {@code date}
- * @throws TopiaException
*/
- public List<FinancialPeriod> findByDates(Date beginDate, Date endDate) throws TopiaException {
+ public List<FinancialPeriod> findByDates(Date beginDate, Date endDate) {
HqlAndParametersBuilder<FinancialPeriod> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(FinancialPeriod.PROPERTY_BEGIN_DATE, beginDate);
@@ -74,9 +71,8 @@
* Retourne toutes les periodes ordonnées par date de debut de periode.
*
* @return all period ordered
- * @throws TopiaException
*/
- public List<FinancialPeriod> findAllOrderByBeginDate() throws TopiaException {
+ public List<FinancialPeriod> findAllOrderByBeginDate() {
List<FinancialPeriod> financialPeriod = newQueryBuilder()
.setOrderByArguments(FinancialPeriod.PROPERTY_BEGIN_DATE)
@@ -89,9 +85,8 @@
* Retourne toutes les periodes ordonnées par date de debut de periode.
*
* @return all period ordered
- * @throws TopiaException
*/
- public List<FinancialPeriod> findAllUnlockedOrderByBeginDate() throws TopiaException {
+ public List<FinancialPeriod> findAllUnlockedOrderByBeginDate() {
List<FinancialPeriod> financialPeriod = forLockedEquals(false)
.setOrderByArguments(FinancialPeriod.PROPERTY_BEGIN_DATE)
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,8 +25,6 @@
package org.chorem.lima.entity;
-import org.nuiton.topia.persistence.TopiaException;
-
/**
* Fiscal period entity DAO.
*
@@ -43,9 +41,8 @@
*
* @param financialPeriod financial period
* @return fiscal period containing financial period
- * @throws TopiaException
*/
- public FiscalPeriod findByFinancialPeriod(FinancialPeriod financialPeriod) throws TopiaException {
+ public FiscalPeriod findByFinancialPeriod(FinancialPeriod financialPeriod) {
FiscalPeriod result = forFinancialPeriodContains(financialPeriod).findUniqueOrNull();
@@ -56,9 +53,8 @@
* Get last fiscal period (higher end date).
*
* @return last fiscal period
- * @throws TopiaException
*/
- public FiscalPeriod getLastFiscalPeriod() throws TopiaException {
+ public FiscalPeriod getLastFiscalPeriod() {
FiscalPeriod result = newQueryBuilder()
.setOrderByArguments(FinancialPeriod.PROPERTY_END_DATE + " DESC")
@@ -71,9 +67,8 @@
* Get first fiscal period (higher end date).
*
* @return last fiscal period
- * @throws TopiaException
*/
- public FiscalPeriod getFirstFiscalPeriod() throws TopiaException {
+ public FiscalPeriod getFirstFiscalPeriod() {
FiscalPeriod result = newQueryBuilder()
.setOrderByArguments(FinancialPeriod.PROPERTY_END_DATE)
.findFirstOrNull();
@@ -85,9 +80,8 @@
* Get last non locked fiscal period (higher end date).
*
* @return last fiscal period
- * @throws TopiaException
*/
- public FiscalPeriod getLastUnlockedFiscalPeriod() throws TopiaException {
+ public FiscalPeriod getLastUnlockedFiscalPeriod() {
FiscalPeriod result = forLockedEquals(false)
.setOrderByArguments(FinancialPeriod.PROPERTY_END_DATE + " DESC")
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -1,11 +1,8 @@
package org.chorem.lima.entity;
-import java.util.List;
-
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
-import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.topia.persistence.TopiaIdFactory;
import org.nuiton.topia.persistence.internal.HibernateProvider;
import org.nuiton.topia.persistence.internal.TopiaHibernateSessionRegistry;
@@ -15,6 +12,8 @@
import org.nuiton.topia.persistence.support.TopiaSqlSupport;
import org.nuiton.topia.persistence.support.TopiaSqlWork;
+import java.util.List;
+
public class LimaCallaoTopiaPersistenceContext extends AbstractLimaCallaoTopiaPersistenceContext implements TopiaHibernateSupport, TopiaSqlSupport {
public LimaCallaoTopiaPersistenceContext(HibernateProvider hibernateProvider, TopiaListenableSupport listenableSupport, TopiaIdFactory topiaIdFactory, TopiaHibernateSessionRegistry sessionRegistry) {
@@ -47,12 +46,12 @@
}
@Override
- public <O> O findSingleResult(TopiaSqlQuery<O> query) throws TopiaException {
+ public <O> O findSingleResult(TopiaSqlQuery<O> query) {
return getSqlSupport().findSingleResult(query);
}
@Override
- public <O> List<O> findMultipleResult(TopiaSqlQuery<O> query) throws TopiaException {
+ public <O> List<O> findMultipleResult(TopiaSqlQuery<O> query) {
return getSqlSupport().findMultipleResult(query);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,14 +29,14 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
import org.chorem.lima.beans.EntryBookCondition;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.Filter.ConditionHandler;
import org.chorem.lima.ui.Filter.financialTransactionCondition.FinancialTransactionConditionHandler;
-import javax.swing.*;
+import javax.swing.JComponent;
+import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import java.util.List;
@@ -75,16 +75,8 @@
public Object[] getEntryBookList() {
EntryBookService entryBookService = LimaServiceFactory.getService(EntryBookService.class);
- Object[] result = {};
- List<EntryBook> periods = null;
- try {
- periods = entryBookService.getAllEntryBooks();
- result = periods.toArray();
- } catch (LimaException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Financial Period list", ex);
- }
- }
+ List<EntryBook> periods = entryBookService.getAllEntryBooks();
+ Object[] result = periods.toArray();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,7 +29,6 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
import org.chorem.lima.beans.FinancialPeriodCondition;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -37,7 +36,8 @@
import org.chorem.lima.ui.Filter.financialTransactionCondition.FinancialTransactionConditionHandler;
import org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchViewHandler;
-import javax.swing.*;
+import javax.swing.JComponent;
+import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import java.util.List;
@@ -78,16 +78,8 @@
public Object[] getFinancialPeriodList() {
FinancialPeriodService financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
- Object[] result = {};
- List<FinancialPeriod> periods = null;
- try {
- periods = financialPeriodService.getAllFinancialPeriods();
- result = periods.toArray();
- } catch (LimaException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Financial Period list", ex);
- }
- }
+ List<FinancialPeriod> periods = financialPeriodService.getAllFinancialPeriods();
+ Object[] result = periods.toArray();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,14 +29,14 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
import org.chorem.lima.beans.FiscalPeriodCondition;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.Filter.ConditionHandler;
import org.chorem.lima.ui.Filter.financialTransactionCondition.FinancialTransactionConditionHandler;
-import javax.swing.*;
+import javax.swing.JComponent;
+import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import java.util.List;
@@ -76,16 +76,8 @@
public Object[] getFiscalPeriodList() {
FiscalPeriodService fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
- Object[] result = {};
- List<FiscalPeriod> periods;
- try {
- periods = fiscalPeriodService.getAllFiscalPeriods();
- result = periods.toArray();
- } catch (LimaException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Fiscal Period list", ex);
- }
- }
+ List<FiscalPeriod> periods = fiscalPeriodService.getAllFiscalPeriods();
+ Object[] result = periods.toArray();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,7 +27,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.UsedAccountException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.entity.Account;
@@ -35,6 +39,7 @@
import org.chorem.lima.enums.ImportExportEnum;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.importexport.ImportExport;
+import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTreeTable;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
@@ -78,6 +83,8 @@
protected AccountView view;
+ protected ErrorHelper errorHelper;
+
/**
* Sort account with label length.
*/
@@ -112,6 +119,7 @@
// Gets factory service
LimaServiceFactory.addServiceListener(ImportService.class, this);
accountService = LimaServiceFactory.getService(AccountService.class);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
/**
@@ -263,6 +271,8 @@
model.insertNodeInto(newNode, node, node.getChildCount());
treeTable.expandPath(new TreePath(model.getPathToRoot(node)));
+ } catch (AccountException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
} finally {
dialog.dispose();
}
@@ -367,6 +377,8 @@
//lastPathComponent.setUserObject(account);
model.valueForPathChanged(treePath, account);
+ } catch (InvalidAccountNumberException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
} finally {
// close dialog
dialog.dispose();
@@ -391,18 +403,22 @@
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
- accountService.removeAccount(account);
+ try {
+ accountService.removeAccount(account);
- // add all sub accounts to parent
- DefaultTreeTableModel model = (DefaultTreeTableModel)treeTable.getTreeTableModel();
- MutableTreeTableNode parent = (MutableTreeTableNode)lastNode.getParent();
- for (int childIndex = lastNode.getChildCount() -1 ; childIndex >= 0 ; childIndex--) {
- MutableTreeTableNode child = (MutableTreeTableNode)lastNode.getChildAt(childIndex);
- model.insertNodeInto(child, parent, parent.getChildCount());
+ // add all sub accounts to parent
+ DefaultTreeTableModel model = (DefaultTreeTableModel) treeTable.getTreeTableModel();
+ MutableTreeTableNode parent = (MutableTreeTableNode) lastNode.getParent();
+ for (int childIndex = lastNode.getChildCount() - 1; childIndex >= 0; childIndex--) {
+ MutableTreeTableNode child = (MutableTreeTableNode) lastNode.getChildAt(childIndex);
+ model.insertNodeInto(child, parent, parent.getChildCount());
+ }
+
+ // remove node
+ model.removeNodeFromParent(lastNode);
+ } catch (UsedAccountException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
-
- // remove node
- model.removeNodeFromParent(lastNode);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,14 +27,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
-import javax.swing.*;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
import java.util.List;
/** Account combo box model. */
@@ -84,14 +84,7 @@
}
public List<Account> getDataList() {
- List<Account> result = null;
- try {
- result = accountService.getAllAccounts();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list accounts", eee);
- }
- }
+ List<Account> result = accountService.getAllAccounts();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,20 +25,18 @@
package org.chorem.lima.ui.combobox;
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+import java.util.List;
+
/**
* Opened financial period combo box model.
*
@@ -92,14 +90,7 @@
/** get the accounts list */
public List<EntryBook> getDataList() {
- List<EntryBook> result = null;
- try {
- result = entryBookService.getAllEntryBooks();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list entry books", eee);
- }
- }
+ List<EntryBook> result = entryBookService.getAllEntryBooks();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,7 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FiscalPeriodService;
@@ -36,7 +35,8 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import javax.swing.*;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
import java.util.List;
/**
@@ -129,16 +129,10 @@
//get unblocked financial periods data list
public List<FinancialPeriod> getDataList() {
List<FinancialPeriod> result = null;
- try {
- if (selectedFiscalPeriod != null) {
- result = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate());
- } else {
- result = financialPeriodService.getUnblockedFinancialPeriods();
- }
- } catch (LimaException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Financial Period list", ex);
- }
+ if (selectedFiscalPeriod != null) {
+ result = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate());
+ } else {
+ result = financialPeriodService.getUnblockedFinancialPeriods();
}
return result;
}
@@ -146,16 +140,10 @@
//get all financial periods data list
public List<FinancialPeriod> getAllDataList() {
List<FinancialPeriod> result = null;
- try {
- if (selectedFiscalPeriod != null) {
- result = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate());
- } else {
- result = financialPeriodService.getAllFinancialPeriods();
- }
- } catch (LimaException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Financial Period list", ex);
- }
+ if (selectedFiscalPeriod != null) {
+ result = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate());
+ } else {
+ result = financialPeriodService.getAllFinancialPeriods();
}
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,22 +25,18 @@
package org.chorem.lima.ui.combobox;
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.entity.FiscalPeriodImpl;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+import java.util.List;
+
public class FiscalPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener {
private static final long serialVersionUID = 1L;
@@ -106,14 +102,8 @@
//get unblocked fiscal periods data list
public List<FiscalPeriod> getDataList() {
- List<FiscalPeriod> result = null;
- try {
- result = fiscalPeriodService.getAllUnblockedFiscalPeriods();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list accounts", eee);
- }
- }
+ List<FiscalPeriod> result = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+
if (log.isDebugEnabled()) {
log.debug("Size of result : " + result.size());
log.debug("Beginning and end dates of first fiscal period : " + result.get(0).getBeginDate() + ", " + result.get(0).getEndDate());
@@ -125,14 +115,7 @@
//get all fiscal periods data list
public List<FiscalPeriod> getAllDataList() {
- List<FiscalPeriod> result = null;
- try {
- result = fiscalPeriodService.getAllFiscalPeriods();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list accounts", eee);
- }
- }
+ List<FiscalPeriod> result = fiscalPeriodService.getAllFiscalPeriods();
if (log.isDebugEnabled()) {
log.debug("Size of result : " + result);
log.debug("Beginning and end dates of first fiscal period : " + result.get(0).getBeginDate() + ", " + result.get(0).getEndDate());
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,7 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ImportService;
@@ -35,8 +34,8 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
-import javax.swing.*;
-import java.util.ArrayList;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
import java.util.Collections;
import java.util.List;
@@ -85,14 +84,7 @@
}
public List<Account> getDataList() {
- List<Account> result = new ArrayList<Account>();
- try {
- result = accountService.getAllLeafAccounts();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list subaccounts", eee);
- }
- }
+ List<Account> result = accountService.getAllLeafAccounts();
Collections.sort(result, new AccountComparator());
return result;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,12 +25,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
-import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.FinancialTransactionService;
-import org.chorem.lima.business.api.ImportService;
-import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
import javax.swing.AbstractListModel;
@@ -86,14 +82,7 @@
}
public List<String> getDataList() {
- List<String> result = null;
- try {
- result = financialTransactionService.getAllLetters();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list letters", eee);
- }
- }
+ List<String> result = financialTransactionService.getAllLetters();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,9 @@
* #L%
*/
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.util.ErrorHelper;
+
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
@@ -37,10 +40,13 @@
protected boolean editable;
+ protected ErrorHelper errorHelper;
+
public AbstractColumn(Class<?> columnClass, String columnName, boolean editable) {
this.columnClass = columnClass;
this.columnName = columnName;
this.editable = editable;
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
public Class<?> getColumnClass() {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,6 +26,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.entity.Entry;
@@ -120,7 +122,7 @@
*
* @param entry entry to insert
*/
- public Entry addEntry(Entry entry) {
+ public Entry addEntry(Entry entry) throws FinancialTransactionException {
Entry newEntry = null;
FinancialTransaction transaction = entry.getFinancialTransaction();
if (contains(transaction)) {
@@ -147,13 +149,13 @@
*
* @param row
*/
- public void removeTransaction(int row) {
+ public void removeTransaction(int row) throws FinancialTransactionException {
FinancialTransaction transaction = getTransactionAt(row);
removeAll(transaction.getEntry());
financialTransactionService.removeFinancialTransaction(transaction);
}
- public void removeEntry(int row) {
+ public void removeEntry(int row) throws FinancialTransactionException {
Entry entry = get(row);
FinancialTransaction transaction = entry.getFinancialTransaction();
if (transaction.sizeEntry() > 1) {
@@ -166,7 +168,7 @@
}
}
- public FinancialTransaction addTransaction(FinancialTransaction transaction) {
+ public FinancialTransaction addTransaction(FinancialTransaction transaction) throws FinancialTransactionException {
FinancialTransaction newTransaction = new FinancialTransactionImpl();
newTransaction.setEntryBook(transaction.getEntryBook());
newTransaction.setTransactionDate(transaction.getTransactionDate());
@@ -214,14 +216,14 @@
return e1.getFinancialTransaction().equals(e2.getFinancialTransaction());
}
- public void updateEntry(Entry entry) {
+ public void updateEntry(Entry entry) throws EntryException {
if (log.isDebugEnabled()) {
log.debug("Update Entry");
}
financialTransactionService.updateEntry(entry);
}
- public void updateTransaction(FinancialTransaction transaction) {
+ public void updateTransaction(FinancialTransaction transaction) throws FinancialTransactionException {
if (log.isDebugEnabled()) {
log.debug("Update transaction");
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,6 +27,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.EntryBookException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.ImportService;
@@ -36,6 +38,7 @@
import org.chorem.lima.enums.ImportExportEnum;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.importexport.ImportExport;
+import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTable;
import javax.swing.*;
@@ -64,10 +67,13 @@
protected EntryBookService entryBookService;
+ protected ErrorHelper errorHelper;
+
public EntryBookViewHandler(EntryBookView view) {
this.view = view;
entryBookService = LimaServiceFactory.getService(EntryBookService.class);
LimaServiceFactory.addServiceListener(ImportService.class, this);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
public void init() {
@@ -228,9 +234,12 @@
JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
-
- entryBookService.removeEntryBook(selectedEntryBook);
- entryBookTableModel.remove(selectedEntryBook);
+ try {
+ entryBookService.removeEntryBook(selectedEntryBook);
+ entryBookTableModel.remove(selectedEntryBook);
+ } catch (EntryBookException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,13 +27,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.business.utils.FinancialPeriodComparator;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTable;
import javax.swing.*;
@@ -61,12 +64,15 @@
protected FinancialPeriodView view;
+ protected ErrorHelper errorHelper;
+
protected FinancialPeriodViewHandler(FinancialPeriodView view) {
this.view = view;
financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
LimaServiceFactory.addServiceListener(ImportService.class, this);
LimaServiceFactory.addServiceListener(FiscalPeriodService.class, this);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
/**
@@ -115,8 +121,12 @@
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
- closedPeriodicEntryBook = financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
- model.setValue(selectedRow, closedPeriodicEntryBook);
+ try {
+ closedPeriodicEntryBook = financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ model.setValue(selectedRow, closedPeriodicEntryBook);
+ } catch (ClosedPeriodicEntryBookException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,21 +25,19 @@
package org.chorem.lima.ui.financialstatementchart;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.List;
-
-import javax.swing.tree.TreePath;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.FinancialStatementService;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementImpl;
import org.chorem.lima.service.LimaServiceFactory;
import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
+import javax.swing.tree.TreePath;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+
/**
* Tree table model for account edition.
*
@@ -100,21 +98,13 @@
public int getChildCount(Object node) {
int result = 0;
if (node == getRoot()) {
- try {
- result = financialStatementService.
- getChildrenFinancialStatement(null).size();
- } catch (LimaException eee) {
- log.debug("Can't count child", eee);
- }
+ result = financialStatementService.
+ getChildrenFinancialStatement(null).size();
} else {
FinancialStatement parentFinancialStatementHeader =
(FinancialStatement) node;
- try {
- result = financialStatementService.getChildrenFinancialStatement(
- parentFinancialStatementHeader).size();
- } catch (LimaException eee) {
- log.debug("Can't count child", eee);
- }
+ result = financialStatementService.getChildrenFinancialStatement(
+ parentFinancialStatementHeader).size();
}
return result;
}
@@ -123,23 +113,15 @@
public Object getChild(Object parent, int index) {
Object result = null;
if (parent == getRoot()) {
- try {
- List<FinancialStatement> financialStatements =
- financialStatementService.getChildrenFinancialStatement(null);
- result = financialStatements.get(index);
- } catch (LimaException eee) {
- log.debug("Can't get child", eee);
- }
+ List<FinancialStatement> financialStatements =
+ financialStatementService.getChildrenFinancialStatement(null);
+ result = financialStatements.get(index);
} else {
FinancialStatement parentFinancialStatement =
- (FinancialStatement) parent;
- try {
- List<FinancialStatement> financialStatements = financialStatementService.
- getChildrenFinancialStatement(parentFinancialStatement);
- result = financialStatements.get(index);
- } catch (LimaException eee) {
- log.debug("Can't get child", eee);
- }
+ (FinancialStatement) parent;
+ List<FinancialStatement> financialStatements = financialStatementService.
+ getChildrenFinancialStatement(parentFinancialStatement);
+ result = financialStatements.get(index);
}
return result;
}
@@ -148,24 +130,16 @@
public int getIndexOfChild(Object parent, Object child) {
int result = 0;
- if (parent == getRoot()) {
- try {
- List<FinancialStatement> financialStatements =
- financialStatementService.getChildrenFinancialStatement(null);
- result = financialStatements.indexOf(child);
- } catch (LimaException eee) {
- log.debug("Can't get index child", eee);
- }
+ if (parent == getRoot()) {
+ List<FinancialStatement> financialStatements =
+ financialStatementService.getChildrenFinancialStatement(null);
+ result = financialStatements.indexOf(child);
} else {
FinancialStatement parentFinancialStatement =
(FinancialStatement) parent;
- try {
- List<FinancialStatement> financialStatements = financialStatementService.
- getChildrenFinancialStatement(parentFinancialStatement);
- result = financialStatements.indexOf(child);
- } catch (LimaException eee) {
- log.debug("Can't get index child", eee);
- }
+ List<FinancialStatement> financialStatements = financialStatementService.
+ getChildrenFinancialStatement(parentFinancialStatement);
+ result = financialStatements.indexOf(child);
}
return result;
}
@@ -206,7 +180,7 @@
/** Refresh FinancialStatementChart. */
- public void refreshTree() throws LimaException {
+ public void refreshTree() {
modelSupport.fireNewRoot();
}
@@ -217,9 +191,8 @@
*
* @param path
* @param financialStatement
- * @throws LimaException
*/
- public void addFinancialStatement(TreePath path, FinancialStatement financialStatement) throws LimaException {
+ public void addFinancialStatement(TreePath path, FinancialStatement financialStatement) {
// Calling account service
FinancialStatement parentFinancialStatementHeader =
(FinancialStatement) path.getLastPathComponent();
@@ -237,9 +210,8 @@
*
* @param path
* @param financialStatement
- * @throws LimaException
*/
- public void updateFinancialStatement(TreePath path, FinancialStatement financialStatement) throws LimaException {
+ public void updateFinancialStatement(TreePath path, FinancialStatement financialStatement) {
financialStatementService.updateFinancialStatement(financialStatement);
modelSupport.fireTreeStructureChanged(path);
@@ -251,9 +223,8 @@
*
* @param path
* @param financialStatement
- * @throws LimaException
*/
- public void removeFinancialStatementObject(TreePath path, FinancialStatement financialStatement) throws LimaException {
+ public void removeFinancialStatementObject(TreePath path, FinancialStatement financialStatement) {
// Calling account service
int index = getIndexOfChild(
path.getParentPath().getLastPathComponent(), financialStatement);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
@@ -55,8 +56,12 @@
&& account != null
&& !entry.getAccount().getAccountNumber().equals(account.getAccountNumber()));
if (update) {
- entry.setAccount(account);
- tableModel.updateEntry(entry);
+ try {
+ entry.setAccount(account);
+ tableModel.updateEntry(entry);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -53,10 +54,14 @@
BigDecimal credit= (BigDecimal) value;
boolean update = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0));
if (update) {
- entry.setAmount(credit);
- entry.setDebit(false);
- tableModel.updateEntry(entry);
- tableModel.fireTransaction(entry.getFinancialTransaction());
+ try {
+ entry.setAmount(credit);
+ entry.setDebit(false);
+ tableModel.updateEntry(entry);
+ tableModel.fireTransaction(entry.getFinancialTransaction());
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.common.AbstractColumn;
@@ -66,8 +67,12 @@
FinancialTransaction transaction = tableModel.get(row).getFinancialTransaction();
boolean update = (transaction.getTransactionDate().compareTo((Date) value) != 0);
if (update) {
- transaction.setTransactionDate((Date) value);
- tableModel.updateTransaction(transaction);
+ try {
+ transaction.setTransactionDate((Date) value);
+ tableModel.updateTransaction(transaction);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -53,10 +54,14 @@
BigDecimal debit = (BigDecimal) value;
boolean update = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
if (update) {
- entry.setAmount(debit);
- entry.setDebit(true);
- tableModel.updateEntry(entry);
- tableModel.fireTransaction(entry.getFinancialTransaction());
+ try {
+ entry.setAmount(debit);
+ entry.setDebit(true);
+ tableModel.updateEntry(entry);
+ tableModel.fireTransaction(entry.getFinancialTransaction());
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -51,8 +52,12 @@
boolean update = (entry.getDescription() == null ||entry.getDescription().compareTo(description) != 0);
if (update) {
- entry.setDescription(description);
- tableModel.updateEntry(entry);
+ try {
+ entry.setDescription(description);
+ tableModel.updateEntry(entry);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialTransaction;
@@ -66,8 +67,12 @@
EntryBook entryBook = (EntryBook) value;
boolean update = (transaction.getEntryBook().getCode().compareTo(entryBook.getCode()) != 0);
if (update) {
- transaction.setEntryBook(entryBook);
- tableModel.updateTransaction(transaction);
+ try {
+ transaction.setEntryBook(entryBook);
+ tableModel.updateTransaction(transaction);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -49,6 +49,5 @@
return error;
-
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -28,6 +28,9 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
@@ -43,6 +46,7 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
+import org.chorem.lima.util.ErrorHelper;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@@ -85,7 +89,9 @@
protected FiscalPeriodService fiscalPeriodService;
protected FinancialTransactionService financialTransactionService;
protected Date lastAssignDate;
-
+
+ protected ErrorHelper errorHelper;
+
public FinancialTransactionViewHandler(FinancialTransactionView view) {
this.view = view;
@@ -96,6 +102,7 @@
LimaServiceFactory.addServiceListener(FinancialPeriodService.class, this);
LimaServiceFactory.addServiceListener(FiscalPeriodService.class, this);
LimaServiceFactory.addServiceListener(ImportService.class, this);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
initShortCuts();
}
@@ -334,25 +341,28 @@
TableCellEditor editor = table.getCellEditor();
editor.stopCellEditing();
}
+ try {
+ Entry entry = tableModel.get(rowSelected);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (entry.isDebit()) {
+ debit = debit.subtract(entry.getAmount());
+ } else {
+ credit = credit.subtract(entry.getAmount());
+ }
- Entry entry = tableModel.get(rowSelected);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- if (entry.isDebit()) {
- debit = debit.subtract(entry.getAmount());
- } else {
- credit = credit.subtract(entry.getAmount());
+ BigDecimal balance = credit.subtract(debit);
+ entry.setAmount(balance.abs());
+ entry.setDebit(balance.signum() > 0);
+ tableModel.updateEntry(entry);
+ int firstRow = tableModel.indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ tableModel.fireTableRowsUpdated(firstRow, lastRow);
+ view.setBalance(true);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
-
- BigDecimal balance = credit.subtract(debit);
- entry.setAmount(balance.abs());
- entry.setDebit(balance.signum() > 0);
- tableModel.updateEntry(entry);
- int firstRow = tableModel.indexOf(transaction);
- int lastRow = firstRow + transaction.sizeEntry() - 1;
- tableModel.fireTableRowsUpdated(firstRow, lastRow);
- view.setBalance(true);
}
}
@@ -394,23 +404,27 @@
ListSelectionModel selectionModel = table.getSelectionModel();
if (clipBoard != null && clipBoard instanceof FinancialTransaction) {
- FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
- FinancialTransaction transaction = (FinancialTransaction) clipBoard;
+ try {
+ FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
+ FinancialTransaction transaction = (FinancialTransaction) clipBoard;
- EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem();
+ EntryBook entryBook = (EntryBook) view.getEntryBookComboBox().getSelectedItem();
- transaction.setEntryBook(entryBook);
- transaction.setTransactionDate(getUseDate());
+ transaction.setEntryBook(entryBook);
+ transaction.setTransactionDate(getUseDate());
- tableModel.addTransaction(transaction);
+ tableModel.addTransaction(transaction);
- if (table.isEditing()) {
- TableCellEditor editor = table.getCellEditor();
- editor.stopCellEditing();
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
+ int index = tableModel.indexOf(transaction);
+ selectionModel.setSelectionInterval(index, index);
+ table.editCellAt(index, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
- int index = tableModel.indexOf(transaction);
- selectionModel.setSelectionInterval(index, index);
- table.editCellAt(index, 1);
}
}
@@ -426,28 +440,32 @@
ListSelectionModel selectionModel = table.getSelectionModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1 && clipBoard != null && clipBoard instanceof Entry) {
- Entry entryTmp = (Entry) clipBoard;
- FinancialTransaction transaction = tableModel.getTransactionAt(indexSelectedRow);
- Entry entry = new EntryImpl();
- entry.setFinancialTransaction(transaction);
- entry.setVoucher(entryTmp.getVoucher());
- entry.setAccount(entryTmp.getAccount());
- entry.setDescription(entryTmp.getDescription());
- entry.setAmount(entryTmp.getAmount());
- entry.setDebit(entryTmp.isDebit());
+ try {
+ Entry entryTmp = (Entry) clipBoard;
+ FinancialTransaction transaction = tableModel.getTransactionAt(indexSelectedRow);
+ Entry entry = new EntryImpl();
+ entry.setFinancialTransaction(transaction);
+ entry.setVoucher(entryTmp.getVoucher());
+ entry.setAccount(entryTmp.getAccount());
+ entry.setDescription(entryTmp.getDescription());
+ entry.setAmount(entryTmp.getAmount());
+ entry.setDebit(entryTmp.isDebit());
- if (table.isEditing()) {
- TableCellEditor editor = table.getCellEditor();
- editor.stopCellEditing();
- }
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
- tableModel.addEntry(entry);
+ tableModel.addEntry(entry);
- int index = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
- selectionModel.setSelectionInterval(index, index);
- //focus on second column
- table.changeSelection(index, 1, false, false);
- table.editCellAt(index, 1);
+ int index = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
+ selectionModel.setSelectionInterval(index, index);
+ //focus on second column
+ table.changeSelection(index, 1, false, false);
+ table.editCellAt(index, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
@@ -455,33 +473,36 @@
* Add new transaction.
*/
public void addFinancialTransaction() {
- FinancialPeriod financialPeriod = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
- EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem();
- FinancialTransactionTable table = view.getFinancialTransactionTable();
- FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
-
- FinancialTransaction financialTransaction = new FinancialTransactionImpl();
- // can be defined later by user
- if (entryBook != null) {
- financialTransaction.setEntryBook(entryBook);
- }
+ try {
+ EntryBook entryBook = (EntryBook) view.getEntryBookComboBox().getSelectedItem();
+ FinancialTransactionTable table = view.getFinancialTransactionTable();
+ FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
- // set date to the financial transaction
- financialTransaction.setTransactionDate(getUseDate());
- // create it
- financialTransaction = tableModel.addTransaction(financialTransaction);
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ // can be defined later by user
+ if (entryBook != null) {
+ financialTransaction.setEntryBook(entryBook);
+ }
- int addIndex = tableModel.indexOf(financialTransaction);
+ // set date to the financial transaction
+ financialTransaction.setTransactionDate(getUseDate());
+ // create it
+ financialTransaction = tableModel.addTransaction(financialTransaction);
- //select the new line
- if (table.isEditing()) {
- TableCellEditor editor = table.getCellEditor();
- editor.stopCellEditing();
+ int addIndex = tableModel.indexOf(financialTransaction);
+
+ //select the new line
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(addIndex, addIndex);
+ table.changeSelection(addIndex, 1, false, false);
+ table.editCellAt(addIndex, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
- ListSelectionModel selectionModel = table.getSelectionModel();
- selectionModel.setSelectionInterval(addIndex, addIndex);
- table.changeSelection(addIndex, 1, false, false);
- table.editCellAt(addIndex, 1);
}
/**
@@ -500,74 +521,78 @@
if (cellEditor != null) {
cellEditor.cancelCellEditing();
}
- //First case, where line selected is an entry : take its transaction
- //to select the last entry of the transaction
- Entry entryAt = tableModel.get(indexSelectedRow);
- FinancialTransaction transaction = entryAt.getFinancialTransaction();
- int rowLasEntry = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
- Entry lastEntry = tableModel.get(rowLasEntry);
- if (log.isDebugEnabled()) {
- log.debug("Selected row : " + indexSelectedRow);
- }
+ try {
+ //First case, where line selected is an entry : take its transaction
+ //to select the last entry of the transaction
+ Entry entryAt = tableModel.get(indexSelectedRow);
+ FinancialTransaction transaction = entryAt.getFinancialTransaction();
+ int rowLasEntry = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
+ Entry lastEntry = tableModel.get(rowLasEntry);
- String defaultVoucher = null;
- String defaultDescription = null;
+ if (log.isDebugEnabled()) {
+ log.debug("Selected row : " + indexSelectedRow);
+ }
- if (lastEntry != null) {
- defaultVoucher = lastEntry.getVoucher();
- defaultDescription = lastEntry.getDescription();
- }
+ String defaultVoucher = null;
+ String defaultDescription = null;
- // creates the new entry
- Entry entry = new EntryImpl();
- entry.setVoucher(defaultVoucher);
- if (log.isDebugEnabled()) {
- log.debug("Description of precedent entry : " + defaultDescription);
- }
- entry.setDescription(defaultDescription);
+ if (lastEntry != null) {
+ defaultVoucher = lastEntry.getVoucher();
+ defaultDescription = lastEntry.getDescription();
+ }
- String defaultAccount;
- //Actual (2012) tva percentage : 19,6%
- BigDecimal tvaPercentAdd = new BigDecimal(0.196);
- BigDecimal tvaTax = null;
+ // creates the new entry
+ Entry entry = new EntryImpl();
+ entry.setVoucher(defaultVoucher);
+ if (log.isDebugEnabled()) {
+ log.debug("Description of precedent entry : " + defaultDescription);
+ }
+ entry.setDescription(defaultDescription);
- //Calculation of tva tax only if first entry is a sale
- if (lastEntry != null && lastEntry.getAccount()!= null){
- defaultAccount = lastEntry.getAccount().getAccountNumber();
- if (defaultAccount.equals("410") || defaultAccount.equals("418")){
- tvaTax = (lastEntry.getAmount()).multiply(tvaPercentAdd);
+ String defaultAccount;
+ //Actual (2012) tva percentage : 19,6%
+ BigDecimal tvaPercentAdd = new BigDecimal(0.196);
+ BigDecimal tvaTax = null;
+
+ //Calculation of tva tax only if first entry is a sale
+ if (lastEntry != null && lastEntry.getAccount() != null) {
+ defaultAccount = lastEntry.getAccount().getAccountNumber();
+ if (defaultAccount.equals("410") || defaultAccount.equals("418")) {
+ tvaTax = (lastEntry.getAmount()).multiply(tvaPercentAdd);
+ }
}
- }
- //Set tva tax on the debit of the new entry
- if (tvaTax != null){
- entry.setAmount(tvaTax);
- entry.setDebit(true);
- }
+ //Set tva tax on the debit of the new entry
+ if (tvaTax != null) {
+ entry.setAmount(tvaTax);
+ entry.setDebit(true);
+ }
- if (log.isInfoEnabled()) {
- log.info("tva : " + tvaTax);
- }
+ if (log.isInfoEnabled()) {
+ log.info("tva : " + tvaTax);
+ }
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- entry.setDebit(credit.compareTo(debit) > 0);
- entry.setAmount(credit.subtract(debit).abs());
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ entry.setDebit(credit.compareTo(debit) > 0);
+ entry.setAmount(credit.subtract(debit).abs());
- entry.setFinancialTransaction(transaction);
+ entry.setFinancialTransaction(transaction);
- // create it in service
- tableModel.addEntry(entry);
+ // create it in service
+ tableModel.addEntry(entry);
- //select the new line
- int row = rowLasEntry + 1;
- ListSelectionModel selectionModel = table.getSelectionModel();
- selectionModel.setSelectionInterval(
- row, row);
- table.changeSelection(row, 1, false, false);
- table.editCellAt(row, 1);
-
+ //select the new line
+ int row = rowLasEntry + 1;
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ row, row);
+ table.changeSelection(row, 1, false, false);
+ table.editCellAt(row, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
} else {
if (log.isWarnEnabled()) {
log.warn("Call addentry selected transaction without selection");
@@ -591,17 +616,20 @@
t("lima.ui.financialtransaction.titleremovetransaction"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
+ try {
+ tableModel.removeTransaction(indexSelectedRow);
- tableModel.removeTransaction(indexSelectedRow);
-
- if (tableModel.size() > 0) {
- if (indexSelectedRow >= tableModel.size()) {
- indexSelectedRow = tableModel.size() - 1;
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
}
- selectionModel.setSelectionInterval(
- indexSelectedRow, indexSelectedRow);
- table.changeSelection(indexSelectedRow, 1, false, false);
- table.editCellAt(indexSelectedRow, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
}
@@ -626,17 +654,20 @@
t("lima.ui.financialtransaction.titleremoveentry"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
+ try {
+ tableModel.removeEntry(indexSelectedRow);
- tableModel.removeEntry(indexSelectedRow);
-
- if (tableModel.size() > 0) {
- if (indexSelectedRow >= tableModel.size()) {
- indexSelectedRow = tableModel.size() - 1;
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
}
- selectionModel.setSelectionInterval(
- indexSelectedRow, indexSelectedRow);
- table.changeSelection(indexSelectedRow, 1, false, false);
- table.editCellAt(indexSelectedRow, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
}
}
@@ -652,30 +683,34 @@
int selectedRow = table.getSelectedRow();
int selectedColumn = table.getSelectedColumn();
if (selectedRow >= 0 && (selectedColumn == 1 || selectedColumn == 3)) {
- Entry entrySource = tableModel.get(selectedRow);
- FinancialTransaction transaction = entrySource.getFinancialTransaction();
- for (Entry entryTarget : transaction.getEntry()) {
- if (entrySource != entryTarget) {
- switch (selectedColumn) {
- case 1 :
- if (!StringUtils.equals(entryTarget.getVoucher(), entrySource.getVoucher())) {
- entryTarget.setVoucher(entrySource.getVoucher());
- financialTransactionService.updateEntry(entryTarget);
- }
- break;
- case 3 :
- if (!StringUtils.equals(entryTarget.getDescription(), entrySource.getDescription())) {
- entryTarget.setDescription(entrySource.getDescription());
- financialTransactionService.updateEntry(entryTarget);
- }
- break;
+ try {
+ Entry entrySource = tableModel.get(selectedRow);
+ FinancialTransaction transaction = entrySource.getFinancialTransaction();
+ for (Entry entryTarget : transaction.getEntry()) {
+ if (entrySource != entryTarget) {
+ switch (selectedColumn) {
+ case 1:
+ if (!StringUtils.equals(entryTarget.getVoucher(), entrySource.getVoucher())) {
+ entryTarget.setVoucher(entrySource.getVoucher());
+ financialTransactionService.updateEntry(entryTarget);
+ }
+ break;
+ case 3:
+ if (!StringUtils.equals(entryTarget.getDescription(), entrySource.getDescription())) {
+ entryTarget.setDescription(entrySource.getDescription());
+ financialTransactionService.updateEntry(entryTarget);
+ }
+ break;
+ }
}
}
+ int firstRow = tableModel.indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ tableModel.fireTableRowsUpdated(firstRow, lastRow);
+ table.editCellAt(selectedRow, selectedColumn);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
- int firstRow = tableModel.indexOf(transaction);
- int lastRow = firstRow + transaction.sizeEntry() - 1;
- tableModel.fireTableRowsUpdated(firstRow, lastRow);
- table.editCellAt(selectedRow, selectedColumn);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -52,8 +53,12 @@
boolean update = (entry.getLettering() == null || entry.getLettering().compareTo(letter) != 0);
if (update) {
- entry.setLettering(letter);
- tableModel.updateEntry(entry);
+ try {
+ entry.setLettering(letter);
+ tableModel.updateEntry(entry);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -52,8 +53,12 @@
boolean update = (entry.getVoucher() == null || entry.getVoucher().compareTo(voucher) != 0);
if (update) {
- entry.setVoucher(voucher);
- tableModel.updateEntry(entry);
+ try {
+ entry.setVoucher(voucher);
+ tableModel.updateEntry(entry);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(e.getMessage());
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,11 +27,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionDefaultTable;
+import org.chorem.lima.util.ErrorHelper;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
@@ -58,8 +62,11 @@
protected FinancialTransactionUnbalancedView view;
+ protected ErrorHelper errorHelper;
+
protected FinancialTransactionUnbalancedViewHandler(FinancialTransactionUnbalancedView view) {
this.view = view;
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
initShortCuts();
}
@@ -141,26 +148,30 @@
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
- TableCellEditor cellEditor = table.getCellEditor();
- if (cellEditor != null) {
- cellEditor.cancelCellEditing();
- }
+ try {
+ TableCellEditor cellEditor = table.getCellEditor();
+ if (cellEditor != null) {
+ cellEditor.cancelCellEditing();
+ }
- Entry entry = tableModel.get(indexSelectedRow);
- //copy + paste the description
- Entry newEntry = new EntryImpl();
- newEntry.setFinancialTransaction(entry.getFinancialTransaction());
- newEntry.setVoucher(entry.getVoucher());
- newEntry.setDescription(entry.getDescription());
+ Entry entry = tableModel.get(indexSelectedRow);
+ //copy + paste the description
+ Entry newEntry = new EntryImpl();
+ newEntry.setFinancialTransaction(entry.getFinancialTransaction());
+ newEntry.setVoucher(entry.getVoucher());
+ newEntry.setDescription(entry.getDescription());
- tableModel.addEntry(newEntry);
- //select the new line
- int row = tableModel.indexOf(newEntry.getFinancialTransaction()) + newEntry.getFinancialTransaction().sizeEntry() - 1;
- ListSelectionModel selectionModel = table.getSelectionModel();
- selectionModel.setSelectionInterval(
- row, row);
- table.changeSelection(row, 1, false, false);
- table.editCellAt(row, 1);
+ tableModel.addEntry(newEntry);
+ //select the new line
+ int row = tableModel.indexOf(newEntry.getFinancialTransaction()) + newEntry.getFinancialTransaction().sizeEntry() - 1;
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ row, row);
+ table.changeSelection(row, 1, false, false);
+ table.editCellAt(row, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
} else {
if (log.isWarnEnabled()) {
log.warn("Call addentry selected transaction without selection");
@@ -192,19 +203,22 @@
t("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
+ try {
+ tableModel.removeEntry(indexSelectedRow);
- tableModel.removeEntry(indexSelectedRow);
-
- if (tableModel.size() > 0) {
- if (indexSelectedRow >= tableModel.size()) {
- indexSelectedRow = tableModel.size() - 1;
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
}
- ListSelectionModel selectionModel =
- table.getSelectionModel();
- selectionModel.setSelectionInterval(
- indexSelectedRow, indexSelectedRow);
- table.changeSelection(indexSelectedRow, 1, false, false);
- table.editCellAt(indexSelectedRow, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
}
} else {
@@ -238,18 +252,22 @@
t("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
- tableModel.removeTransaction(indexSelectedRow);
- //select the upper line
- if (tableModel.size() > 0) {
- if (indexSelectedRow >= tableModel.size()) {
- indexSelectedRow = tableModel.size() - 1;
+ try {
+ tableModel.removeTransaction(indexSelectedRow);
+ //select the upper line
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
}
- ListSelectionModel selectionModel =
- table.getSelectionModel();
- selectionModel.setSelectionInterval(
- indexSelectedRow, indexSelectedRow);
- table.changeSelection(indexSelectedRow, 1, false, false);
- table.editCellAt(indexSelectedRow, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
}
} else {
@@ -286,31 +304,34 @@
TableCellEditor editor = table.getCellEditor();
editor.stopCellEditing();
}
+ try {
+ Entry entry = tableModel.get(rowSelected);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (entry.isDebit()) {
+ debit = debit.subtract(entry.getAmount());
+ } else {
+ credit = credit.subtract(entry.getAmount());
+ }
- Entry entry = tableModel.get(rowSelected);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- if (entry.isDebit()) {
- debit = debit.subtract(entry.getAmount());
- } else {
- credit = credit.subtract(entry.getAmount());
+ BigDecimal balance = credit.subtract(debit);
+ entry.setAmount(balance.abs());
+ entry.setDebit(balance.signum() > 0);
+ tableModel.updateEntry(entry);
+ int firstRow = tableModel.indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ tableModel.fireTableRowsUpdated(firstRow, lastRow);
+ view.setBalance(true);
+
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(rowSelected, rowSelected);
+ table.changeSelection(rowSelected, 1, false, false);
+ table.editCellAt(rowSelected, 1);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
- BigDecimal balance = credit.subtract(debit);
- entry.setAmount(balance.abs());
- entry.setDebit(balance.signum() > 0);
- tableModel.updateEntry(entry);
- int firstRow = tableModel.indexOf(transaction);
- int lastRow = firstRow + transaction.sizeEntry() - 1;
- tableModel.fireTableRowsUpdated(firstRow, lastRow);
- view.setBalance(true);
-
- ListSelectionModel selectionModel = table.getSelectionModel();
- selectionModel.setSelectionInterval(rowSelected, rowSelected);
- table.changeSelection(rowSelected, 1, false, false);
- table.editCellAt(rowSelected, 1);
-
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,7 +29,8 @@
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
@@ -39,9 +40,17 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodImpl;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
import org.nuiton.util.DateUtil;
-import javax.swing.*;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
+import javax.swing.SwingWorker;
import javax.swing.event.ListSelectionEvent;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -71,6 +80,8 @@
protected FinancialTransactionService financialTransactionService;
+ protected ErrorHelper errorHelper;
+
/**
* Constructor.
*
@@ -83,6 +94,7 @@
financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class);
LimaServiceFactory.addServiceListener(FiscalPeriodService.class, this);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
public void init() {
@@ -154,18 +166,10 @@
// set begin date picker
Date beginDate = null;
Date endDate;
- try {
- FiscalPeriod result = fiscalPeriodService.getLastFiscalPeriod();
- if (result != null){
- beginDate = DateUtils.addDays(result.getEndDate(), 1);
- }
+ FiscalPeriod result = fiscalPeriodService.getLastFiscalPeriod();
+ if (result != null){
+ beginDate = DateUtils.addDays(result.getEndDate(), 1);
}
- catch (LimaException eee){
- if(log.isDebugEnabled()){
- log.debug("Can't get last fiscal period", eee);
- }
-
- }
if (beginDate == null) {
Calendar calendarBegin = Calendar.getInstance();
// set begindate to JAN 1 - 0:00.000 of this years
@@ -186,11 +190,15 @@
addPeriodDialog.setVisible(true);
if (checkFiscalPeriod(addPeriodDialog)) {
- FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
- fiscalPeriod.setBeginDate(addPeriodDialog.getBeginDatePicker().getDate());
- fiscalPeriod.setEndDate(addPeriodDialog.getEndDatePicker().getDate());
- fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod);
- tableModel.addValue(fiscalPeriod);
+ try {
+ FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
+ fiscalPeriod.setBeginDate(addPeriodDialog.getBeginDatePicker().getDate());
+ fiscalPeriod.setEndDate(addPeriodDialog.getEndDatePicker().getDate());
+ fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod);
+ tableModel.addValue(fiscalPeriod);
+ } catch (FiscalPeriodException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
@@ -283,11 +291,15 @@
JOptionPane.WARNING_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
- fiscalPeriodService.deleteFiscalPeriod(selectedFiscalPeriod);
+ try {
+ fiscalPeriodService.deleteFiscalPeriod(selectedFiscalPeriod);
- tableModel.remove(selectedFiscalPeriod);
- view.setBlockEnabled(false);
- view.setDeleteEnabled(false);
+ tableModel.remove(selectedFiscalPeriod);
+ view.setBlockEnabled(false);
+ view.setDeleteEnabled(false);
+ } catch (FiscalPeriodException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
}
@@ -409,13 +421,15 @@
}
} else {
+ try {
+ FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.blockFiscalPeriod(selectedFiscalPeriod);
+ tableModel.setValue(selectedRow, fiscalPeriodBlocked);
- FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.blockFiscalPeriod(selectedFiscalPeriod);
- tableModel.setValue(selectedRow, fiscalPeriodBlocked);
-
- view.setBlockEnabled(false);
- view.setDeleteEnabled(false);
-
+ view.setBlockEnabled(false);
+ view.setDeleteEnabled(false);
+ } catch (FiscalPeriodException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -28,7 +28,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ImportService;
@@ -84,29 +83,22 @@
+ "<p style=vertical-align:'bottom', horizontal-align:'center'>";
String htmlEnd = "</p></font>";
- try {
-
- long accountCount = accountService.getAccountCount();
- if (accountCount > 0) {
- setBackground(GREEN_BACKGROUND);
- String accountsString = t("lima.ui.home.chartaccounts.state1_2") + " "
- + accountCount + " " + t("lima.ui.home.chartaccounts.state2_2")
- + "<br/><br/><a href='#accountschart'>"
- + t("lima.ui.home.chartaccounts.modify") + "</a>";
- //set Text
- setText(htmlBegin + accountsString + htmlEnd);
- } else {
- setBackground(RED_BACKGROUND);
- String accountsString = t("lima.ui.home.chartaccounts.nothing")
- + "<br/><br/><a href='#accountschart'>"
- + t("lima.ui.home.chartaccounts.create") + "</a>";
- //set Text
- setText(htmlBegin + accountsString + htmlEnd);
- }
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't get datas account editor pane home", ex);
- }
+ long accountCount = accountService.getAccountCount();
+ if (accountCount > 0) {
+ setBackground(GREEN_BACKGROUND);
+ String accountsString = t("lima.ui.home.chartaccounts.state1_2") + " "
+ + accountCount + " " + t("lima.ui.home.chartaccounts.state2_2")
+ + "<br/><br/><a href='#accountschart'>"
+ + t("lima.ui.home.chartaccounts.modify") + "</a>";
+ //set Text
+ setText(htmlBegin + accountsString + htmlEnd);
+ } else {
+ setBackground(RED_BACKGROUND);
+ String accountsString = t("lima.ui.home.chartaccounts.nothing")
+ + "<br/><br/><a href='#accountschart'>"
+ + t("lima.ui.home.chartaccounts.create") + "</a>";
+ //set Text
+ setText(htmlBegin + accountsString + htmlEnd);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,16 +25,9 @@
package org.chorem.lima.ui.home;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.List;
-
-import javax.swing.event.HyperlinkEvent;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.ImportService;
@@ -42,6 +35,11 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
+import javax.swing.event.HyperlinkEvent;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+
/**
* Home view pane that display entry books statistics.
*
@@ -87,49 +85,43 @@
+ "<p style=vertical-align:'bottom', horizontal-align:'center'>";
String htmlEnd = "</p></font>";
- try {
+ List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
+ int ebSize = entryBooks.size();
+ if (ebSize > 0) {
+ setBackground(GREEN_BACKGROUND);
+ String entryBooksString;
+ if (ebSize == 1) {
+ entryBooksString = t("lima.ui.home.entrybooks.state.single")
+ + "<br/>" + entryBooks.get(0).getLabel()
+ + "<br/><br/><a href='#entrybookschart'>"
+ + t("lima.ui.home.entrybooks.modify") + "</a>";
- List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
- int ebSize = entryBooks.size();
- if (ebSize > 0) {
- setBackground(GREEN_BACKGROUND);
- String entryBooksString;
- if (ebSize == 1) {
- entryBooksString = t("lima.ui.home.entrybooks.state.single")
- + "<br/>" + entryBooks.get(0).getLabel()
- + "<br/><br/><a href='#entrybookschart'>"
- + t("lima.ui.home.entrybooks.modify") + "</a>";
-
- } else {
- entryBooksString = t("lima.ui.home.entrybooks.state1_2.plural")
- + " " + entryBooks.size() + " "
- + t("lima.ui.home.entrybooks.state2_2.plural") + "<ul>";
- for (int i = 0; i < ebSize && i < 3; i++) {
+ } else {
+ entryBooksString = t("lima.ui.home.entrybooks.state1_2.plural")
+ + " " + entryBooks.size() + " "
+ + t("lima.ui.home.entrybooks.state2_2.plural") + "<ul>";
+ for (int i = 0; i < ebSize && i < 3; i++) {
// for (EntryBook entryBook : entryBooks) {
- EntryBook entryBook = entryBooks.get(i);
- entryBooksString += "<li>" + entryBook.getCode() +
- " - " + entryBook.getLabel() + "</li>";
- }
- if (ebSize > 3) {
- entryBooksString += "<li> ... </li>";
- }
- entryBooksString += "</ul></p><p horizontal-align:'center'>"
- + "<a href='#entrybookschart'>"
- + t("lima.ui.home.entrybooks.modify") + "</a>";
+ EntryBook entryBook = entryBooks.get(i);
+ entryBooksString += "<li>" + entryBook.getCode() +
+ " - " + entryBook.getLabel() + "</li>";
}
- //set Text
- setText(htmlBegin + entryBooksString + htmlEnd);
- } else {
- setBackground(RED_BACKGROUND);
- //set Text
- setText(htmlBegin
- + t("lima.ui.home.entrybooks.nothing")
- + "<br/><br/><a href='#entrybookschart'>"
- + t("lima.ui.home.entrybooks.create") + "</a>" + htmlEnd);
+ if (ebSize > 3) {
+ entryBooksString += "<li> ... </li>";
+ }
+ entryBooksString += "</ul></p><p horizontal-align:'center'>"
+ + "<a href='#entrybookschart'>"
+ + t("lima.ui.home.entrybooks.modify") + "</a>";
}
-
- } catch (LimaException eee) {
- log.debug("Can't get datas account editor pane home", eee);
+ //set Text
+ setText(htmlBegin + entryBooksString + htmlEnd);
+ } else {
+ setBackground(RED_BACKGROUND);
+ //set Text
+ setText(htmlBegin
+ + t("lima.ui.home.entrybooks.nothing")
+ + "<br/><br/><a href='#entrybookschart'>"
+ + t("lima.ui.home.entrybooks.create") + "</a>" + htmlEnd);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,16 +25,9 @@
package org.chorem.lima.ui.home;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.List;
-
-import javax.swing.event.HyperlinkEvent;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialTransactionService;
@@ -46,8 +39,11 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
-import com.google.common.collect.Multiset.Entry;
+import javax.swing.event.HyperlinkEvent;
+import java.util.List;
+import static org.nuiton.i18n.I18n.t;
+
/**
* Home view pane that display statistics about unbalanced transactions.
*
@@ -104,52 +100,46 @@
+ "<p style=vertical-align:'bottom', horizontal-align:'center'>";
String htmlEnd = "</p></font>";
- try {
+ List<FiscalPeriod> unblockedFiscalPeriods =
+ fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
- List<FiscalPeriod> unblockedFiscalPeriods =
- fiscalPeriodService.getAllUnblockedFiscalPeriods();
- List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
-
- //Au moins un exercice ouvert et un journal ouvert
- if (unblockedFiscalPeriods.size() != 0 && entryBooks.size() != 0) {
- List<FinancialTransaction> financialTransactionsInexact =
- financialTransactionService.
- getAllInexactFinancialTransactions(unblockedFiscalPeriods.get(0));
- if (financialTransactionsInexact.size() > 0) {
- setBackground(RED_BACKGROUND);
- String transactionsString = financialTransactionsInexact.size()
- + " " + t("lima.ui.home.transaction.inexact")
- + "<br/><br/><a href='#financialtransactionunbalanced'>"
- + t("lima.ui.home.transaction.modifiy.inexact") + "</a>";
- //set Text
+ //Au moins un exercice ouvert et un journal ouvert
+ if (unblockedFiscalPeriods.size() != 0 && entryBooks.size() != 0) {
+ List<FinancialTransaction> financialTransactionsInexact =
+ financialTransactionService.
+ getAllInexactFinancialTransactions(unblockedFiscalPeriods.get(0));
+ if (financialTransactionsInexact.size() > 0) {
+ setBackground(RED_BACKGROUND);
+ String transactionsString = financialTransactionsInexact.size()
+ + " " + t("lima.ui.home.transaction.inexact")
+ + "<br/><br/><a href='#financialtransactionunbalanced'>"
+ + t("lima.ui.home.transaction.modifiy.inexact") + "</a>";
+ //set Text
+ setText(htmlBegin + transactionsString + htmlEnd);
+ } else {
+ List<FinancialTransaction> financialTransactionsBal =
+ financialTransactionService.getAllFinancialTransactionsBalanced(unblockedFiscalPeriods.get(0));
+
+ if (financialTransactionsBal.size() > 0) {
+ setBackground(GREEN_BACKGROUND);
+ String transactionsString = financialTransactionsBal.size()
+ + " " + t("lima.ui.home.transaction.balanced")
+ + "<br/><br/><a href='#financialtransactionbalanced'>"
+ + t("lima.ui.home.transaction.modifiy.balanced") + "</a>";
setText(htmlBegin + transactionsString + htmlEnd);
} else {
- List<FinancialTransaction> financialTransactionsBal =
- financialTransactionService.getAllFinancialTransactionsBalanced(unblockedFiscalPeriods.get(0));
-
- if (financialTransactionsBal.size() > 0) {
- setBackground(GREEN_BACKGROUND);
- String transactionsString = financialTransactionsBal.size()
- + " " + t("lima.ui.home.transaction.balanced")
- + "<br/><br/><a href='#financialtransactionbalanced'>"
- + t("lima.ui.home.transaction.modifiy.balanced") + "</a>";
- setText(htmlBegin + transactionsString + htmlEnd);
- } else {
- setBackground(RED_BACKGROUND);
- String transactionsString = t("lima.ui.home.transaction.nothing")
- + "<br/><br/><a href='#financialtransactionbalanced'>"
- + t("lima.ui.home.transaction.create") + "</a>";
- setText(htmlBegin + transactionsString + htmlEnd);
- }
-
+ setBackground(RED_BACKGROUND);
+ String transactionsString = t("lima.ui.home.transaction.nothing")
+ + "<br/><br/><a href='#financialtransactionbalanced'>"
+ + t("lima.ui.home.transaction.create") + "</a>";
+ setText(htmlBegin + transactionsString + htmlEnd);
}
- }else {
- setBackground(RED_BACKGROUND);
- setText("");
- }
- } catch (LimaException eee) {
- log.debug("Can't get datas account editor pane home", eee);
+ }
+ }else {
+ setBackground(RED_BACKGROUND);
+ setText("");
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,16 +25,9 @@
package org.chorem.lima.ui.home;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.List;
-
-import javax.swing.event.HyperlinkEvent;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.ImportService;
@@ -42,6 +35,11 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
+import javax.swing.event.HyperlinkEvent;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+
/**
* Panenl de la home view de lima qui affiche les statistiques de
* l'exercice en cours.
@@ -93,40 +91,35 @@
+ "<p style=vertical-align:'bottom', horizontal-align:'center'>";
String htmlEnd = "</p></font>";
- try {
+ //FISCAL PERIOD
+ List<FiscalPeriod> fiscalPeriods =
+ fiscalPeriodService.getAllFiscalPeriods();
+ List<FiscalPeriod> unblockedFiscalPeriods =
+ fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ if (unblockedFiscalPeriods.size() > 0) {
+ setBackground(GREEN_BACKGROUND);
+ String fiscalString = unblockedFiscalPeriods.size() + " "
+ + t("lima.ui.home.fiscalperiod.opened") + "<br/>"
+ + (fiscalPeriods.size() - unblockedFiscalPeriods.size())
+ + " " + t("lima.ui.home.fiscalperiod.closed")
+ + "<br/><br/><a href='#fiscalperiodschart'>"
+ + t("lima.ui.home.fiscalperiod.modify") + "</a>";
+ //set Text
+ setText(htmlBegin + fiscalString + htmlEnd);
- //FISCAL PERIOD
- List<FiscalPeriod> fiscalPeriods =
- fiscalPeriodService.getAllFiscalPeriods();
- List<FiscalPeriod> unblockedFiscalPeriods =
- fiscalPeriodService.getAllUnblockedFiscalPeriods();
- if (unblockedFiscalPeriods.size() > 0) {
- setBackground(GREEN_BACKGROUND);
- String fiscalString = unblockedFiscalPeriods.size() + " "
- + t("lima.ui.home.fiscalperiod.opened") + "<br/>"
- + (fiscalPeriods.size() - unblockedFiscalPeriods.size())
- + " " + t("lima.ui.home.fiscalperiod.closed")
- + "<br/><br/><a href='#fiscalperiodschart'>"
- + t("lima.ui.home.fiscalperiod.modify") + "</a>";
- //set Text
- setText(htmlBegin + fiscalString + htmlEnd);
-
- } else {
- setBackground(RED_BACKGROUND);
- String fiscalString = t("lima.ui.home.fiscalperiod.noopen");
- if (fiscalPeriods.size() > 0) {
- fiscalString += "<br/>" + fiscalPeriods.size() + " "
- + t("lima.ui.home.fiscalperiod.closed");
- }
- fiscalString += "<br/><br/><a href='#fiscalperiodschart'>"
- + t("lima.ui.home.fiscalperiod.create") + "</a>";
- //set Text
- setText(htmlBegin + fiscalString + htmlEnd);
-
+ } else {
+ setBackground(RED_BACKGROUND);
+ String fiscalString = t("lima.ui.home.fiscalperiod.noopen");
+ if (fiscalPeriods.size() > 0) {
+ fiscalString += "<br/>" + fiscalPeriods.size() + " "
+ + t("lima.ui.home.fiscalperiod.closed");
}
- } catch (LimaException eee) {
- log.debug("Can't get datas home", eee);
+ fiscalString += "<br/><br/><a href='#fiscalperiodschart'>"
+ + t("lima.ui.home.fiscalperiod.create") + "</a>";
+ //set Text
+ setText(htmlBegin + fiscalString + htmlEnd);
+
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,7 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.IdentityService;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.IdentityImpl;
@@ -47,14 +46,7 @@
}
public Identity getIdentity() {
- Identity identity = null;
- try {
- identity = identityService.getIdentity();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Identity", eee);
- }
- }
+ Identity identity = identityService.getIdentity();
if (identity == null) {
identity = new IdentityImpl();
}
@@ -62,13 +54,6 @@
}
public void updateIdentity(Identity identity) {
-
- try {
- identityService.updateIdentity(identity);
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't update Identity", eee);
- }
- }
+ identityService.updateIdentity(identity);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,8 +25,32 @@
package org.chorem.lima.ui.importexport;
-import static org.nuiton.i18n.I18n.t;
+import com.google.common.base.Charsets;
+import com.google.common.base.Strings;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.LimaTechnicalException;
+import org.chorem.lima.business.ImportEbpException;
+import org.chorem.lima.business.api.ExportService;
+import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.business.api.NewExportService;
+import org.chorem.lima.business.utils.ImportExportEntityEnum;
+import org.chorem.lima.enums.EncodingEnum;
+import org.chorem.lima.enums.ImportExportEnum;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
+import org.jdesktop.swingx.painter.BusyPainter;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -36,37 +60,14 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.concurrent.ExecutionException;
-import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.SwingWorker;
+import static org.nuiton.i18n.I18n.t;
-import com.google.common.base.Charsets;
-import com.google.common.base.Strings;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.api.ExportService;
-import org.chorem.lima.business.api.ImportService;
-import org.chorem.lima.business.api.NewExportService;
-import org.chorem.lima.business.utils.ImportExportEntityEnum;
-import org.chorem.lima.enums.EncodingEnum;
-import org.chorem.lima.enums.ImportExportEnum;
-import org.chorem.lima.service.LimaServiceFactory;
-import org.jdesktop.swingx.painter.BusyPainter;
-
/**
* Import export helper.
* Calling service with specified file to import and displaying wait view to user.
@@ -94,6 +95,8 @@
private ImportExportWaitView waitView;
+ protected ErrorHelper errorHelper;
+
public ImportExport(Component view) {
viewComponent = view;
@@ -101,6 +104,7 @@
importService = LimaServiceFactory.getService(ImportService.class);
exportService = LimaServiceFactory.getService(ExportService.class);
newExportService = LimaServiceFactory.getService(NewExportService.class);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
//create the wait dialog panel
waitView = new ImportExportWaitView();
@@ -134,86 +138,90 @@
protected String doInBackground() {
String datas;
String result = "";
- switch (importExportMethodeF) {
- case CSV_ALL_EXPORT:
- datas = newExportService.exportAllAsCSV(charset.name());
- createZipFile(filePath, datas);
- break;
- case CSV_ACCOUNTCHARTS_EXPORT:
- datas = exportService.exportAccountsChartAsCSV();
- createFile(filePath, charset.name(), datas);
- break;
- case CSV_ENTRYBOOKS_EXPORT:
- datas = exportService.exportEntryBookChartAsCSV();
- createFile(filePath, charset.name(), datas);
- break;
- case CSV_FINANCIALSTATEMENTS_EXPORT:
- datas = exportService.exportFinancialStatementChartAsCSV();
- createFile(filePath, charset.name(), datas);
- break;
- case CSV_VAT_EXPORT:
- datas = exportService.exportVatStatementChartAsCSV();
- createFile(filePath, charset.name(), datas);
- break;
- case EBP_ACCOUNTCHARTS_EXPORT:
- //For windows ebp
- datas = exportService.exportAccountsAsEBP();
- createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
- break;
- case EBP_ENTRIES_EXPORT:
- //For windows ebp
- datas = exportService.exportEntriesAsEBP();
- createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
- break;
- case CSV_ALL_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAllAsCSV(datas);
- break;
- case CSV_ACCOUNTCHARTS_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAsCSV(datas, ImportExportEntityEnum.ACCOUNT);
- break;
- case CSV_ENTRYBOOKS_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRYBOOK);
- break;
- case CSV_FINANCIALSTATEMENTS_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAsCSV(datas, ImportExportEntityEnum.FINANCIALSTATEMENT);
- break;
- case CSV_VAT_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAsCSV(datas, ImportExportEntityEnum.VATSTATEMENT);
- break;
- case CSV_ENTRIES_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRY);
- break;
- case PDF_VAT_IMPORT:
- int response = JOptionPane.showConfirmDialog(waitView,
- t("lima.importexport.usevatpdf"),
- t("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
- extractFile(filePath, charset.name());
- result = importService.importAsPDF(filePath, ImportExportEntityEnum.VATPDF, response == JOptionPane.YES_OPTION);
- break;
- case EBP_ACCOUNTCHARTS_IMPORT:
- //For windows ebp
- datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
- result = importService.importAccountsChartFromEbp(datas);
- break;
- case EBP_ENTRIES_IMPORT:
- //For windows ebp
- datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
- result = importService.importEntriesFromEbp(datas);
- break;
- case EBP_ENTRYBOOKS_IMPORT:
- datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
- result = importService.importEntryBookFromEbp(datas);
- break;
- case EBP_ENTRYBOOKS_EXPORT:
- datas = exportService.exportEntryBooksAsEBP();
- createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
- break;
+ try {
+ switch (importExportMethodeF) {
+ case CSV_ALL_EXPORT:
+ datas = newExportService.exportAllAsCSV(charset.name());
+ createZipFile(filePath, datas);
+ break;
+ case CSV_ACCOUNTCHARTS_EXPORT:
+ datas = exportService.exportAccountsChartAsCSV();
+ createFile(filePath, charset.name(), datas);
+ break;
+ case CSV_ENTRYBOOKS_EXPORT:
+ datas = exportService.exportEntryBookChartAsCSV();
+ createFile(filePath, charset.name(), datas);
+ break;
+ case CSV_FINANCIALSTATEMENTS_EXPORT:
+ datas = exportService.exportFinancialStatementChartAsCSV();
+ createFile(filePath, charset.name(), datas);
+ break;
+ case CSV_VAT_EXPORT:
+ datas = exportService.exportVatStatementChartAsCSV();
+ createFile(filePath, charset.name(), datas);
+ break;
+ case EBP_ACCOUNTCHARTS_EXPORT:
+ //For windows ebp
+ datas = exportService.exportAccountsAsEBP();
+ createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
+ break;
+ case EBP_ENTRIES_EXPORT:
+ //For windows ebp
+ datas = exportService.exportEntriesAsEBP();
+ createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
+ break;
+ case CSV_ALL_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAllAsCSV(datas);
+ break;
+ case CSV_ACCOUNTCHARTS_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.ACCOUNT);
+ break;
+ case CSV_ENTRYBOOKS_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRYBOOK);
+ break;
+ case CSV_FINANCIALSTATEMENTS_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.FINANCIALSTATEMENT);
+ break;
+ case CSV_VAT_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.VATSTATEMENT);
+ break;
+ case CSV_ENTRIES_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRY);
+ break;
+ case PDF_VAT_IMPORT:
+ int response = JOptionPane.showConfirmDialog(waitView,
+ t("lima.importexport.usevatpdf"),
+ t("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
+ extractFile(filePath, charset.name());
+ result = importService.importAsPDF(filePath, ImportExportEntityEnum.VATPDF, response == JOptionPane.YES_OPTION);
+ break;
+ case EBP_ACCOUNTCHARTS_IMPORT:
+ //For windows ebp
+ datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
+ result = importService.importAccountsChartFromEbp(datas);
+ break;
+ case EBP_ENTRIES_IMPORT:
+ //For windows ebp
+ datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
+ result = importService.importEntriesFromEbp(datas);
+ break;
+ case EBP_ENTRYBOOKS_IMPORT:
+ datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
+ result = importService.importEntryBookFromEbp(datas);
+ break;
+ case EBP_ENTRYBOOKS_EXPORT:
+ datas = exportService.exportEntryBooksAsEBP();
+ createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
+ break;
+ }
+ } catch (ImportEbpException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
return result;
}
@@ -392,13 +400,13 @@
return result;
}
- protected void createZipFile(String path, String zippedBase64Str) throws LimaException {
+ protected void createZipFile(String path, String zippedBase64Str) {
try {
byte[] bytes = Base64.decodeBase64(zippedBase64Str);
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
IOUtils.copy(inputStream, new FileOutputStream(path));
} catch (IOException e) {
- throw new LimaException("could not zip file", e);
+ throw new LimaTechnicalException(e);
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -28,7 +28,10 @@
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.LetteringFilterImpl;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
@@ -39,6 +42,7 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -81,6 +85,8 @@
protected LettringSelectionModel lettringSelectionModel;
protected LetteringEditModel editModel;
+ protected ErrorHelper errorHelper;
+
protected enum ButtonMode {DELETTRED, LETTRED, EQUALIZED, ALL}
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
@@ -92,6 +98,7 @@
accountService = LimaServiceFactory.getService(AccountService.class);
financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class);
entryBookService = LimaServiceFactory.getService(EntryBookService.class);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
/**
@@ -398,22 +405,26 @@
int[] selectedRows = view.getTable().getSelectedRows();
if (editModel.isEqualized() && selectedRows.length == 2) {
- /*Treatment only if one of values contains decimals*/
- Entry firstSelectedEntry = tableModel.get(selectedRows[0]);
- Entry secondSelectedEntry = tableModel.get(selectedRows[1]);
+ try {
+ /*Treatment only if one of values contains decimals*/
+ Entry firstSelectedEntry = tableModel.get(selectedRows[0]);
+ Entry secondSelectedEntry = tableModel.get(selectedRows[1]);
- Entry[] newEntriesFormEqualizing = financialTransactionService.getEntriesFromEqualizing(firstSelectedEntry, secondSelectedEntry);
+ Entry[] newEntriesFormEqualizing = financialTransactionService.getEntriesFromEqualizing(firstSelectedEntry, secondSelectedEntry);
- /*Add new entries to the model and the table*/
- Entry newSameAccountEntry = newEntriesFormEqualizing[0];
- Entry newCostOrProductEntry = newEntriesFormEqualizing[1];
- tableModel.addValue(newSameAccountEntry);
- tableModel.addValue(newCostOrProductEntry);
+ /*Add new entries to the model and the table*/
+ Entry newSameAccountEntry = newEntriesFormEqualizing[0];
+ Entry newCostOrProductEntry = newEntriesFormEqualizing[1];
+ tableModel.addValue(newSameAccountEntry);
+ tableModel.addValue(newCostOrProductEntry);
- /*Re-select the two entries (firstSelectedEntry and secondSelectedEntry)
- * and the new sameAccountEntry
- * */
- view.getLettringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], newSameAccountEntry);
+ /*Re-select the two entries (firstSelectedEntry and secondSelectedEntry)
+ * and the new sameAccountEntry
+ * */
+ view.getLettringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], newSameAccountEntry);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
@@ -470,12 +481,16 @@
LetteringTableModel tableModel = view.getTableModel();
- for (int indexEntry : entrieSelected){
- Entry entry = tableModel.get(indexEntry);
- entry.setLettering(newLetters);
- financialTransactionService.updateEntry(entry);
- tableModel.fireTableRowsUpdated(indexEntry, indexEntry);
+ try {
+ for (int indexEntry : entrieSelected) {
+ Entry entry = tableModel.get(indexEntry);
+ entry.setLettering(newLetters);
+ financialTransactionService.updateEntry(entry);
+ tableModel.fireTableRowsUpdated(indexEntry, indexEntry);
+ }
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx 2014-06-30 07:41:22 UTC (rev 3834)
@@ -46,17 +46,10 @@
// set begindate to JAN 1 - 0:00.000 of this years
Date beginDate = calendarBegin.getTime();
beginDate = DateUtils.truncate(beginDate, Calendar.DATE);
- try {
- FiscalPeriod result = fiscalPeriodService.getLastFiscalPeriod();
- if (result != null){
- beginDate = result.getEndDate();
- }
+ FiscalPeriod result = fiscalPeriodService.getLastFiscalPeriod();
+ if (result != null){
+ beginDate = result.getEndDate();
}
- catch (LimaException eee){
- if(log.isDebugEnabled()){
- log.debug("Can't get last fiscal period", eee);
- }
- }
beginDate = DateUtils.addDays(beginDate, 1);
getBeginDatePicker().setDate(beginDate);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,21 +24,19 @@
*/
package org.chorem.lima.ui.vatchart;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.List;
-
-import javax.swing.tree.TreePath;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.VatStatementService;
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementImpl;
import org.chorem.lima.service.LimaServiceFactory;
import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
+import javax.swing.tree.TreePath;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+
public class VatChartTreeTableModel extends AbstractTreeTableModel {
/** log. */
@@ -81,21 +79,13 @@
public int getChildCount(Object node) {
int result = 0;
if (node == getRoot()) {
- try {
- result = vatStatementService.
- getChildrenVatStatement(null).size();
- } catch (LimaException eee) {
- log.debug("Can't count child", eee);
- }
+ result = vatStatementService.
+ getChildrenVatStatement(null).size();
} else {
VatStatement parentVatStatementHeader =
(VatStatement) node;
- try {
- result = vatStatementService.getChildrenVatStatement(
- parentVatStatementHeader).size();
- } catch (LimaException eee) {
- log.debug("Can't count child", eee);
- }
+ result = vatStatementService.getChildrenVatStatement(
+ parentVatStatementHeader).size();
}
return result;
}
@@ -104,23 +94,15 @@
public Object getChild(Object parent, int index) {
Object result = null;
if (parent == getRoot()) {
- try {
- List<VatStatement> vatStatements =
- vatStatementService.getChildrenVatStatement(null);
- result = vatStatements.get(index);
- } catch (LimaException eee) {
- log.debug("Can't get child", eee);
- }
+ List<VatStatement> vatStatements =
+ vatStatementService.getChildrenVatStatement(null);
+ result = vatStatements.get(index);
} else {
VatStatement parentVatStatement =
(VatStatement) parent;
- try {
- List<VatStatement> vatStatements = vatStatementService.
- getChildrenVatStatement(parentVatStatement);
- result = vatStatements.get(index);
- } catch (LimaException eee) {
- log.debug("Can't get child", eee);
- }
+ List<VatStatement> vatStatements = vatStatementService.
+ getChildrenVatStatement(parentVatStatement);
+ result = vatStatements.get(index);
}
return result;
}
@@ -130,23 +112,15 @@
int result = 0;
if (parent == getRoot()) {
- try {
- List<VatStatement> vatStatements =
- vatStatementService.getChildrenVatStatement(null);
- result = vatStatements.indexOf(child);
- } catch (LimaException eee) {
- log.debug("Can't get index child", eee);
- }
+ List<VatStatement> vatStatements =
+ vatStatementService.getChildrenVatStatement(null);
+ result = vatStatements.indexOf(child);
} else {
VatStatement parentVatStatement =
(VatStatement) parent;
- try {
- List<VatStatement> vatStatements = vatStatementService.
- getChildrenVatStatement(parentVatStatement);
- result = vatStatements.indexOf(child);
- } catch (LimaException eee) {
- log.debug("Can't get index child", eee);
- }
+ List<VatStatement> vatStatements = vatStatementService.
+ getChildrenVatStatement(parentVatStatement);
+ result = vatStatements.indexOf(child);
}
return result;
}
@@ -178,7 +152,7 @@
/** Refresh VatStatementChart. */
- public void refreshTree() throws LimaException {
+ public void refreshTree() {
modelSupport.fireNewRoot();
}
@@ -189,9 +163,8 @@
*
* @param path
* @param vatStatement
- * @throws LimaException
*/
- public void addVatStatement(TreePath path, VatStatement vatStatement) throws LimaException {
+ public void addVatStatement(TreePath path, VatStatement vatStatement) {
// Calling account service
//fixed bug when path is null
VatStatement parentVatStatementHeader = null;
@@ -210,9 +183,8 @@
*
* @param path
* @param vatStatement
- * @throws LimaException
*/
- public void updateVatStatement(TreePath path, VatStatement vatStatement) throws LimaException {
+ public void updateVatStatement(TreePath path, VatStatement vatStatement) {
vatStatementService.updateVatStatement(vatStatement);
modelSupport.fireTreeStructureChanged(path);
@@ -223,9 +195,8 @@
*
* @param path
* @param vatStatement
- * @throws LimaException
*/
- public void removeVatStatementObject(TreePath path, VatStatement vatStatement) throws LimaException {
+ public void removeVatStatementObject(TreePath path, VatStatement vatStatement) {
// Calling account service
int index = getIndexOfChild(
path.getParentPath().getLastPathComponent(), vatStatement);
@@ -238,11 +209,7 @@
public void setValueAt(Object value, Object node, int column) {
VatStatement vatStatement = (VatStatement) node;
vatStatement.setAccounts((String) value);
- try {
vatStatementService.updateVatStatement(vatStatement);
- } catch (LimaException eee) {
- log.debug("Can't update vatStatement", eee);
- }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,8 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaBusinessException;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.business.api.VatStatementService;
@@ -37,9 +35,15 @@
import org.chorem.lima.enums.VatStatementsChartEnum;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.importexport.ImportExport;
+import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTreeTable;
-import javax.swing.*;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
import javax.swing.tree.TreePath;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -147,27 +151,7 @@
if (newVatChartMovement != null) {
// add it
- try {
- treeTableModel.addVatStatement(treePath, newVatChartMovement);
- } catch (LimaBusinessException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add Vat chart Movement", eee);
- }
- JOptionPane.showMessageDialog(
- view,
- eee.getMessage(),
- t("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- } catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add Vat chart Movement", eee);
- }
- JOptionPane.showMessageDialog(
- view,
- eee.getMessage(),
- t("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- }
+ treeTableModel.addVatStatement(treePath, newVatChartMovement);
refresh();
}
}
@@ -218,19 +202,8 @@
//if action confirmed
if (vatStatement != null) {
// update it
- try {
- treeTableModel.updateVatStatement(
- treePath, vatStatement);
- } catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add update", eee);
- }
- JOptionPane.showMessageDialog(
- view,
- eee.getMessage(),
- t("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- }
+ treeTableModel.updateVatStatement(
+ treePath, vatStatement);
}
}
refresh();
@@ -258,14 +231,7 @@
// if action confirmed
if (value != null) {
if (form.getDeleteVatStatementChart().isSelected()) {
- try {
- vatStatementService.removeAllVatStatement();
-
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't delete financial statement chart", eee);
- }
- }
+ vatStatementService.removeAllVatStatement();
}
VatStatementsChartEnum defaultVatStatementsEnum =
(VatStatementsChartEnum) value;
@@ -302,19 +268,8 @@
t("lima.common.info"),
JOptionPane.INFORMATION_MESSAGE);
} else {
- try {
- treeTableModel.removeVatStatementObject(
- treePath, vatStatement);
- } catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't delete account", eee);
- }
- JOptionPane.showMessageDialog(
- view,
- eee.getMessage(),
- t("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- }
+ treeTableModel.removeVatStatementObject(
+ treePath, vatStatement);
}
}
refresh();
@@ -325,13 +280,7 @@
JXTreeTable treeTable = view.getTreeTable();
VatChartTreeTableModel treeTableModel =
(VatChartTreeTableModel) treeTable.getTreeTableModel();
- try {
- treeTableModel.refreshTree();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't refresh model", eee);
- }
- }
+ treeTableModel.refreshTree();
//refresh view
view.repaint();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -99,6 +99,17 @@
* Display a user friendly error frame.
*
* @param message message for user
+ */
+ public void showErrorMessage(String message) {
+ JOptionPane.showMessageDialog(null, message,
+ t("lima.ui.common.error"), JOptionPane.ERROR_MESSAGE);
+ }
+
+
+ /**
+ * Display a user friendly error frame.
+ *
+ * @param message message for user
* @param cause exception cause
*/
public void showErrorDialog(String message, Throwable cause) {
1
0
Author: dcosse
Date: 2014-06-12 18:07:45 +0200 (Thu, 12 Jun 2014)
New Revision: 3833
Url: http://forge.chorem.org/projects/lima/repository/revisions/3833
Log:
#934 refactoring sur dao suppression methodes d?\195?\169preci?\195?\169es
Removed:
trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java
trunk/lima-swing/src/test/java/org/chorem/lima/ui/account/AccountViewHandlerTest.java
trunk/pom.xml
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -27,13 +27,18 @@
import static org.nuiton.i18n.I18n.t;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
+import org.apache.commons.lang3.StringUtils;
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
@@ -242,9 +247,9 @@
Account result;
try {
// DAO
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ AccountTopiaDao accountDao = getDaoHelper().getAccountDao();
accountingRules.updateAccountRules(account);
- result = AccountTopiaDao.update(account);
+ result = accountDao.update(account);
} catch (Exception ex) {
throw new LimaException("Can't update account", ex);
@@ -252,4 +257,71 @@
return result;
}
+
+ @Override
+ public List<Account> stringToListAccounts(String selectedAccounts) throws TopiaException {
+ Set<Account> accounts = new HashSet<Account>();
+ if (selectedAccounts != null) {
+ AccountTopiaDao accountDao = getDaoHelper().getAccountDao();
+ //Remove Spaces
+ String result = StringUtils.deleteWhitespace(selectedAccounts);
+
+ Boolean first = true;
+ // TODO DCossé 12/06/14 separator can be anything as accounts are text field
+ StringTokenizer stStar = new StringTokenizer(result, "-");
+ while (stStar.hasMoreTokens()) {
+ String subString = stStar.nextToken();
+
+ //Split comma
+ // TODO DCossé 12/06/14 separator can be anything as accounts are text field
+ StringTokenizer stComma = new StringTokenizer(subString, ",");
+ while (stComma.hasMoreTokens()) {
+ String s = stComma.nextToken();
+ //if intervall account
+ if (s.contains("..") && !s.endsWith("..")) {
+ //Split ..
+ String stringDoubleDot[] = s.split("\\.\\.");
+
+ List<Account> resultInterval = accountDao.findIntervalAccountByNumber(stringDoubleDot[0], stringDoubleDot[1]);
+
+ //if first add accounts, else remove
+ if (first) {
+ accounts.addAll(resultInterval);
+ } else {
+ accounts.removeAll(resultInterval);
+ }
+ }
+ //else one account
+ else {
+
+ Account account = accountDao.forAccountNumberEquals(s).findUniqueOrNull();
+
+ //if exist
+ if (account != null) {
+ //if first
+ if (first) {
+ accounts.add(account);
+ } else {
+ accounts.remove(account);
+ }
+ }
+ //search all account start with accountnumber
+ else {
+ List<Account> accountsResult = accountDao.findLeafAccounts(s);
+ if (accountsResult != null) {
+ //if first
+ if (first) {
+ accounts.addAll(accountsResult);
+ } else {
+ accounts.removeAll(accountsResult);
+ }
+ }
+ }
+ }
+ }
+ first = false;
+ }
+ }
+ return new ArrayList<Account>(accounts);
+ }
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -50,6 +50,7 @@
import org.chorem.lima.beans.FinancialStatementDatasImpl;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.FinancialStatementService;
import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.entity.Account;
@@ -66,6 +67,9 @@
@EJB
private ReportService reportService;
+ @EJB
+ private AccountService accountService;
+
protected static final Log log = LogFactory.getLog(FinancialStatementServiceImpl.class);
@Override
@@ -80,7 +84,7 @@
FinancialStatement masterfinancialStatementUpdate = null;
if (masterFinancialStatement != null) {
- masterfinancialStatementUpdate = financialStatementTopiaDao.findByLabel(masterFinancialStatement.getLabel());
+ masterfinancialStatementUpdate = financialStatementTopiaDao.forLabelEquals(masterFinancialStatement.getLabel()).findAnyOrNull();
}
// check if parent account exist;
@@ -230,9 +234,7 @@
List<FinancialStatementAmounts> subResult = new ArrayList<FinancialStatementAmounts>();
for (FinancialStatement subFinancialStatement : financialStatements) {
- FinancialStatementAmounts financialStatementAmounts =
- financialStatementAmounts(subFinancialStatement,
- selectedBeginDate, selectedEndDate);
+ FinancialStatementAmounts financialStatementAmounts = financialStatementAmounts(subFinancialStatement, selectedBeginDate, selectedEndDate);
if (!subFinancialStatement.isHeader()) {
//on calcul
grossAmount =
@@ -350,16 +352,14 @@
Amounts amounts;
String accountsString = financialStatement.getAccounts();
if (accountsString != null && !accountsString.equals("")) {
- amounts = amountFromAccountList(accountsString,
- selectedBeginDate, selectedEndDate);
+ amounts = amountFromAccountList(accountsString, selectedBeginDate, selectedEndDate);
debitAmount = debitAmount.add(amounts.getDebit());
creditAmount = creditAmount.add(amounts.getCredit());
}
// DEBIT ACCOUNTS LIST
String debitAccountsString = financialStatement.getDebitAccounts();
if (debitAccountsString != null && !debitAccountsString.equals("")) {
- amounts = amountFromAccountList(debitAccountsString,
- selectedBeginDate, selectedEndDate);
+ amounts = amountFromAccountList(debitAccountsString, selectedBeginDate, selectedEndDate);
debitAmount = debitAmount.add(amounts.getDebit());
}
//CREDIT ACCOUNTS LIST
@@ -373,9 +373,7 @@
String provisionDeprecationAccountsString =
financialStatement.getProvisionDeprecationAccounts();
if (provisionDeprecationAccountsString != null && !provisionDeprecationAccountsString.equals("")) {
- amounts = amountFromAccountList(
- provisionDeprecationAccountsString, selectedBeginDate,
- selectedEndDate);
+ amounts = amountFromAccountList(provisionDeprecationAccountsString, selectedBeginDate, selectedEndDate);
provisionDeprecationAmount =
provisionDeprecationAmount.add(amounts.getCredit());
provisionDeprecationAmount =
@@ -420,13 +418,16 @@
StringTokenizer stQuote = new StringTokenizer(result, "-");
while (stQuote.hasMoreTokens()) {
String s = stQuote.nextToken();
- List<Account> accountsList = accountTopiaDao.stringToListAccounts(s, false);
+ //List<Account> accountsList = accountTopiaDao.stringToListAccounts(s, false);
+ List<Account> accountsList = accountService.stringToListAccounts(s);
BigDecimal debitTemp = new BigDecimal(0);
BigDecimal creditTemp = new BigDecimal(0);
for (Account account : accountsList) {
ReportsDatas reportsDatas = reportService.
- generateAccountsReports(account, true,
- selectedBeginDate, selectedEndDate);
+ generateAccountsReports(
+ account,
+ true,
+ selectedBeginDate, selectedEndDate);
if (reportsDatas.getSoldeDebit()) {
debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
} else {
@@ -471,20 +472,20 @@
for (FinancialStatement financialStatement : financialStatementsList) {
accountsList.removeAll(
- accountTopiaDao.stringToListAccounts(
- financialStatement.getAccounts(), true));
+ accountService.stringToListAccounts(
+ financialStatement.getAccounts()));
accountsList.removeAll(
- accountTopiaDao.stringToListAccounts(
- financialStatement.getCreditAccounts(), true));
+ accountService.stringToListAccounts(
+ financialStatement.getCreditAccounts()));
accountsList.removeAll(
- accountTopiaDao.stringToListAccounts(
- financialStatement.getDebitAccounts(), true));
+ accountService.stringToListAccounts(
+ financialStatement.getDebitAccounts()));
accountsList.removeAll(
- accountTopiaDao.stringToListAccounts(
- financialStatement.getProvisionDeprecationAccounts(), true));
+ accountService.stringToListAccounts(
+ financialStatement.getProvisionDeprecationAccounts()));
}
for (Account account : accountsList) {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -432,8 +432,7 @@
calendar.setTime(fiscalPeriod.getEndDate());
//Sets entries
- BalanceTrial results = reportService.generateBalanceTrial(localFiscalPeriod.getBeginDate(),
- localFiscalPeriod.getEndDate(), null, false, false);
+ BalanceTrial results = reportService.generateBalanceTrial(localFiscalPeriod.getBeginDate(),localFiscalPeriod.getEndDate(), null, false, false);
List<ReportsDatas> reportsDatasList = (List<ReportsDatas>) results.getReportsDatas();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -319,6 +319,7 @@
List<Account> accounts;
//Remove Spaces
+ // TODO DCossé 12/06/14 selectedAccounts is allways NULL
String result = StringUtils.deleteWhitespace(selectedAccounts);
//if no filter account
if (result == null || result.equals("")) {
@@ -326,7 +327,7 @@
}
//build list account from selectedAccounts
else {
- accounts = accountTopiaDao.stringToListAccounts( result, false);
+ accounts = accountService.stringToListAccounts(result);
}
Collections.sort(accounts, new AccountComparator());
@@ -387,11 +388,7 @@
Date endDate,
String selectedAccounts,
Boolean movementedFilter) throws LimaException {
- return generateBalanceTrial(beginDate,
- endDate,
- selectedAccounts,
- true,
- movementedFilter);
+ return generateBalanceTrial(beginDate, endDate, selectedAccounts, true, movementedFilter);
}
/**
@@ -419,9 +416,7 @@
//FIXME echatellier 44 is hardcoded and depends on
//french rule ?
if (account.getAccountNumber().startsWith("44")) {
- list.add(generateBalanceTrial(fp.getBeginDate(),
- fp.getEndDate(), account.getAccountNumber(),
- true, false));
+ list.add(generateBalanceTrial(fp.getBeginDate(), fp.getEndDate(), account.getAccountNumber(), true, false));
}
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -40,10 +40,10 @@
import org.chorem.lima.beans.VatStatementDatas;
import org.chorem.lima.beans.VatStatementDatasImpl;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.business.api.VatStatementService;
import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.AccountTopiaDao;
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementTopiaDao;
import org.nuiton.topia.persistence.TopiaException;
@@ -61,6 +61,9 @@
@EJB
private ReportService reportService;
+ @EJB
+ private AccountService accountService;
+
@Override
public void createVatStatement(VatStatement masterVatStatement,
VatStatement vatStatement) throws LimaException {
@@ -228,8 +231,7 @@
String accountNumbersList = findAccountNumberByVatStatement(vatStatement);
- AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
- List<Account> accountsList = accountTopiaDao.stringToListAccounts(accountNumbersList, false);
+ List<Account> accountsList = accountService.stringToListAccounts(accountNumbersList);
for (Account account : accountsList) {
ReportsDatas reportsDatas = reportService.
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -220,4 +220,15 @@
account4.setLabel("Unsaved account");
accountService.removeAccount(account4);
}
+
+ @Test
+ public void testStringToListAccounts() throws Exception {
+ List<Account> accounts = accountService.stringToListAccounts("50..511");
+ Assert.assertEquals(5, accounts.size());
+
+ accounts = accountService.stringToListAccounts("60..99");
+ Assert.assertEquals(0, accounts.size());
+
+ context.close();
+ }
}
\ No newline at end of file
Deleted: trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -1,68 +0,0 @@
-/*
- * #%L
- * $Id: AccountDAOTest.java 3585 2012-08-08 14:52:14Z tchemit $
- * $HeadURL: http://svn.chorem.org/svn/lima/trunk/lima-business/src/test/java/org/chorem… $
- * %%
- * Copyright (C) 2012 Codelutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.entity;
-
-import org.chorem.lima.business.AbstractLimaTest;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.nuiton.topia.persistence.TopiaException;
-
-import java.util.List;
-
-/**
- * Test for AccountDAO class.
- *
- * @author chatellier
- * @version $Revision: 3585 $
- *
- * Last update : $Date: 2012-08-08 16:52:14 +0200 (mer. 08 août 2012) $
- * By : $Author: tchemit $
- */
-public class AccountDAOTest extends AbstractLimaTest {
-
- @Before
- public void initTest() throws Exception {
- initTestDatabase();
- }
-
- /**
- * Test la recherche de compte par interval.
- * @throws TopiaException
- */
- @Test
- public void testStringToListAccounts() throws Exception {
- initTestWithAccounts();
-
- AccountTopiaDao accountDAO = context.newPersistenceContext().getAccountDao();
-
- List<Account> accounts = accountDAO.stringToListAccounts("50..511", false);
- Assert.assertEquals(5, accounts.size());
-
- accounts = accountDAO.stringToListAccounts("60..99", false);
- Assert.assertEquals(0, accounts.size());
-
- context.close();
- }
-}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -96,4 +96,6 @@
Account updateAccount(Account account) throws LimaException;
void removeAccount(Account account) throws LimaException;
+
+ List<Account> stringToListAccounts(String selectedAccounts) throws TopiaException;
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -26,17 +26,12 @@
package org.chorem.lima.entity;
import com.google.common.collect.Maps;
-import org.apache.commons.lang3.StringUtils;
import org.nuiton.topia.persistence.HqlAndParametersBuilder;
import org.nuiton.topia.persistence.TopiaException;
-import java.util.ArrayList;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
public class AccountTopiaDao extends AbstractAccountTopiaDao<Account> {
@@ -88,7 +83,7 @@
* @return account list
* @throws TopiaException
*/
- protected List<Account> findIntervalAccountByNumber(String accountNumberLow,
+ public List<Account> findIntervalAccountByNumber(String accountNumberLow,
String accountNumberHigh) throws TopiaException {
HqlAndParametersBuilder<Account> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(Account.PROPERTY_ACCOUNT_NUMBER, accountNumberLow);
@@ -112,80 +107,13 @@
return accounts;
}
- /**
- * @deprecated since 0.6, business method, need to be moved out of dao
- */
- @Deprecated
- public List<Account> stringToListAccounts(String selectedAccounts,
- Boolean leafAccountsMode) throws TopiaException {
- Set<Account> accounts = new HashSet<Account>();
- if (selectedAccounts != null) {
- //Remove Spaces
- String result = StringUtils.deleteWhitespace(selectedAccounts);
-
- Boolean first = true;
- StringTokenizer stStar = new StringTokenizer(result, "-");
- while (stStar.hasMoreTokens()) {
- String subString = stStar.nextToken();
-
- //Split comma
- StringTokenizer stComma = new StringTokenizer(subString, ",");
- while (stComma.hasMoreTokens()) {
- String s = stComma.nextToken();
- //if intervall account
- if (s.contains("..") && !s.endsWith("..")) {
- //Split ..
- String stringDoubleDot[] = s.split("\\.\\.");
-
- List<Account> resultIntervall =
- findIntervalAccountByNumber(stringDoubleDot[0], stringDoubleDot[1]);
-
- //if first add accounts, else remove
- if (first) {
- accounts.addAll(resultIntervall);
- } else {
- accounts.removeAll(resultIntervall);
- }
- }
- //else one account
- else {
- Account account;
- if (leafAccountsMode) {
- account = findLeafAccountByNumber(s);
- } else {
- account = forAccountNumberEquals(s).findUniqueOrNull();
- }
- //if exist
- if (account != null) {
- //if first
- if (first) {
- accounts.add(account);
- } else {
- accounts.remove(account);
- }
- }
- //search all account start with accountnumber
- else {
- String query = "FROM " + Account.class.getName() + " a WHERE a NOT IN (" +
- "FROM " + Account.class.getName() + " b where b.accountNumber like a.accountNumber+'%')" +
- " AND a.accountNumber LIKE :s";
- Map<String, Object> args = Maps.newLinkedHashMap();
- args.put("s",s);
- List<Account> accountsResult = findAll(query, args);
- if (accountsResult != null) {
- //if first
- if (first) {
- accounts.addAll(accountsResult);
- } else {
- accounts.removeAll(accountsResult);
- }
- }
- }
- }
- }
- first = false;
- }
- }
- return new ArrayList(accounts);
+ public List<Account> findLeafAccounts(String accountNumber) throws TopiaException {
+ String query = "FROM " + Account.class.getName() + " a WHERE a NOT IN (" +
+ "FROM " + Account.class.getName() + " b WHERE b.accountNumber LIKE a.accountNumber+'%')" +
+ " AND a.accountNumber LIKE :accountNumber";
+ Map<String, Object> args = Maps.newLinkedHashMap();
+ args.put("accountNumber",accountNumber);
+ List<Account> accountsResult = findAll(query, args);
+ return accountsResult;
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -24,6 +24,7 @@
* #L%
*/
+import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
@@ -37,8 +38,6 @@
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
/**
@@ -91,7 +90,7 @@
public void setEntryBook(ListSelectionEvent event) {
JList entryBookList = view.getEntryBookList();
- List selectedValuesList = new ArrayList(Arrays.asList(entryBookList.getSelectedValues()));
+ List<EntryBook> selectedValuesList = Lists.newArrayList(entryBookList.getSelectedValuesList());
condition.setEntryBooks(selectedValuesList);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -24,6 +24,7 @@
* #L%
*/
+import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
@@ -38,8 +39,6 @@
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
/**
@@ -94,7 +93,7 @@
public void setFinancialPeriod(ListSelectionEvent event) {
JList financialPeriodList = view.getFinancialPeriodList();
- List selectedValuesList = new ArrayList(Arrays.asList(financialPeriodList.getSelectedValues()));
+ List<FinancialPeriod> selectedValuesList = Lists.newArrayList(financialPeriodList.getSelectedValuesList());
condition.setFinancialPeriods(selectedValuesList);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -24,6 +24,7 @@
* #L%
*/
+import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
@@ -37,8 +38,6 @@
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
@@ -92,7 +91,7 @@
public void setFiscalPeriod(ListSelectionEvent event) {
JList fiscalPeriodList = view.getFiscalPeriodList();
- List selectedValuesList = new ArrayList(Arrays.asList(fiscalPeriodList.getSelectedValues()));
+ List<FiscalPeriod> selectedValuesList = Lists.newArrayList(fiscalPeriodList.getSelectedValuesList());
condition.setFiscalPeriods(selectedValuesList);
}
Modified: trunk/lima-swing/src/test/java/org/chorem/lima/ui/account/AccountViewHandlerTest.java
===================================================================
--- trunk/lima-swing/src/test/java/org/chorem/lima/ui/account/AccountViewHandlerTest.java 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/lima-swing/src/test/java/org/chorem/lima/ui/account/AccountViewHandlerTest.java 2014-06-12 16:07:45 UTC (rev 3833)
@@ -29,12 +29,11 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
+import org.junit.Assert;
import org.junit.Test;
import com.google.common.collect.Lists;
-import junit.framework.Assert;
-
/**
* @author David Cossé
*/
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-06-12 09:02:50 UTC (rev 3832)
+++ trunk/pom.xml 2014-06-12 16:07:45 UTC (rev 3833)
@@ -183,7 +183,7 @@
<nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion>
<launch4jPluginVersion>1.5.0.0</launch4jPluginVersion>
- <jaxxVersion>2.8.7</jaxxVersion>
+ <jaxxVersion>2.8.8-SNAPSHOT</jaxxVersion>
<openEjbVersion>4.6.0.2</openEjbVersion>
<slf4jVersion>1.7.7</slf4jVersion>
<swingxVersion>1.6.5-1</swingxVersion>
1
0
r3832 - in trunk/lima-business/src: main/java/org/chorem/lima/business main/java/org/chorem/lima/business/ejb test/java/org/chorem/lima/business test/java/org/chorem/lima/business/accountingrules
by dcosse@users.chorem.org 12 Jun '14
by dcosse@users.chorem.org 12 Jun '14
12 Jun '14
Author: dcosse
Date: 2014-06-12 11:02:50 +0200 (Thu, 12 Jun 2014)
New Revision: 3832
Url: http://forge.chorem.org/projects/lima/repository/revisions/3832
Log:
#934 refactoring retrait d'acc?\195?\168s static ?\195?\160 des methodes dont la classe est un singleton
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/EntryBookServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialPeriodServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialTransactionServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FiscalPeriodServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ReportServiceRuleFrTest.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -101,7 +101,7 @@
*
* @return l'instance de rule
*/
- public static AccountingRules getAccountingRules() {
+ public AccountingRules getAccountingRules() {
if (accountingRules == null) {
Class<?> accountingRulesClass = config.getOptionAsClass(ServiceConfigOption.RULES_NATIONALTY.key);
@@ -125,48 +125,48 @@
return accountingRules;
}
- public static void setAccountingRule(String accountingRule) {
+ public void setAccountingRule(String accountingRule) {
accountingRules = null; // clear cache
config.setOption(ServiceConfigOption.RULES_NATIONALTY.key, accountingRule);
}
- public static File getDataDir() {
+ public File getDataDir() {
File datadir = config.getOptionAsFile(ServiceConfigOption.DATA_DIR.getKey());
return datadir;
}
- public static File getReportsDir() {
+ public File getReportsDir() {
File reportsDir = config.getOptionAsFile(ServiceConfigOption.REPORTS_DIR.getKey());
return reportsDir;
}
- public static String getAddressServer() {
+ public String getAddressServer() {
String serverAddress = config.getOption(ServiceConfigOption.SERVER_ADRESS.getKey());
return serverAddress;
}
- public static int getHttpPort() {
+ public int getHttpPort() {
String httpPort = config.getOption(ServiceConfigOption.HTTP_PORT.getKey());
Integer port = Integer.valueOf(httpPort);
return port;
}
- public static String getScale() {
+ public String getScale() {
String scale = config.getOption(ServiceConfigOption.SCALE.getKey());
return scale;
}
- public static void setScale(String locale) {
+ public void setScale(String locale) {
config.setOption(ServiceConfigOption.SCALE.key, locale);
config.saveForUser();
}
- public static String getVatPDFUrl() {
+ public String getVatPDFUrl() {
String vatPDFUrl = config.getOption(ServiceConfigOption.VAT_PDF_URL.getKey());
return vatPDFUrl;
}
- public static void setVatPDFUrl(String url) {
+ public void setVatPDFUrl(String url) {
config.setOption(ServiceConfigOption.VAT_PDF_URL.key, url);
config.saveForUser();
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -81,7 +81,7 @@
public Account createAccount(Account account) throws LimaException {
// check rules before create the account
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
accountingRules.createAccountRules(account);
Account result;
@@ -208,7 +208,7 @@
@Override
public void removeAccount(Account account) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
@@ -237,7 +237,7 @@
@Override
public Account updateAccount(Account account) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
Account result;
try {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -101,7 +101,7 @@
protected String path;
public DocumentServiceImpl() {
- path = LimaConfig.getReportsDir().getAbsolutePath();
+ path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
if (log.isDebugEnabled()) {
log.debug("Path : " + path);
@@ -722,7 +722,7 @@
String filePath = path + File.separator
+ DocumentsEnum.VAT.getFileName() + ".pdf";
- String path = LimaConfig.getReportsDir().getAbsolutePath();
+ String path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
String filePathDefault = path + File.separator
+ DocumentsEnum.VAT.getFileName() + "_default.pdf";
@@ -730,7 +730,7 @@
PDDocument doc;
InputStream reportsStream;
- String vatPDFUrl = LimaConfig.getVatPDFUrl();
+ String vatPDFUrl = LimaConfig.getInstance().getVatPDFUrl();
if (vatPDFUrl.equals("default")) {
reportsStream = DocumentServiceImpl.class
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -141,7 +141,7 @@
public void removeEntryBook(EntryBook entryBook) throws LimaException {
// check rule
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
accountingRules.removeEntryBookRules(entryBook);
try {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -122,7 +122,7 @@
@Override
public ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
ClosedPeriodicEntryBook result;
try {
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 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -101,7 +101,7 @@
public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction)
throws LimaException {
FinancialTransaction result;
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
//check if the financial period is blocked
@@ -476,7 +476,7 @@
@Override
public void updateFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
@@ -504,7 +504,7 @@
public void removeFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
// check if the financial period is blocked
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialTransaction);
try {
@@ -527,7 +527,7 @@
@Override
public Entry createEntry(Entry entry) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
Entry newEntry;
try {
@@ -550,7 +550,7 @@
@Override
public void updateEntry(Entry entry) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
@@ -576,7 +576,7 @@
@Override
public void removeEntry(Entry entry) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
FinancialTransaction financialTransaction = entry.getFinancialTransaction();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -111,7 +111,7 @@
ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
// fix begin date at midnight and end date at 23:59:59.999
Date beginDate = fiscalPeriod.getBeginDate();
@@ -237,7 +237,7 @@
@Override
public FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
FiscalPeriod result;
try {
@@ -500,7 +500,7 @@
public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod)
throws LimaException {
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
try {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -91,8 +91,8 @@
private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd");
public HttpServerServiceImpl() {
- path = LimaConfig.getReportsDir().getAbsolutePath();
- port = LimaConfig.getHttpPort();
+ path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
+ port = LimaConfig.getInstance().getHttpPort();
}
/** start the server */
@@ -131,7 +131,7 @@
public class MainServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
- private String serverAddressConfig = LimaConfig.getAddressServer();
+ private String serverAddressConfig = LimaConfig.getInstance().getAddressServer();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
@@ -270,7 +270,7 @@
+ ":" + req.getServerPort();
} else {
serverAdress += serverAddressConfig + ":"
- + LimaConfig.getHttpPort();
+ + LimaConfig.getInstance().getHttpPort();
}
Calendar calendar = Calendar.getInstance();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -730,7 +730,7 @@
PDDocument doc = null;
try {
- String path = LimaConfig.getReportsDir().getAbsolutePath();
+ String path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
String filePathDefault = path + File.separator
+ DocumentsEnum.VAT.getFileName() + "_default.pdf";
@@ -760,7 +760,7 @@
//sets the new pdf url to be used as pdf document edited for reports
if (setMode) {
- LimaConfig.setVatPDFUrl(datas);
+ LimaConfig.getInstance().setVatPDFUrl(datas);
}
} catch (IOException ex) {
log.error("Can't read vat pdf", ex);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -39,8 +39,8 @@
protected String vatPDFUrl;
public OptionsServiceImpl() {
- scale = LimaConfig.getScale();
- vatPDFUrl = LimaConfig.getVatPDFUrl();
+ scale = LimaConfig.getInstance().getScale();
+ vatPDFUrl = LimaConfig.getInstance().getVatPDFUrl();
}
public int getScale() {
@@ -52,7 +52,7 @@
}
public void setScale(String scale) {
- LimaConfig.setScale(scale);
+ LimaConfig.getInstance().setScale(scale);
}
public String getVatPDFUrl() {
@@ -60,7 +60,7 @@
}
public void setVatPDFUrl(String url) {
- LimaConfig.setVatPDFUrl(url);
+ LimaConfig.getInstance().setVatPDFUrl(url);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -72,7 +72,7 @@
VatStatement mastervatStatementUpdate = null;
if (masterVatStatement != null) {
- mastervatStatementUpdate = vatStatementTopiaDao.findByLabel(masterVatStatement.getLabel());
+ mastervatStatementUpdate = vatStatementTopiaDao.forLabelEquals(masterVatStatement.getLabel()).findUniqueOrNull();
}
// check if parent account exist;
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -44,7 +44,7 @@
*/
@Test
public void testDefaultRule() {
- Assert.assertFalse(LimaConfig.getAccountingRules()
+ Assert.assertFalse(LimaConfig.getInstance().getAccountingRules()
instanceof FranceAccountingRules);
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -51,7 +51,7 @@
@Before
public void installFrenchRule() throws Exception {
- LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -60,7 +60,7 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/EntryBookServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/EntryBookServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/EntryBookServiceRuleFrTest.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -47,7 +47,7 @@
@Before
public void installFrenchRule() throws Exception {
- LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -56,6 +56,6 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialPeriodServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialPeriodServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialPeriodServiceRuleFrTest.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -47,7 +47,7 @@
@Before
public void installFrenchRule() throws Exception {
- LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -56,6 +56,6 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialTransactionServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialTransactionServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialTransactionServiceRuleFrTest.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -47,7 +47,7 @@
@Before
public void installFrenchRule() throws Exception {
- LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -56,6 +56,6 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FiscalPeriodServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FiscalPeriodServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FiscalPeriodServiceRuleFrTest.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -47,7 +47,7 @@
@Before
public void installFrenchRule() throws Exception {
- LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -56,6 +56,6 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -59,7 +59,7 @@
*/
@Test
public void testRuleInstance() throws Exception {
- AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
Assert.assertTrue("accountingRules:" + accountingRules,accountingRules instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ReportServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ReportServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ReportServiceRuleFrTest.java 2014-06-12 09:02:50 UTC (rev 3832)
@@ -50,7 +50,7 @@
@BeforeClass
public static void installFrenchRule() throws Exception {
- LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -59,6 +59,6 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
}
}
1
0
12 Jun '14
Author: dcosse
Date: 2014-06-12 10:35:38 +0200 (Thu, 12 Jun 2014)
New Revision: 3831
Url: http://forge.chorem.org/projects/lima/repository/revisions/3831
Log:
#934 refactorin sur LimaConfig
Added:
trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java
trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/EntryBookServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialPeriodServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialTransactionServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FiscalPeriodServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ReportServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java
trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java
trunk/lima-business/src/test/resources/lima-test.properties
trunk/lima-business/src/test/resources/log4j.properties
trunk/pom.xml
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -27,7 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.accountingrules.DefaultAccountingRules;
import org.chorem.lima.business.accountingrules.FranceAccountingRules;
import org.chorem.lima.business.migration.DatabaseMigrationClass;
import org.chorem.lima.entity.LimaCallaoEntityEnum;
@@ -56,21 +55,31 @@
*/
public class LimaConfig extends ApplicationConfig {
- private static final Log log = LogFactory.getLog(LimaConfig.class);
+ protected static final Log log = LogFactory.getLog(LimaConfig.class);
protected static LimaConfig instance;
- protected AccountingRules accountingRules;
+ protected static AccountingRules accountingRules;
+ protected static ApplicationConfig config;
+
+ protected static final String LIMA_DEFAULT_CONF_FILENAME = "lima.properties";
+
public LimaConfig() {
- // load default options
- super(Option.class, null, null, null);
+ try {
+ setOption("topia.service.migration", TopiaMigrationEngine.class.getName());
+ setOption("topia.service.migration.callback", DatabaseMigrationClass.class.getName());
- setOption("topia.service.migration", TopiaMigrationEngine.class.getName());
- setOption("topia.service.migration.callback", DatabaseMigrationClass.class.getName());
+ setOption(TopiaMigrationService.MIGRATION_SHOW_SQL, Boolean.TRUE.toString());
+ setOption(TopiaMigrationService.MIGRATION_SHOW_PROGRESSION, Boolean.TRUE.toString());
- setOption(TopiaMigrationService.MIGRATION_SHOW_SQL, Boolean.TRUE.toString());
- setOption(TopiaMigrationService.MIGRATION_SHOW_PROGRESSION, Boolean.TRUE.toString());
+ config = new ApplicationConfig(LIMA_DEFAULT_CONF_FILENAME);
+ config.loadDefaultOptions(ServiceConfigOption.values());
+ config.parse();
+
+ } catch (ArgumentsParserException ex) {
+ throw new LimaException("Can't read configuration", ex);
+ }
}
public static LimaConfig getInstance() {
@@ -81,19 +90,26 @@
return instance;
}
+ public ApplicationConfig getConfig() {
+ return config;
+ }
+
/**
* Instancie la bonne classe de nationalite en fonction du fichier de configuration.
*
* L'instance est conservée en cache.
- *
+ *
* @return l'instance de rule
*/
- public AccountingRules getAccountingRules() {
+ public static AccountingRules getAccountingRules() {
if (accountingRules == null) {
- Class<?> accountingRulesClass = getOptionAsClass(Option.RULES_NATIONALTY.key);
+ Class<?> accountingRulesClass = config.getOptionAsClass(ServiceConfigOption.RULES_NATIONALTY.key);
if (accountingRulesClass == null) {
- accountingRules = new DefaultAccountingRules();
+ if (log.isErrorEnabled()) {
+ log.error("No accounting rules defined for:" + accountingRulesClass);
+ }
+ accountingRules = new FranceAccountingRules();
} else {
try {
accountingRules = (AccountingRules) accountingRulesClass.newInstance();
@@ -101,6 +117,7 @@
if (log.isErrorEnabled()) {
log.error("Can't instantiate accounting rules", ex);
}
+
}
}
}
@@ -108,50 +125,50 @@
return accountingRules;
}
- public void setAccountingRule(String accountingRule) {
+ public static void setAccountingRule(String accountingRule) {
accountingRules = null; // clear cache
- setOption(Option.RULES_NATIONALTY.key, accountingRule);
+ config.setOption(ServiceConfigOption.RULES_NATIONALTY.key, accountingRule);
}
- public File getDataDir() {
- File datadir = getOptionAsFile(Option.DATA_DIR.getKey());
+ public static File getDataDir() {
+ File datadir = config.getOptionAsFile(ServiceConfigOption.DATA_DIR.getKey());
return datadir;
}
- public File getReportsDir() {
- File reportsDir = getOptionAsFile(Option.REPORTS_DIR.getKey());
+ public static File getReportsDir() {
+ File reportsDir = config.getOptionAsFile(ServiceConfigOption.REPORTS_DIR.getKey());
return reportsDir;
}
- public String getAddressServer() {
- String serverAddress = getOption(Option.SERVER_ADRESS.getKey());
+ public static String getAddressServer() {
+ String serverAddress = config.getOption(ServiceConfigOption.SERVER_ADRESS.getKey());
return serverAddress;
}
- public int getHttpPort() {
- String httpPort = getOption(Option.HTTP_PORT.getKey());
+ public static int getHttpPort() {
+ String httpPort = config.getOption(ServiceConfigOption.HTTP_PORT.getKey());
Integer port = Integer.valueOf(httpPort);
return port;
}
- public String getScale() {
- String scale = getOption(Option.SCALE.getKey());
+ public static String getScale() {
+ String scale = config.getOption(ServiceConfigOption.SCALE.getKey());
return scale;
}
- public void setScale(String locale) {
- setOption(Option.SCALE.key, locale);
- saveForUser();
+ public static void setScale(String locale) {
+ config.setOption(ServiceConfigOption.SCALE.key, locale);
+ config.saveForUser();
}
- public String getVatPDFUrl() {
- String vatPDFUrl = getOption(Option.VAT_PDF_URL.getKey());
+ public static String getVatPDFUrl() {
+ String vatPDFUrl = config.getOption(ServiceConfigOption.VAT_PDF_URL.getKey());
return vatPDFUrl;
}
- public void setVatPDFUrl(String url) {
- setOption(Option.VAT_PDF_URL.key, url);
- saveForUser();
+ public static void setVatPDFUrl(String url) {
+ config.setOption(ServiceConfigOption.VAT_PDF_URL.key, url);
+ config.saveForUser();
}
/**
@@ -159,14 +176,14 @@
*/
protected void loadConfiguration() {
try {
- instance.parse();
+ config.parse();
} catch (ArgumentsParserException ex) {
if (log.isErrorEnabled()) {
log.error("Can't read configuration", ex);
}
}
- instance.setOption(TopiaConfigurationConstants.CONFIG_PERSISTENCE_CLASSES,
+ config.setOption(TopiaConfigurationConstants.CONFIG_PERSISTENCE_CLASSES,
LimaCallaoEntityEnum.getImplementationClassesAsString());
}
@@ -177,9 +194,9 @@
* information for jaxx configuration frame ({@code #type},
* {@code #transientBoolean}, {@code #finalBoolean}...)
*/
- public enum Option implements ConfigOptionDef {
+ public enum ServiceConfigOption implements ConfigOptionDef {
- CONFIG_FILE(CONFIG_FILE_NAME, n("lima.config.configFileName.description"), "lima.properties", String.class, true, true),
+ CONFIG_FILE(CONFIG_FILE_NAME, n("lima.configFileName.description"), "lima.properties", String.class, true, true),
DATA_DIR("lima.data.dir", n("lima.config.data.dir.description"), "${user.home}/.lima", File.class, false, false),
REPORTS_DIR("lima.reports.dir", n("lima.config.reports.dir.description"), "${lima.data.dir}/reports", File.class, false, false),
RULES_NATIONALTY("lima.rules", n("lima.config.rulesnationality.description"), FranceAccountingRules.class.getName(), String.class, false, false),
@@ -200,8 +217,8 @@
private boolean finalBoolean;
- Option(String key, String description, String defaultValue,
- Class<?> type, boolean transientBoolean, boolean finalBoolean) {
+ ServiceConfigOption(String key, String description, String defaultValue,
+ Class<?> type, boolean transientBoolean, boolean finalBoolean) {
this.key = key;
this.description = description;
this.defaultValue = defaultValue;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -39,6 +39,7 @@
import org.chorem.lima.entity.LimaCallaoTopiaApplicationContext;
import org.chorem.lima.entity.LimaCallaoTopiaDaoSupplier;
import org.chorem.lima.entity.LimaCallaoTopiaPersistenceContext;
+import org.nuiton.config.ApplicationConfig;
import org.nuiton.topia.persistence.TopiaApplicationContextCache;
import com.google.common.base.Function;
@@ -93,8 +94,9 @@
context.getTarget().getClass() + "#" + context.getMethod().getName());
}
- LimaConfig config = LimaConfig.getInstance();
+ ApplicationConfig config = LimaConfig.getInstance().getConfig();
+
LimaCallaoTopiaApplicationContext rootContext = TopiaApplicationContextCache.getContext(config.getFlatOptions(), CREATE_CONTEXT_FUNCTION);
LimaCallaoTopiaPersistenceContext tx = rootContext.newPersistenceContext();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -81,7 +81,7 @@
public Account createAccount(Account account) throws LimaException {
// check rules before create the account
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
accountingRules.createAccountRules(account);
Account result;
@@ -208,7 +208,7 @@
@Override
public void removeAccount(Account account) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
try {
@@ -237,7 +237,7 @@
@Override
public Account updateAccount(Account account) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
Account result;
try {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -101,7 +101,7 @@
protected String path;
public DocumentServiceImpl() {
- path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
+ path = LimaConfig.getReportsDir().getAbsolutePath();
if (log.isDebugEnabled()) {
log.debug("Path : " + path);
@@ -722,7 +722,7 @@
String filePath = path + File.separator
+ DocumentsEnum.VAT.getFileName() + ".pdf";
- String path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
+ String path = LimaConfig.getReportsDir().getAbsolutePath();
String filePathDefault = path + File.separator
+ DocumentsEnum.VAT.getFileName() + "_default.pdf";
@@ -730,7 +730,7 @@
PDDocument doc;
InputStream reportsStream;
- String vatPDFUrl = LimaConfig.getInstance().getVatPDFUrl();
+ String vatPDFUrl = LimaConfig.getVatPDFUrl();
if (vatPDFUrl.equals("default")) {
reportsStream = DocumentServiceImpl.class
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -141,7 +141,7 @@
public void removeEntryBook(EntryBook entryBook) throws LimaException {
// check rule
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
accountingRules.removeEntryBookRules(entryBook);
try {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -122,7 +122,7 @@
@Override
public ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
ClosedPeriodicEntryBook result;
try {
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 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -101,7 +101,7 @@
public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction)
throws LimaException {
FinancialTransaction result;
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
try {
//check if the financial period is blocked
@@ -476,7 +476,7 @@
@Override
public void updateFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
try {
@@ -504,7 +504,7 @@
public void removeFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
// check if the financial period is blocked
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialTransaction);
try {
@@ -527,7 +527,7 @@
@Override
public Entry createEntry(Entry entry) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
Entry newEntry;
try {
@@ -550,7 +550,7 @@
@Override
public void updateEntry(Entry entry) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
try {
EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
@@ -576,7 +576,7 @@
@Override
public void removeEntry(Entry entry) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
try {
FinancialTransaction financialTransaction = entry.getFinancialTransaction();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -111,7 +111,7 @@
ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
// fix begin date at midnight and end date at 23:59:59.999
Date beginDate = fiscalPeriod.getBeginDate();
@@ -237,7 +237,7 @@
@Override
public FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
FiscalPeriod result;
try {
@@ -500,7 +500,7 @@
public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod)
throws LimaException {
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
try {
try {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -91,8 +91,8 @@
private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd");
public HttpServerServiceImpl() {
- path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
- port = LimaConfig.getInstance().getHttpPort();
+ path = LimaConfig.getReportsDir().getAbsolutePath();
+ port = LimaConfig.getHttpPort();
}
/** start the server */
@@ -131,7 +131,7 @@
public class MainServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
- private String serverAddressConfig = LimaConfig.getInstance().getAddressServer();
+ private String serverAddressConfig = LimaConfig.getAddressServer();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
@@ -270,7 +270,7 @@
+ ":" + req.getServerPort();
} else {
serverAdress += serverAddressConfig + ":"
- + LimaConfig.getInstance().getHttpPort();
+ + LimaConfig.getHttpPort();
}
Calendar calendar = Calendar.getInstance();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -730,7 +730,7 @@
PDDocument doc = null;
try {
- String path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
+ String path = LimaConfig.getReportsDir().getAbsolutePath();
String filePathDefault = path + File.separator
+ DocumentsEnum.VAT.getFileName() + "_default.pdf";
@@ -760,7 +760,7 @@
//sets the new pdf url to be used as pdf document edited for reports
if (setMode) {
- LimaConfig.getInstance().setVatPDFUrl(datas);
+ LimaConfig.setVatPDFUrl(datas);
}
} catch (IOException ex) {
log.error("Can't read vat pdf", ex);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -39,8 +39,8 @@
protected String vatPDFUrl;
public OptionsServiceImpl() {
- scale = LimaConfig.getInstance().getScale();
- vatPDFUrl = LimaConfig.getInstance().getVatPDFUrl();
+ scale = LimaConfig.getScale();
+ vatPDFUrl = LimaConfig.getVatPDFUrl();
}
public int getScale() {
@@ -52,7 +52,7 @@
}
public void setScale(String scale) {
- LimaConfig.getInstance().setScale(scale);
+ LimaConfig.setScale(scale);
}
public String getVatPDFUrl() {
@@ -60,7 +60,7 @@
}
public void setVatPDFUrl(String url) {
- LimaConfig.getInstance().setVatPDFUrl(url);
+ LimaConfig.setVatPDFUrl(url);
}
}
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2014-06-12 08:35:38 UTC (rev 3831)
@@ -116,6 +116,7 @@
lima.config.rulesnationality.description=Rules Nationality
lima.config.scale.description=Scale
lima.config.serveraddress.description=Server Address
+lima.configFileName.description=
lima.reports.account.noaccount=
lima.reports.account.noaccounttitle=
lima.reports.accounts=
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2014-06-12 08:35:38 UTC (rev 3831)
@@ -117,6 +117,7 @@
lima.config.rulesnationality.description=Règles nationales
lima.config.scale.description=Précision
lima.config.serveraddress.description=Addresse serveur
+lima.configFileName.description=
lima.reports.account.noaccount=
lima.reports.account.noaccounttitle=
lima.reports.accounts=
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -23,22 +23,10 @@
package org.chorem.lima.business;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.Locale;
-import java.util.Properties;
-import java.util.UUID;
-
+import com.google.common.base.Function;
import com.google.common.collect.Lists;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaConfig.Option;
import org.chorem.lima.business.accountingrules.TestAccountingRules;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
@@ -63,13 +51,20 @@
import org.chorem.lima.entity.LimaCallaoEntityEnum;
import org.chorem.lima.entity.LimaCallaoTopiaApplicationContext;
import org.chorem.lima.service.LimaServiceFactory;
+import org.hibernate.cfg.Environment;
import org.junit.After;
import org.junit.Before;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.ClassPathI18nInitializer;
import org.nuiton.topia.persistence.TopiaApplicationContextCache;
-import com.google.common.base.Function;
+import java.io.File;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.UUID;
/**
* Common initialization code for all lima tests.
@@ -103,18 +98,22 @@
protected NewImportService newImportService;
protected NewExportService newExportService;
+ protected LimaCallaoTopiaApplicationContext context;
+
/**
* This is a before class method, but junit will fail to run inherited
* BeforeClass methods if there is one.
- *
+ *
* @throws Exception
*/
@Before
public void initAbstractTest() throws Exception {
setUpLocale();
- setUpTestConfig();
- setUpDefaultRule();
- initServices();
+
+ Properties options = getTestConfiguration();
+ LimaConfig config = new LimaTestsConfig("/lima-test.properties", options);
+ initServices(config);
+ context = getTestContext(options);
}
protected void setUpLocale() throws Exception {
@@ -123,10 +122,11 @@
/**
* Init services after i18n#init().
- * @throws IOException
+ * @throws java.io.IOException
*/
- protected void initServices() throws IOException {
+ protected void initServices(LimaConfig config) throws IOException {
if(accountService == null) {
+ LimaServiceFactory.initFactory(config.getConfig());
accountService = LimaServiceFactory.getService(AccountService.class);
entryBookService = LimaServiceFactory.getService(EntryBookService.class);
financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
@@ -144,107 +144,76 @@
/**
* Return a new instance of configuration defined on a new database at
* each call.
- *
+ *
* @return single test config
*/
- protected LimaConfig getTestConfiguration() {
- LimaConfig instance = new LimaConfig();
+ protected Properties getTestConfiguration() {
// do not call parse() method (don't read /etc...)
// load file manually (lima.properties)
Properties testProperties = new Properties();
- InputStream streamMain = null;
- InputStream streamTest = null;
-
- try {
- streamMain = AbstractLimaTest.class.getResourceAsStream("/" + Option.CONFIG_FILE.getDefaultValue());
- testProperties.load(streamMain);
- streamMain.close();
-
- streamTest = AbstractLimaTest.class.getResourceAsStream("/lima-test.properties");
- testProperties.load(streamTest);
- streamTest.close();
- } catch (IOException ex) {
- throw new RuntimeException("Can't init test configuration", ex);
- } finally {
- IOUtils.closeQuietly(streamMain);
- IOUtils.closeQuietly(streamTest);
- }
-
// override somes
+ testProperties.setProperty(LimaConfig.ServiceConfigOption.CONFIG_FILE.getKey(), "/lima-test.properties");
String testDir = System.getProperty("java.io.tmpdir") + File.separator + "lima-business-" + UUID.randomUUID().toString();
- testProperties.setProperty(Option.DATA_DIR.getKey(), testDir);
- testProperties.setProperty("hibernate.connection.url", "jdbc:h2:file:" + testDir + File.separator + "data");
- testProperties.setProperty("hibernate.hbm2ddl.auto", "update");
+ testProperties.setProperty(LimaConfig.ServiceConfigOption.DATA_DIR.getKey(), testDir);
+ testProperties.setProperty(Environment.HBM2DDL_AUTO, "update");
+ testProperties.setProperty(Environment.DIALECT, "org.hibernate.dialect.H2Dialect");
+ testProperties.setProperty(Environment.DRIVER, "org.h2.Driver");
- instance.setOptions(testProperties);
- instance.setOption("topia.persistence.classes", LimaCallaoEntityEnum.getImplementationClassesAsString());
+ testProperties.setProperty(Environment.URL, "jdbc:h2:file:" + testDir + File.separator + "data");
+ testProperties.setProperty(Environment.USER, "sa");
+ testProperties.setProperty(Environment.PASS, "");
+ testProperties.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
- if (log.isDebugEnabled()) {
- log.debug("Using test configuration" + instance.getFlatOptions());
- }
- return instance;
- }
- protected void setUpTestConfig() throws Exception {
- LimaConfig.instance = getTestConfiguration();
- LimaServiceFactory.initFactory(LimaConfig.getInstance());
+ testProperties.setProperty("topia.persistence.classes", LimaCallaoEntityEnum.getImplementationClassesAsString());
+ testProperties.setProperty(LimaConfig.ServiceConfigOption.RULES_NATIONALTY.getKey(), TestAccountingRules.class.getName());
+ return testProperties;
}
@After
public void cleanDatabase() throws Exception {
- LimaConfig config = LimaConfig.getInstance();
- FileUtils.deleteDirectory(config.getDataDir());
+ //context.dropSchema();
}
/**
- * Default rule configuration should stay in France rule.
- *
- * But test will run without a specific rule during normal tests
- * and france rule will be re-enabled for specifics tests.
- * @throws Exception
- */
- protected static void setUpDefaultRule() throws Exception {
- LimaConfig config = LimaConfig.getInstance();
- config.setAccountingRule(TestAccountingRules.class.getName());
- }
-
- /**
* Method to use only for class that need a context to be tester.
* Only for DOA for now.
*
* @return a topia context
*/
- protected LimaCallaoTopiaApplicationContext getTestContext() {
- LimaConfig config = LimaConfig.getInstance();
- Properties options = config.getFlatOptions();
+ protected LimaCallaoTopiaApplicationContext getTestContext(Properties options) {
+ log.info("Opening context to database : " + options.getProperty("hibernate.connection.url"));
- if (log.isDebugEnabled()) {
- log.debug("Opening context to database : " + options.getProperty("hibernate.connection.url"));
- }
LimaCallaoTopiaApplicationContext result = TopiaApplicationContextCache.getContext(options, CREATE_CONTEXT_FUNCTION);
return result;
}
+ protected LimaCallaoTopiaApplicationContext createNewTestContext() {
+ Properties options = getTestConfiguration();
+ LimaCallaoTopiaApplicationContext result = getTestContext(options);
+ return result;
+ }
+
/**
* Create a basic database.
- *
+ *
* Not called by default (<code>@Before</code>) to allow init test with
* CSV or EBP import.
- *
- * @throws LimaException
- * @throws ParseException
+ *
+ * @throws org.chorem.lima.business.LimaException
+ * @throws java.text.ParseException
*/
protected void initTestDatabase() throws Exception {
- getTestContext().createSchema();
+ context.createSchema();
}
/**
* Create a basic account plan.
*
- * @throws org.chorem.lima.business.LimaException
+ * @throws LimaException
* @throws java.text.ParseException
*/
protected void initTestWithAccounts() throws Exception {
@@ -289,8 +258,8 @@
/**
* Create some EntryBooks.
*
- * @throws LimaException
- * @throws ParseException
+ * @throws org.chorem.lima.business.LimaException
+ * @throws java.text.ParseException
*/
protected void initTestWithEntryBooks() throws Exception {
// creation d'un journal
@@ -314,8 +283,8 @@
/**
* Create a FiscalPeriod with an EntryBook.
*
- * @throws LimaException
- * @throws ParseException
+ * @throws org.chorem.lima.business.LimaException
+ * @throws java.text.ParseException
*/
protected void initTestWithFiscalPeriod() throws Exception {
initTestWithAccounts();
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -109,7 +109,7 @@
public void deleteNonUsedEntryBookTest() throws LimaException {
EntryBook myEntryBook = new EntryBookImpl();
- myEntryBook.setCode("JRN");
+ myEntryBook.setCode("JRN2");
myEntryBook.setLabel("MyJournal");
myEntryBook = entryBookService.createEntryBook(myEntryBook);
int nbEntryBooks = entryBookService.getAllEntryBooks().size();
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -62,20 +62,20 @@
initTestWithFinancialTransaction();
// find one closed to close
- LimaCallaoTopiaPersistenceContext context = getTestContext().newPersistenceContext();
- ClosedPeriodicEntryBookTopiaDao dao = context.getClosedPeriodicEntryBookDao();
+ LimaCallaoTopiaPersistenceContext tcontext = context.newPersistenceContext();
+ ClosedPeriodicEntryBookTopiaDao dao = tcontext.getClosedPeriodicEntryBookDao();
ClosedPeriodicEntryBook closedPeriodic = dao.findAll().get(0);
- context.close();
+ tcontext.close();
// block it
Assert.assertFalse(closedPeriodic.isLocked());
financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodic);
// check it's blocked
- context = getTestContext().newPersistenceContext();
- dao = context.getClosedPeriodicEntryBookDao();
+ tcontext = context.newPersistenceContext();
+ dao = tcontext.getClosedPeriodicEntryBookDao();
closedPeriodic = dao.findAll().get(0);
- context.close();
+ tcontext.close();
Assert.assertFalse(closedPeriodic.isLocked());
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -140,7 +140,7 @@
*/
@Test
public void testImportCSVPCG() throws Exception {
- getTestContext().createSchema();
+ createNewTestContext().createSchema();
String pcg = IOUtils.toString(ImportServiceImplTest.class.getResourceAsStream("/import/pcg_base.csv"));
importService.importAsCSV(pcg, ImportExportEntityEnum.ACCOUNT);
@@ -153,7 +153,7 @@
*/
@Test
public void testImportCSVEb() throws Exception {
- getTestContext().createSchema();
+ createNewTestContext().createSchema();
String pcg = IOUtils.toString(ImportServiceImplTest.class.getResourceAsStream("/import/eb_default.csv"));
importService.importAsCSV(pcg, ImportExportEntityEnum.ENTRYBOOK);
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -44,7 +44,7 @@
*/
@Test
public void testDefaultRule() {
- Assert.assertFalse(LimaConfig.getInstance().getAccountingRules()
+ Assert.assertFalse(LimaConfig.getAccountingRules()
instanceof FranceAccountingRules);
}
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -0,0 +1,36 @@
+package org.chorem.lima.business;
+
+import org.apache.commons.lang3.StringUtils;
+import org.nuiton.config.ApplicationConfig;
+import org.nuiton.config.ArgumentsParserException;
+
+import java.util.Properties;
+
+/**
+ * Created by davidcosse on 11/06/14.
+ */
+public class LimaTestsConfig extends LimaConfig {
+
+ public LimaTestsConfig(String configFileName, Properties properties) {
+ try {
+ accountingRules = null;
+ ApplicationConfig defaultConfig = new ApplicationConfig(LIMA_DEFAULT_CONF_FILENAME);
+ defaultConfig.loadDefaultOptions(ServiceConfigOption.values());
+ defaultConfig.parse();
+ if (StringUtils.isNotBlank(configFileName)) {
+ Properties flatOptions = defaultConfig.getFlatOptions(false);
+ flatOptions.putAll(properties);
+ config = new ApplicationConfig(flatOptions, configFileName);
+ config.parse();
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("No specific configuration provided, using the default one");
+ }
+ config = defaultConfig;
+ }
+ instance = this;
+ } catch (ArgumentsParserException ex) {
+ throw new LimaException("Can't read configuration", ex);
+ }
+ }
+}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -51,7 +51,7 @@
@Before
public void installFrenchRule() throws Exception {
- LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -60,7 +60,7 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/EntryBookServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/EntryBookServiceRuleFrTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/EntryBookServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -47,7 +47,7 @@
@Before
public void installFrenchRule() throws Exception {
- LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -56,6 +56,6 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialPeriodServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialPeriodServiceRuleFrTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialPeriodServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -47,7 +47,7 @@
@Before
public void installFrenchRule() throws Exception {
- LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -56,6 +56,6 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialTransactionServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialTransactionServiceRuleFrTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FinancialTransactionServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -47,7 +47,7 @@
@Before
public void installFrenchRule() throws Exception {
- LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -56,6 +56,6 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FiscalPeriodServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FiscalPeriodServiceRuleFrTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/FiscalPeriodServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -47,7 +47,7 @@
@Before
public void installFrenchRule() throws Exception {
- LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -56,6 +56,6 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -23,13 +23,14 @@
package org.chorem.lima.business.accountingrules;
+import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.ImportServiceImplTest;
import org.chorem.lima.business.LimaConfig;
import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
+import java.util.Properties;
+
/**
* Add configuration to add specific test on French rules set.
*
@@ -45,9 +46,11 @@
*/
public class ImportServiceRuleFrTest extends ImportServiceImplTest {
- @Before
- public void installFrenchRule() throws Exception {
- LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
+ protected Properties getTestConfiguration() {
+ Properties config = super.getTestConfiguration();
+ config.remove(LimaConfig.ServiceConfigOption.RULES_NATIONALTY.getKey());
+ config.put(LimaConfig.ServiceConfigOption.RULES_NATIONALTY.getKey(), FranceAccountingRules.class.getName());
+ return config;
}
/**
@@ -55,7 +58,8 @@
* elle peut être mise en cache dans {@link LimaConfig}.
*/
@Test
- public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
+ public void testRuleInstance() throws Exception {
+ AccountingRules accountingRules = LimaConfig.getAccountingRules();
+ Assert.assertTrue("accountingRules:" + accountingRules,accountingRules instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ReportServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ReportServiceRuleFrTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ReportServiceRuleFrTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -50,7 +50,7 @@
@BeforeClass
public static void installFrenchRule() throws Exception {
- LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName());
+ LimaConfig.setAccountingRule(FranceAccountingRules.class.getName());
}
/**
@@ -59,6 +59,6 @@
*/
@Test
public void testRuleInstance() {
- Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
+ Assert.assertTrue(LimaConfig.getAccountingRules() instanceof FranceAccountingRules);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -53,11 +53,9 @@
*/
@Test
public void testStringToListAccounts() throws Exception {
- LimaCallaoTopiaPersistenceContext context = getTestContext().newPersistenceContext();
-
initTestWithAccounts();
- AccountTopiaDao accountDAO = context.getAccountDao();
+ AccountTopiaDao accountDAO = context.newPersistenceContext().getAccountDao();
List<Account> accounts = accountDAO.stringToListAccounts("50..511", false);
Assert.assertEquals(5, accounts.size());
Modified: trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java 2014-06-12 08:35:38 UTC (rev 3831)
@@ -60,8 +60,8 @@
FinancialPeriod financialPeriod = financialPeriodService.getAllFinancialPeriods().get(0);
EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv");
- LimaCallaoTopiaPersistenceContext context = getTestContext().newPersistenceContext();
- FinancialTransactionTopiaDao ftDAO = context.getFinancialTransactionDao();
+ LimaCallaoTopiaPersistenceContext tcontext = context.newPersistenceContext();
+ FinancialTransactionTopiaDao ftDAO = tcontext.getFinancialTransactionDao();
Assert.assertFalse(ftDAO.isExistUnbalancedTransaction(
financialPeriod.getBeginDate(),
financialPeriod.getEndDate(),
Modified: trunk/lima-business/src/test/resources/lima-test.properties
===================================================================
--- trunk/lima-business/src/test/resources/lima-test.properties 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/resources/lima-test.properties 2014-06-12 08:35:38 UTC (rev 3831)
@@ -26,3 +26,8 @@
# Embedded mode
lima.openejb.remotemode=false
java.naming.factory.initial=org.openejb.client.LocalInitialContextFactory
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.username=sa
+hibernate.connection.password=
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.hbm2ddl.auto=update
Modified: trunk/lima-business/src/test/resources/log4j.properties
===================================================================
--- trunk/lima-business/src/test/resources/log4j.properties 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/lima-business/src/test/resources/log4j.properties 2014-06-12 08:35:38 UTC (rev 3831)
@@ -31,6 +31,6 @@
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
# package level
-log4j.logger.org.chorem.lima=INFO
+log4j.logger.org.chorem.lima=DEBUG
log4j.logger.org.chorem.lima.business.ejb.FinancialTransactionServiceImpl=DEBUG
\ No newline at end of file
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-06-11 09:16:17 UTC (rev 3830)
+++ trunk/pom.xml 2014-06-12 08:35:38 UTC (rev 3831)
@@ -170,7 +170,7 @@
<nuitonCsvVersion>3.0-rc-1</nuitonCsvVersion>
<eugeneVersion>2.10</eugeneVersion>
<nuitonI18nVersion>3.1</nuitonI18nVersion>
- <topiaVersion>3.0-SNAPSHOT</topiaVersion>
+ <topiaVersion>3.0-beta-5</topiaVersion>
<swinglabsVersion>3.0.4</swinglabsVersion>
<h2Version>1.3.176</h2Version>
1
0
r3830 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business lima-business-api/src/main/java/org/chorem/lima/business/api lima-swing lima-swing/src/main/java/org/chorem/lima/ui/importexport
by dcosse@users.chorem.org 11 Jun '14
by dcosse@users.chorem.org 11 Jun '14
11 Jun '14
Author: dcosse
Date: 2014-06-11 11:16:17 +0200 (Wed, 11 Jun 2014)
New Revision: 3830
Url: http://forge.chorem.org/projects/lima/repository/revisions/3830
Log:
#1032 creation du zip cot?\195?\169 swing
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java
trunk/lima-swing/pom.xml
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-11 08:16:27 UTC (rev 3829)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-11 09:16:17 UTC (rev 3830)
@@ -91,7 +91,7 @@
private FinancialTransactionService financialTransactionService;
@Override
- public String exportAllAsCSV(String path, String charset) throws LimaException {
+ public String exportAllAsCSV(String charset) throws LimaException {
ByteArrayOutputStream rstBao = new ByteArrayOutputStream();
ZipOutputStream export = null;
try {
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java 2014-06-11 08:16:27 UTC (rev 3829)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java 2014-06-11 09:16:17 UTC (rev 3830)
@@ -1,6 +1,7 @@
package org.chorem.lima.business;
import com.google.common.collect.Lists;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
@@ -10,11 +11,16 @@
import org.junit.Assert;
import org.junit.Test;
+import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.List;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
/**
* Created by davidcosse on 03/06/14.
@@ -209,11 +215,18 @@
@Test
public void exportAllAsCSVTest() throws Exception {
initTestWithFinancialTransaction();
- String tmpDir = System.getProperty("java.io.tmpdir")+"/";
- String export = newExportService.exportAllAsCSV(tmpDir, "UTF-8");
+ String export = newExportService.exportAllAsCSV("UTF-8");
initAbstractTest();
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/TMP_BACKUP.zip";
+ createZipFile(tmpDir, export);
newImportService.importAllAsCSV(export);
}
+ protected void createZipFile(String path, String zippedBase64Str) throws Exception {
+ byte[] bytes = Base64.decodeBase64(zippedBase64Str);
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
+ IOUtils.copy(inputStream, new FileOutputStream(path));
+ }
+
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java 2014-06-11 08:16:27 UTC (rev 3829)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java 2014-06-11 09:16:17 UTC (rev 3830)
@@ -42,7 +42,7 @@
*/
public interface NewExportService {
- String exportAllAsCSV(String path, String charset) throws LimaException;
+ String exportAllAsCSV(String charset) throws LimaException;
String exportAccountsStream(String charset) throws LimaException;
Modified: trunk/lima-swing/pom.xml
===================================================================
--- trunk/lima-swing/pom.xml 2014-06-11 08:16:27 UTC (rev 3829)
+++ trunk/lima-swing/pom.xml 2014-06-11 09:16:17 UTC (rev 3830)
@@ -169,6 +169,11 @@
<artifactId>commons-lang</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+
</dependencies>
<build>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-06-11 08:16:27 UTC (rev 3829)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-06-11 09:16:17 UTC (rev 3830)
@@ -31,16 +31,15 @@
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
-import java.io.BufferedReader;
import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
-import java.io.StringWriter;
import java.nio.charset.Charset;
import java.util.concurrent.ExecutionException;
@@ -53,10 +52,12 @@
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.ExportService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.business.api.NewExportService;
@@ -135,7 +136,8 @@
String result = "";
switch (importExportMethodeF) {
case CSV_ALL_EXPORT:
- newExportService.exportAllAsCSV(filePath, charset.name());
+ datas = newExportService.exportAllAsCSV(charset.name());
+ createZipFile(filePath, datas);
break;
case CSV_ACCOUNTCHARTS_EXPORT:
datas = exportService.exportAccountsChartAsCSV();
@@ -389,4 +391,14 @@
return result;
}
+
+ protected void createZipFile(String path, String zippedBase64Str) throws LimaException {
+ try {
+ byte[] bytes = Base64.decodeBase64(zippedBase64Str);
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
+ IOUtils.copy(inputStream, new FileOutputStream(path));
+ } catch (IOException e) {
+ throw new LimaException("could not zip file", e);
+ }
+ }
}
1
0
r3829 - in trunk: . lima-business lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business lima-business-api/src/main/java/org/chorem/lima/business/api
by dcosse@users.chorem.org 11 Jun '14
by dcosse@users.chorem.org 11 Jun '14
11 Jun '14
Author: dcosse
Date: 2014-06-11 10:16:27 +0200 (Wed, 11 Jun 2014)
New Revision: 3829
Url: http://forge.chorem.org/projects/lima/repository/revisions/3829
Log:
#1032 utilisation de Base64 pour envoie du zip du server vers swing
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java
trunk/lima-business/pom.xml
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java
trunk/pom.xml
Modified: trunk/lima-business/pom.xml
===================================================================
--- trunk/lima-business/pom.xml 2014-06-10 16:17:01 UTC (rev 3828)
+++ trunk/lima-business/pom.xml 2014-06-11 08:16:27 UTC (rev 3829)
@@ -122,6 +122,10 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
</dependencies>
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-10 16:17:01 UTC (rev 3828)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-11 08:16:27 UTC (rev 3829)
@@ -49,18 +49,17 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
import org.nuiton.csv.Export;
+import org.apache.commons.codec.binary.Base64;
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.nio.charset.Charset;
-import java.text.SimpleDateFormat;
-import java.util.Date;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -93,8 +92,8 @@
@Override
public String exportAllAsCSV(String path, String charset) throws LimaException {
+ ByteArrayOutputStream rstBao = new ByteArrayOutputStream();
ZipOutputStream export = null;
- String filePath;
try {
List<File> files = Lists.newArrayList();
files.add(exportAccountsFile(charset));
@@ -103,12 +102,8 @@
files.add(exportFinancialTransactionsFile(charset));
files.add(exportEntriesFile(charset));
- SimpleDateFormat exportDate = new SimpleDateFormat(DATE_PATTERN);
- filePath = path + "LIMA-BACKUP-"+ exportDate.format(new Date()) +".zip";
+ export = new ZipOutputStream(rstBao);
- FileOutputStream out = new FileOutputStream(filePath);
- export = new ZipOutputStream(out);
-
for (File file : files) {
ZipEntry ze= new ZipEntry(file.getName());
export.putNextEntry(ze);
@@ -121,14 +116,15 @@
stream.close();
FileUtils.forceDelete(file);
}
+ export.flush();
} catch (Exception e) {
throw new LimaException("Can't export All",e);
} finally {
IOUtils.closeQuietly(export);
}
-
- return filePath;
+ byte[] bytes = rstBao.toByteArray();
+ return Base64.encodeBase64String(bytes);
}
protected File exportAccountsFile(String charset) throws Exception {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-06-10 16:17:01 UTC (rev 3828)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-06-11 08:16:27 UTC (rev 3829)
@@ -4,6 +4,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
@@ -32,6 +33,7 @@
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
+import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
@@ -40,8 +42,6 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import static org.nuiton.i18n.I18n.t;
-
/**
* Created by davidcosse on 03/06/14.
*/
@@ -165,14 +165,14 @@
}
@Override
- public void importAllAsCSV(String path) throws LimaException {
- FileInputStream contentStream;
+ public void importAllAsCSV(String zippedBase64Str) throws LimaException {
ZipInputStream zipInputStream = null;
InputStream transactionsStream = null, entryBooksStream = null, fiscalPeriodsStream = null, entriesStream = null, accountsStream = null;
try {
- contentStream = new FileInputStream(path);
- zipInputStream = new ZipInputStream(contentStream);
+ //contentStream = new FileInputStream(path);
+ byte[] bytes = Base64.decodeBase64(zippedBase64Str);
+ zipInputStream = new ZipInputStream(new ByteArrayInputStream(bytes));
// unzip
ZipEntry entry;
@@ -204,15 +204,15 @@
zipInputStream.closeEntry();
}
+ entryBooksStream = new FileInputStream(tmpDir + "entryBooks.csv");
+ String entryBooksStreamString = IOUtils.toString(entryBooksStream);
+ importEntryBooksAsCSV(entryBooksStreamString);
+
// import
transactionsStream = new FileInputStream(tmpDir + "financialTransactions.csv");
String transactionsStreamString = IOUtils.toString(transactionsStream);
importFinancialTransactionsAsCSV(transactionsStreamString);
- entryBooksStream = new FileInputStream(tmpDir + "entryBooks.csv");
- String entryBooksStreamString = IOUtils.toString(entryBooksStream);
- importEntryBooksAsCSV(entryBooksStreamString);
-
fiscalPeriodsStream = new FileInputStream(tmpDir + "fiscalPeriods.csv");
String fiscalPeriodsStreamString = IOUtils.toString(fiscalPeriodsStream);
importFiscalPeriodsAsCSV(fiscalPeriodsStreamString);
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java 2014-06-10 16:17:01 UTC (rev 3828)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java 2014-06-11 08:16:27 UTC (rev 3829)
@@ -1,7 +1,6 @@
package org.chorem.lima.business;
import com.google.common.collect.Lists;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
@@ -11,12 +10,10 @@
import org.junit.Assert;
import org.junit.Test;
-import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.nio.charset.Charset;
-import java.util.Collection;
import java.util.List;
/**
@@ -213,14 +210,10 @@
public void exportAllAsCSVTest() throws Exception {
initTestWithFinancialTransaction();
String tmpDir = System.getProperty("java.io.tmpdir")+"/";
- String path = newExportService.exportAllAsCSV(tmpDir, "UTF-8");
-
+ String export = newExportService.exportAllAsCSV(tmpDir, "UTF-8");
initAbstractTest();
+ newImportService.importAllAsCSV(export);
+ }
- Collection<FinancialTransaction> financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("January 1, 2012"),df.parse("December 31, 2012"));
- Assert.assertTrue(financialTransactions.isEmpty());
- newImportService.importAllAsCSV(path);
- FileUtils.deleteDirectory(new File(tmpDir));
- }
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-06-10 16:17:01 UTC (rev 3828)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-06-11 08:16:27 UTC (rev 3829)
@@ -17,5 +17,5 @@
void importEntriesAsCSV(String contents) throws LimaException;
- void importAllAsCSV(String contents) throws LimaException;
+ void importAllAsCSV(String zippedBase64Str) throws LimaException;
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-06-10 16:17:01 UTC (rev 3828)
+++ trunk/pom.xml 2014-06-11 08:16:27 UTC (rev 3829)
@@ -183,12 +183,13 @@
<nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion>
<launch4jPluginVersion>1.5.0.0</launch4jPluginVersion>
- <jaxxVersion>2.8.5</jaxxVersion>
+ <jaxxVersion>2.8.7</jaxxVersion>
<openEjbVersion>4.6.0.2</openEjbVersion>
<slf4jVersion>1.7.7</slf4jVersion>
<swingxVersion>1.6.5-1</swingxVersion>
<pdfboxVersion>1.8.5</pdfboxVersion>
<jbossTransactionVersion>1.0.0.Final</jbossTransactionVersion>
+ <commonsCodecVersion>1.9</commonsCodecVersion>
<!-- license to use -->
<license.licenseName>gpl_v3</license.licenseName>
@@ -486,6 +487,13 @@
<version>${jettyPluginVersion}</version>
</dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>${commonsCodecVersion}</version>
+ </dependency>
+
+
</dependencies>
</dependencyManagement>
1
0
r3828 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business lima-business-api/src/main/java/org/chorem/lima/business/api
by dcosse@users.chorem.org 10 Jun '14
by dcosse@users.chorem.org 10 Jun '14
10 Jun '14
Author: dcosse
Date: 2014-06-10 18:17:01 +0200 (Tue, 10 Jun 2014)
New Revision: 3828
Url: http://forge.chorem.org/projects/lima/repository/revisions/3828
Log:
#1032 move file's creation to swing
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-10 13:23:09 UTC (rev 3827)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-10 16:17:01 UTC (rev 3828)
@@ -27,6 +27,7 @@
import com.google.common.collect.Lists;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
@@ -57,7 +58,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -93,17 +93,19 @@
@Override
public String exportAllAsCSV(String path, String charset) throws LimaException {
- List<File> files = Lists.newArrayList();
- files.add(exportAccountsAsCSV(path + t("lima-business.document.accounts") + ".csv", charset));
- files.add(exportEntryBooksAsCSV(path + t("lima-business.document.entryBooks") + ".csv", charset));
- files.add(exportFiscalPeriodAsCSV(path + t("lima-business.document.fiscalPeriods") + ".csv", charset));
- files.add(exportFinancialTransactionsAsCSV(path + t("lima-business.document.financialTransactions") + ".csv", charset));
- files.add(exportEntriesAsCSV(path + t("lima-business.document.entries") + ".csv", charset));
-
- SimpleDateFormat exportDate = new SimpleDateFormat(DATE_PATTERN);
- String filePath = path + "LIMA-BACKUP-"+ exportDate.format(new Date()) +".zip";
ZipOutputStream export = null;
+ String filePath;
try {
+ List<File> files = Lists.newArrayList();
+ files.add(exportAccountsFile(charset));
+ files.add(exportEntryBooksFile(charset));
+ files.add(exportFiscalPeriodFile(charset));
+ files.add(exportFinancialTransactionsFile(charset));
+ files.add(exportEntriesFile(charset));
+
+ SimpleDateFormat exportDate = new SimpleDateFormat(DATE_PATTERN);
+ filePath = path + "LIMA-BACKUP-"+ exportDate.format(new Date()) +".zip";
+
FileOutputStream out = new FileOutputStream(filePath);
export = new ZipOutputStream(out);
@@ -123,109 +125,139 @@
} catch (Exception e) {
throw new LimaException("Can't export All",e);
} finally {
- if(export != null) {
- //remember close it
- try {
- export.closeEntry();
- export.close();
- } catch (IOException e) {
- // nothing to do
- }
- }
+ IOUtils.closeQuietly(export);
}
return filePath;
}
- @Override
- public File exportAccountsAsCSV(String path, String charset) throws LimaException {
- File file;
- try {
+ protected File exportAccountsFile(String charset) throws Exception {
+ AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
+ List<Account> entities = accountTopiaDao.findAll();
- AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
- List<Account> entities = accountTopiaDao.findAll();
+ AccountModel model = new AccountModel();
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
- file = new File(path);
- AccountModel model = new AccountModel();
- Export.exportToFile(model, entities, file, Charset.forName(charset));
- new FileInputStream(file);
+ File result = new File(tmpDir + "accounts.csv");
+ Export.exportToFile(model, entities, result, Charset.forName(charset));
+ return result;
+ }
+ @Override
+ public String exportAccountsStream(String charset) throws LimaException {
+ String result;
+ try {
+ File file = exportAccountsFile(charset);
+ FileInputStream inputStream = new FileInputStream(file);
+ result = IOUtils.toString(inputStream);
} catch (Exception ex) {
throw new LimaException("Can't export accounts", ex);
}
- return file;
+ return result;
}
- @Override
- public File exportEntryBooksAsCSV(String path, String charset) throws LimaException {
- File file;
- try {
+ protected File exportEntryBooksFile(String charset) throws Exception {
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ List<EntryBook> entities = entryBookTopiaDao.findAll();
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- List<EntryBook> entities = entryBookTopiaDao.findAll();
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
+ File result = new File(tmpDir + "entryBooks.csv");
+ EntryBookModel model = new EntryBookModel();
+ Export.exportToFile(model, entities, result, Charset.forName(charset));
- file = new File(path);
- EntryBookModel model = new EntryBookModel();
- Export.exportToFile(model, entities, file, Charset.forName(charset));
- new FileInputStream(file);
+ return result;
+ }
+
+ @Override
+ public String exportEntryBooksStream(String charset) throws LimaException {
+ String result;
+ try {
+ File file = exportEntryBooksFile(charset);
+ FileInputStream inputStream = new FileInputStream(file);
+ result = IOUtils.toString(inputStream);
} catch (Exception ex) {
throw new LimaException("Can't export entry books", ex);
}
- return file;
+ return result;
}
+ protected File exportFiscalPeriodFile(String charset) throws Exception {
+
+ FiscalPeriodTopiaDao dao = getDaoHelper().getFiscalPeriodDao();
+ List<FiscalPeriod> entities = dao.findAll();
+
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
+ File result = new File(tmpDir + "fiscalPeriod.csv");
+ FiscalPeriodModel model = new FiscalPeriodModel();
+ Export.exportToFile(model, entities, result, Charset.forName(charset));
+
+ return result;
+ }
+
@Override
- public File exportFiscalPeriodAsCSV(String path, String charset) throws LimaException {
- File file;
+ public String exportFiscalPeriodsStream(String charset) throws LimaException {
+ String result;
try {
- FiscalPeriodTopiaDao dao = getDaoHelper().getFiscalPeriodDao();
- List<FiscalPeriod> entities = dao.findAll();
-
- file = new File(path);
- FiscalPeriodModel model = new FiscalPeriodModel();
- Export.exportToFile(model, entities, file, Charset.forName(charset));
- new FileInputStream(file);
+ File file = exportFiscalPeriodFile(charset);
+ FileInputStream inputStream = new FileInputStream(file);
+ result = IOUtils.toString(inputStream);
} catch (Exception ex) {
throw new LimaException("Can't export financial transactions", ex);
}
- return file;
+ return result;
}
+ protected File exportFinancialTransactionsFile(String charset) throws Exception {
+ File result;
+ FinancialTransactionTopiaDao financialTransactionTopiaDao =
+ getDaoHelper().getFinancialTransactionDao();
+ List<FinancialTransaction> entities = financialTransactionTopiaDao.findAll();
+
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
+ result = new File(tmpDir + "financialTransactions.csv");
+ FinancialTransactionModel model = new FinancialTransactionModel(entryBookService);
+ Export.exportToFile(model, entities, result, Charset.forName(charset));
+ Export.exportToFile(model, entities, result, Charset.forName(charset));
+ return result;
+ }
+
@Override
- public File exportFinancialTransactionsAsCSV(String path, String charset) throws LimaException {
- File file;
+ public String exportFinancialTransactionsAsStream(String charset) throws LimaException {
+ String result;
try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao =
- getDaoHelper().getFinancialTransactionDao();
- List<FinancialTransaction> entities = financialTransactionTopiaDao.findAll();
-
- file = new File(path);
- FinancialTransactionModel model = new FinancialTransactionModel(entryBookService);
- Export.exportToFile(model, entities, file, Charset.forName(charset));
- new FileInputStream(file);
+ File file = exportFinancialTransactionsFile(charset);
+ FileInputStream inputStream = new FileInputStream(file);
+ result = IOUtils.toString(inputStream);
} catch (Exception ex) {
throw new LimaException("Can't export financial transactions", ex);
}
- return file;
+ return result;
}
+ protected File exportEntriesFile(String charset) throws Exception {
+ EntryTopiaDao dao = getDaoHelper().getEntryDao();
+ List<Entry> entities = dao.findAll();
+
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
+ File result = new File(tmpDir + "entries.csv");
+ EntryModel model = new EntryModel(accountService, financialTransactionService);
+ Export.exportToFile(model, entities, result, Charset.forName(charset));
+ return result;
+ }
+
@Override
- public File exportEntriesAsCSV(String path, String charset) throws LimaException {
- File file;
+ public String exportEntriesAsCSV(String charset) throws LimaException {
+ String result;
try {
- EntryTopiaDao dao = getDaoHelper().getEntryDao();
- List<Entry> entities = dao.findAll();
-
- file = new File(path);
- EntryModel model = new EntryModel(accountService, financialTransactionService);
- Export.exportToFile(model, entities, file, Charset.forName(charset));
- new FileInputStream(file);
+ File file = exportEntriesFile(charset);
+ FileInputStream inputStream = new FileInputStream(file);
+ result = IOUtils.toString(inputStream);
} catch (Exception ex) {
throw new LimaException("Can't export financial transactions", ex);
}
- return file;
+ return result;
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-06-10 13:23:09 UTC (rev 3827)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-06-10 16:17:01 UTC (rev 3828)
@@ -168,25 +168,29 @@
public void importAllAsCSV(String path) throws LimaException {
FileInputStream contentStream;
ZipInputStream zipInputStream = null;
+
+ InputStream transactionsStream = null, entryBooksStream = null, fiscalPeriodsStream = null, entriesStream = null, accountsStream = null;
try {
contentStream = new FileInputStream(path);
zipInputStream = new ZipInputStream(contentStream);
+ // unzip
ZipEntry entry;
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
while ((entry = zipInputStream.getNextEntry()) != null) {
byte[] buffer = new byte[2048];
FileOutputStream fileoutputstream = null;
- if (entry.getName().equalsIgnoreCase(t("lima-business.document.accounts") + ".csv")) {
- fileoutputstream = new FileOutputStream(t("lima-business.document.accounts"));
- } else if (entry.getName().equalsIgnoreCase(t("lima-business.document.entryBooks") + ".csv")) {
- fileoutputstream = new FileOutputStream(t("lima-business.document.entryBooks"));
- } else if (entry.getName().equalsIgnoreCase(t("lima-business.document.fiscalPeriods") + ".csv")) {
- fileoutputstream = new FileOutputStream(t("lima-business.document.fiscalPeriods"));
- } else if (entry.getName().equalsIgnoreCase(t("lima-business.document.financialTransactions") + ".csv")) {
- fileoutputstream = new FileOutputStream(t("lima-business.document.financialTransactions"));
- } else if (entry.getName().equalsIgnoreCase(t("lima-business.document.entries") + ".csv")) {
- fileoutputstream = new FileOutputStream(t("lima-business.document.entries"));
+ if (entry.getName().equalsIgnoreCase("accounts.csv")) {
+ fileoutputstream = new FileOutputStream(tmpDir + "accounts.csv");
+ } else if (entry.getName().equalsIgnoreCase("entryBooks.csv")) {
+ fileoutputstream = new FileOutputStream(tmpDir + "entryBooks.csv");
+ } else if (entry.getName().equalsIgnoreCase("fiscalPeriod.csv")) {
+ fileoutputstream = new FileOutputStream(tmpDir + "fiscalPeriods.csv");
+ } else if (entry.getName().equalsIgnoreCase("financialTransactions.csv")) {
+ fileoutputstream = new FileOutputStream(tmpDir + "financialTransactions.csv");
+ } else if (entry.getName().equalsIgnoreCase("entries.csv")) {
+ fileoutputstream = new FileOutputStream(tmpDir + "entries.csv");
}
int n;
@@ -200,23 +204,24 @@
zipInputStream.closeEntry();
}
- InputStream transactionsStream = new FileInputStream(t("lima-business.document.financialTransactions"));
+ // import
+ transactionsStream = new FileInputStream(tmpDir + "financialTransactions.csv");
String transactionsStreamString = IOUtils.toString(transactionsStream);
importFinancialTransactionsAsCSV(transactionsStreamString);
- InputStream entryBooksStream = new FileInputStream(t("lima-business.document.entryBooks"));
+ entryBooksStream = new FileInputStream(tmpDir + "entryBooks.csv");
String entryBooksStreamString = IOUtils.toString(entryBooksStream);
importEntryBooksAsCSV(entryBooksStreamString);
- InputStream fiscalPeriodsStream = new FileInputStream(t("lima-business.document.fiscalPeriods"));
+ fiscalPeriodsStream = new FileInputStream(tmpDir + "fiscalPeriods.csv");
String fiscalPeriodsStreamString = IOUtils.toString(fiscalPeriodsStream);
importFiscalPeriodsAsCSV(fiscalPeriodsStreamString);
- InputStream entriesStream = new FileInputStream(t("lima-business.document.entries"));
+ entriesStream = new FileInputStream(tmpDir + "entries.csv");
String entriesStreamString = IOUtils.toString(entriesStream);
importEntriesAsCSV(entriesStreamString);
- InputStream accountsStream = new FileInputStream(t("lima-business.document.accounts"));
+ accountsStream = new FileInputStream(tmpDir + "accounts.csv");
String accountsStreamString = IOUtils.toString(accountsStream);
importAccountAsCSV(accountsStreamString);
@@ -224,6 +229,11 @@
throw new LimaException("Could not import", e);
} finally {
IOUtils.closeQuietly(zipInputStream);
+ IOUtils.closeQuietly(transactionsStream);
+ IOUtils.closeQuietly(entryBooksStream);
+ IOUtils.closeQuietly(fiscalPeriodsStream);
+ IOUtils.closeQuietly(entriesStream);
+ IOUtils.closeQuietly(accountsStream);
}
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java 2014-06-10 13:23:09 UTC (rev 3827)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java 2014-06-10 16:17:01 UTC (rev 3828)
@@ -13,6 +13,8 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.Collection;
import java.util.List;
@@ -31,8 +33,11 @@
// export accounts
- File file = newExportService.exportAccountsAsCSV("export-accounts.csv", Charset.defaultCharset().name());
- log.info("Account File path:" + file.getAbsolutePath());
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
+ String export = newExportService.exportAccountsStream(Charset.defaultCharset().name());
+ InputStream stream = IOUtils.toInputStream(export);
+ FileOutputStream res = new FileOutputStream(tmpDir + "export-accounts.csv");
+ IOUtils.copy(stream, res);
// remove accounts
int nbEntities = accounts.size();
@@ -42,28 +47,29 @@
Assert.assertEquals(0, accountService.getAllAccounts().size());
// import accounts
- FileInputStream contentStream = null;
+ InputStream contentStream = null;
try {
- contentStream = new FileInputStream(file.getPath());
- String stream = IOUtils.toString(contentStream);
- newImportService.importAccountAsCSV(stream);
+ contentStream = new FileInputStream(tmpDir + "export-accounts.csv");
+ String inportStream = IOUtils.toString(contentStream);
+ newImportService.importAccountAsCSV(inportStream);
// make sure all account have been created
Assert.assertEquals(nbEntities, accountService.getAllAccounts().size());
} finally {
IOUtils.closeQuietly(contentStream);
- FileUtils.forceDelete(file);
}
-
-
}
@Test
public void testExportImportEntryBooks() throws Exception {
initTestWithEntryBooks();
- File file = newExportService.exportEntryBooksAsCSV("export-entry-books.csv", Charset.defaultCharset().name());
- Assert.assertNotNull(file);
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
+ String export = newExportService.exportEntryBooksStream(Charset.defaultCharset().name());
+ InputStream stream = IOUtils.toInputStream(export);
+ FileOutputStream res = new FileOutputStream(tmpDir + "export-EntryBooks.csv");
+ IOUtils.copy(stream, res);
+
List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
int nbEntities = entryBooks.size();
Assert.assertEquals(3, nbEntities);
@@ -76,23 +82,25 @@
FileInputStream contentStream = null;
try {
- contentStream = new FileInputStream(file.getPath());
- String stream = IOUtils.toString(contentStream);
- newImportService.importEntryBooksAsCSV(stream);
+ contentStream = new FileInputStream(tmpDir + "export-EntryBooks.csv");
+ String inportStream = IOUtils.toString(contentStream);
+ newImportService.importEntryBooksAsCSV(inportStream);
} finally {
IOUtils.closeQuietly(contentStream);
}
Assert.assertEquals(nbEntities, entryBookService.getAllEntryBooks().size());
- FileUtils.forceDelete(file);
}
@Test
public void testExportImportFinancialTransactions() throws Exception {
initTestWithFinancialTransaction();
- File file = newExportService.exportFinancialTransactionsAsCSV("export-financial-transactions.csv", Charset.defaultCharset().name());
- Assert.assertNotNull(file);
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
+ String export = newExportService.exportFinancialTransactionsAsStream(Charset.defaultCharset().name());
+ InputStream stream = IOUtils.toInputStream(export);
+ FileOutputStream res = new FileOutputStream(tmpDir + "export-financial-transactions.csv");
+ IOUtils.copy(stream, res);
List<FinancialTransaction> financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("January 1, 2012"),df.parse("December 31, 2012"));
int nbEntities = financialTransactions.size();
@@ -106,15 +114,14 @@
FileInputStream contentStream = null;
try {
- contentStream = new FileInputStream(file.getPath());
- String stream = IOUtils.toString(contentStream);
- newImportService.importFinancialTransactionsAsCSV(stream);
+ contentStream = new FileInputStream(tmpDir + "export-financial-transactions.csv");
+ String inportStream = IOUtils.toString(contentStream);
+ newImportService.importFinancialTransactionsAsCSV(inportStream);
} finally {
IOUtils.closeQuietly(contentStream);
}
Assert.assertEquals(nbEntities, financialTransactionService.getAllFinancialTransactions(df.parse("January 1, 2012"),df.parse("December 31, 2012")).size());
- FileUtils.forceDelete(file);
}
@Test
@@ -131,10 +138,12 @@
Assert.assertEquals(2,nbEntities);
//test export
- File file = newExportService.exportEntriesAsCSV("export-entries.csv", Charset.defaultCharset().name());
- Assert.assertNotNull(file);
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
+ String export = newExportService.exportEntriesAsCSV(Charset.defaultCharset().name());
+ InputStream stream = IOUtils.toInputStream(export);
+ FileOutputStream res = new FileOutputStream(tmpDir + "export-entries.csv");
+ IOUtils.copy(stream, res);
-
for (Entry entry : entries) {
FinancialTransaction financialTransaction = entry.getFinancialTransaction();
financialTransactionService.removeEntry(entry);
@@ -153,9 +162,9 @@
// test import
FileInputStream contentStream = null;
try {
- contentStream = new FileInputStream(file.getPath());
- String stream = IOUtils.toString(contentStream);
- newImportService.importEntriesAsCSV(stream);
+ contentStream = new FileInputStream(tmpDir + "export-entries.csv");
+ String inputStream = IOUtils.toString(contentStream);
+ newImportService.importEntriesAsCSV(inputStream);
} finally {
IOUtils.closeQuietly(contentStream);
}
@@ -168,15 +177,17 @@
}
Assert.assertEquals(nbEntities, entries.size());
- FileUtils.forceDelete(file);
}
@Test
public void testExportImportFiscalPeriodsAsCSV() throws Exception {
initTestWithFiscalPeriod();
- File file = newExportService.exportFiscalPeriodAsCSV("export-fiscal-periods.csv", Charset.defaultCharset().name());
- Assert.assertNotNull(file);
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
+ String export = newExportService.exportFiscalPeriodsStream(Charset.defaultCharset().name());
+ InputStream stream = IOUtils.toInputStream(export);
+ FileOutputStream res = new FileOutputStream(tmpDir + "export-fiscal-periods.csv");
+ IOUtils.copy(stream, res);
List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllFiscalPeriods();
int nbEntities = fiscalPeriods.size();
@@ -188,15 +199,14 @@
FileInputStream contentStream = null;
try {
- contentStream = new FileInputStream(file.getPath());
- String stream = IOUtils.toString(contentStream);
- newImportService.importFiscalPeriodsAsCSV(stream);
+ contentStream = new FileInputStream(tmpDir + "export-fiscal-periods.csv");
+ String inputStream = IOUtils.toString(contentStream);
+ newImportService.importFiscalPeriodsAsCSV(inputStream);
} finally {
IOUtils.closeQuietly(contentStream);
}
Assert.assertEquals(nbEntities, fiscalPeriodService.getAllFiscalPeriods().size());
- FileUtils.forceDelete(file);
}
@Test
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java 2014-06-10 13:23:09 UTC (rev 3827)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java 2014-06-10 16:17:01 UTC (rev 3828)
@@ -44,13 +44,13 @@
String exportAllAsCSV(String path, String charset) throws LimaException;
- File exportAccountsAsCSV(String path, String charset) throws LimaException;
+ String exportAccountsStream(String charset) throws LimaException;
- File exportEntryBooksAsCSV(String path, String charset) throws LimaException;
+ String exportEntryBooksStream(String charset) throws LimaException;
- File exportFiscalPeriodAsCSV(String path, String charset) throws LimaException;
+ String exportFiscalPeriodsStream(String charset) throws LimaException;
- File exportFinancialTransactionsAsCSV(String path, String charset) throws LimaException;
+ String exportFinancialTransactionsAsStream(String charset) throws LimaException;
- File exportEntriesAsCSV(String path, String charset) throws LimaException;
+ String exportEntriesAsCSV(String charset) throws LimaException;
}
1
0
Author: dcosse
Date: 2014-06-10 15:23:09 +0200 (Tue, 10 Jun 2014)
New Revision: 3827
Url: http://forge.chorem.org/projects/lima/repository/revisions/3827
Log:
#1032 utilisation de nuiton-csv migration en cours
Added:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AbstractLimaModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AccountModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryBookModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FinancialTransactionModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FiscalPeriodModel.java
trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
trunk/lima-business/pom.xml
trunk/lima-business/src/main/java/org/chorem/lima/LimaXAResource.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/migration/DatabaseMigrationClass.java
trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0V0_5.java
trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_6.java
trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_8.java
trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java
trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java
trunk/lima-callao/src/main/java/org/chorem/lima/DefaultServiceContext.java
trunk/lima-callao/src/main/xmi/accounting-model.properties
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java
trunk/pom.xml
Modified: trunk/lima-business/pom.xml
===================================================================
--- trunk/lima-business/pom.xml 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/pom.xml 2014-06-10 13:23:09 UTC (rev 3827)
@@ -70,6 +70,10 @@
<artifactId>nuiton-config</artifactId>
</dependency>
<dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-csv</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
Modified: trunk/lima-business/src/main/java/org/chorem/lima/LimaXAResource.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/LimaXAResource.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/java/org/chorem/lima/LimaXAResource.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -74,7 +74,7 @@
@Override
public void end(Xid arg0, int arg1) throws XAException {
/*try {
- context.closeContext();
+ context.close();
} catch (TopiaException ex) {
throw new XAException(XAException.XA_HEURCOM);
}*/
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -31,6 +31,7 @@
import org.chorem.lima.business.accountingrules.FranceAccountingRules;
import org.chorem.lima.business.migration.DatabaseMigrationClass;
import org.chorem.lima.entity.LimaCallaoEntityEnum;
+import org.nuiton.topia.migration.TopiaMigrationEngine;
import org.nuiton.topia.persistence.TopiaConfigurationConstants;
import org.nuiton.topia.migration.TopiaMigrationService;
import org.nuiton.config.ApplicationConfig;
@@ -65,9 +66,8 @@
// load default options
super(Option.class, null, null, null);
- // TODO DCossé 19/05/14 disabled until migration service is refactored.
- //setOption("topia.service.migration", TopiaMigrationEngine.class.getName());
- setOption(TopiaMigrationService.MIGRATION_CALLBACK, DatabaseMigrationClass.class.getName());
+ setOption("topia.service.migration", TopiaMigrationEngine.class.getName());
+ setOption("topia.service.migration.callback", DatabaseMigrationClass.class.getName());
setOption(TopiaMigrationService.MIGRATION_SHOW_SQL, Boolean.TRUE.toString());
setOption(TopiaMigrationService.MIGRATION_SHOW_PROGRESSION, Boolean.TRUE.toString());
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -82,7 +82,8 @@
// enter in service layer
// interceptor will be called before each internal
// ejb call, but opening a new transaction in not required
- if (DAO_HELPER.get() == null) {
+ LimaCallaoTopiaDaoSupplier supplier = DAO_HELPER.get();
+ if (supplier == null) {
// maybe take care of TransactionAttributeTypes ?
if (context.getTarget().getClass().getAnnotation(TransactionAttribute.class) != null ||
@@ -96,11 +97,6 @@
LimaCallaoTopiaApplicationContext rootContext = TopiaApplicationContextCache.getContext(config.getFlatOptions(), CREATE_CONTEXT_FUNCTION);
- if (!schemaExistChecked && rootContext.isSchemaEmpty()) {
- rootContext.createSchema();
- schemaExistChecked = true;
- }
-
LimaCallaoTopiaPersistenceContext tx = rootContext.newPersistenceContext();
DAO_HELPER.set(tx);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -33,6 +33,7 @@
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
+import java.util.Collection;
/**
* Created by davidcosse on 17/01/14.
@@ -44,13 +45,14 @@
@Override
public Entry createEntry(Entry entry) {
-
+ Entry result;
try {
EntryTopiaDao entryDao = getDaoHelper().getEntryDao();
- entryDao.create(entry);
+ result = entryDao.create(entry);
} catch (TopiaException e) {
throw new LimaException("Can't create entry", e);
}
- return null;
+ return result;
}
+
}
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 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -100,7 +100,7 @@
@Override
public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction)
throws LimaException {
- FinancialTransaction fTransaction;
+ FinancialTransaction result;
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
@@ -109,12 +109,12 @@
FinancialTransactionTopiaDao financialtransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- fTransaction = financialtransactionTopiaDao.create(financialtransaction);
+ result = financialtransactionTopiaDao.create(financialtransaction);
} catch (TopiaException ex) {
throw new LimaException("Can't create financial transaction", ex);
}
- return fTransaction;
+ return result;
}
/**
@@ -519,6 +519,13 @@
}
@Override
+ public FinancialTransaction getFinancialTransactionWithId(String id) throws LimaException {
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransaction result = transactionTopiaDao.findByTopiaId(id);
+ return result;
+ }
+
+ @Override
public Entry createEntry(Entry entry) throws LimaException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
@@ -572,9 +579,10 @@
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
+ FinancialTransaction financialTransaction = entry.getFinancialTransaction();
+
//check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
- entry.getFinancialTransaction());
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialTransaction);
EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
Entry entryOld = entryTopiaDao.findByTopiaId(entry.getTopiaId());
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -25,6 +25,7 @@
package org.chorem.lima.business.ejb;
+import com.google.common.collect.Lists;
import org.apache.commons.lang3.time.DateUtils;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.ReportsDatas;
@@ -52,6 +53,7 @@
import org.chorem.lima.entity.FinancialPeriodTopiaDao;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionImpl;
+import org.chorem.lima.entity.FinancialTransactionTopiaDao;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
import org.nuiton.topia.persistence.TopiaException;
@@ -104,6 +106,8 @@
try {
FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+
ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
@@ -124,25 +128,28 @@
// create
fiscalPeriod.addAllFinancialPeriod(financialPeriods);
- result = fiscalPeriodTopiaDao.create(fiscalPeriod);
//create all financial period
for (FinancialPeriod financialPeriod : financialPeriods) {
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = Lists.newArrayList();
//create ClosedPeriodicEntryBook for all entrybook
for (EntryBook entryBook : entryBookTopiaDao.findAll()) {
//new closed periodic entrybook
- ClosedPeriodicEntryBook closedPeriodicEntryBook
- = new ClosedPeriodicEntryBookImpl();
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl();
// set entrybook
closedPeriodicEntryBook.setEntryBook(entryBook);
// set financial period
closedPeriodicEntryBook.setFinancialPeriod(financialPeriod);
- // create it
- closedPeriodicEntryBookTopiaDao.create(closedPeriodicEntryBook);
+
+ closedPeriodicEntryBooks.add(closedPeriodicEntryBook);
}
+ financialPeriod.addAllEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBooks);
+
}
+ result = fiscalPeriodTopiaDao.create(fiscalPeriod);
+
} catch (TopiaException ex) {
throw new LimaException("Can't create period", ex);
}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java (from rev 3825, trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,231 @@
+/*
+ * #%L
+ * Lima business
+ *
+ * $Id: ExportServiceImpl.java 3781 2014-05-06 09:22:03Z dcosse $
+ * $HeadURL: http://svn.chorem.org/lima/trunk/lima-business/src/main/java/org/chorem/lim… $
+ * %%
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.business.ejb;
+
+import com.google.common.collect.Lists;
+import org.apache.commons.io.FileUtils;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.api.AccountService;
+import org.chorem.lima.business.api.EntryBookService;
+import org.chorem.lima.business.api.FinancialTransactionService;
+import org.chorem.lima.business.api.NewExportService;
+import org.chorem.lima.business.ejb.csv.AccountModel;
+import org.chorem.lima.business.ejb.csv.EntryBookModel;
+import org.chorem.lima.business.ejb.csv.EntryModel;
+import org.chorem.lima.business.ejb.csv.FinancialTransactionModel;
+import org.chorem.lima.business.ejb.csv.FiscalPeriodModel;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountTopiaDao;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookTopiaDao;
+import org.chorem.lima.entity.EntryTopiaDao;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionTopiaDao;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.entity.FiscalPeriodTopiaDao;
+import org.nuiton.csv.Export;
+
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import static org.nuiton.i18n.I18n.t;
+
+/**
+ * CSV import export service.
+ *
+ * @version $Revision: 3781 $
+ * <p/>
+ * Last update : $Date: 2014-05-06 11:22:03 +0200 (mar. 06 mai 2014) $
+ * By : $Author: dcosse $
+ */
+@Stateless
+(a)Remote(NewExportService.class)
+@TransactionAttribute
+public class NewExportServiceImpl extends AbstractLimaService implements NewExportService {
+
+ protected final String DATE_PATTERN = "dd-MM-yyyy-HH:mm";
+
+ @EJB
+ private EntryBookService entryBookService;
+
+ @EJB
+ private AccountService accountService;
+
+ @EJB
+ private FinancialTransactionService financialTransactionService;
+
+ @Override
+ public String exportAllAsCSV(String path, String charset) throws LimaException {
+ List<File> files = Lists.newArrayList();
+ files.add(exportAccountsAsCSV(path + t("lima-business.document.accounts") + ".csv", charset));
+ files.add(exportEntryBooksAsCSV(path + t("lima-business.document.entryBooks") + ".csv", charset));
+ files.add(exportFiscalPeriodAsCSV(path + t("lima-business.document.fiscalPeriods") + ".csv", charset));
+ files.add(exportFinancialTransactionsAsCSV(path + t("lima-business.document.financialTransactions") + ".csv", charset));
+ files.add(exportEntriesAsCSV(path + t("lima-business.document.entries") + ".csv", charset));
+
+ SimpleDateFormat exportDate = new SimpleDateFormat(DATE_PATTERN);
+ String filePath = path + "LIMA-BACKUP-"+ exportDate.format(new Date()) +".zip";
+ ZipOutputStream export = null;
+ try {
+ FileOutputStream out = new FileOutputStream(filePath);
+ export = new ZipOutputStream(out);
+
+ for (File file : files) {
+ ZipEntry ze= new ZipEntry(file.getName());
+ export.putNextEntry(ze);
+ int len;
+ byte[] buffer = new byte[1024];
+ FileInputStream stream = new FileInputStream(file);
+ while ((len = stream.read(buffer)) > 0) {
+ export.write(buffer, 0, len);
+ }
+ stream.close();
+ FileUtils.forceDelete(file);
+ }
+
+ } catch (Exception e) {
+ throw new LimaException("Can't export All",e);
+ } finally {
+ if(export != null) {
+ //remember close it
+ try {
+ export.closeEntry();
+ export.close();
+ } catch (IOException e) {
+ // nothing to do
+ }
+ }
+ }
+
+ return filePath;
+ }
+
+ @Override
+ public File exportAccountsAsCSV(String path, String charset) throws LimaException {
+ File file;
+ try {
+
+ AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
+ List<Account> entities = accountTopiaDao.findAll();
+
+ file = new File(path);
+ AccountModel model = new AccountModel();
+ Export.exportToFile(model, entities, file, Charset.forName(charset));
+ new FileInputStream(file);
+
+ } catch (Exception ex) {
+ throw new LimaException("Can't export accounts", ex);
+ }
+ return file;
+ }
+
+ @Override
+ public File exportEntryBooksAsCSV(String path, String charset) throws LimaException {
+ File file;
+ try {
+
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ List<EntryBook> entities = entryBookTopiaDao.findAll();
+
+ file = new File(path);
+ EntryBookModel model = new EntryBookModel();
+ Export.exportToFile(model, entities, file, Charset.forName(charset));
+ new FileInputStream(file);
+
+ } catch (Exception ex) {
+ throw new LimaException("Can't export entry books", ex);
+ }
+ return file;
+ }
+
+ @Override
+ public File exportFiscalPeriodAsCSV(String path, String charset) throws LimaException {
+ File file;
+ try {
+ FiscalPeriodTopiaDao dao = getDaoHelper().getFiscalPeriodDao();
+ List<FiscalPeriod> entities = dao.findAll();
+
+ file = new File(path);
+ FiscalPeriodModel model = new FiscalPeriodModel();
+ Export.exportToFile(model, entities, file, Charset.forName(charset));
+ new FileInputStream(file);
+ } catch (Exception ex) {
+ throw new LimaException("Can't export financial transactions", ex);
+ }
+ return file;
+ }
+
+
+ @Override
+ public File exportFinancialTransactionsAsCSV(String path, String charset) throws LimaException {
+ File file;
+ try {
+ FinancialTransactionTopiaDao financialTransactionTopiaDao =
+ getDaoHelper().getFinancialTransactionDao();
+ List<FinancialTransaction> entities = financialTransactionTopiaDao.findAll();
+
+ file = new File(path);
+ FinancialTransactionModel model = new FinancialTransactionModel(entryBookService);
+ Export.exportToFile(model, entities, file, Charset.forName(charset));
+ new FileInputStream(file);
+ } catch (Exception ex) {
+ throw new LimaException("Can't export financial transactions", ex);
+ }
+ return file;
+ }
+
+ @Override
+ public File exportEntriesAsCSV(String path, String charset) throws LimaException {
+ File file;
+ try {
+ EntryTopiaDao dao = getDaoHelper().getEntryDao();
+ List<Entry> entities = dao.findAll();
+
+ file = new File(path);
+ EntryModel model = new EntryModel(accountService, financialTransactionService);
+ Export.exportToFile(model, entities, file, Charset.forName(charset));
+ new FileInputStream(file);
+ } catch (Exception ex) {
+ throw new LimaException("Can't export financial transactions", ex);
+ }
+ return file;
+ }
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,229 @@
+package org.chorem.lima.business.ejb;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.commons.io.IOUtils;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.api.AccountService;
+import org.chorem.lima.business.api.EntryBookService;
+import org.chorem.lima.business.api.FinancialTransactionService;
+import org.chorem.lima.business.api.NewImportService;
+import org.chorem.lima.business.ejb.csv.AccountModel;
+import org.chorem.lima.business.ejb.csv.EntryBookModel;
+import org.chorem.lima.business.ejb.csv.EntryModel;
+import org.chorem.lima.business.ejb.csv.FinancialTransactionModel;
+import org.chorem.lima.business.ejb.csv.FiscalPeriodModel;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountTopiaDao;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookTopiaDao;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionTopiaDao;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.entity.FiscalPeriodTopiaDao;
+import org.nuiton.csv.Import;
+import org.nuiton.csv.ImportModel;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import static org.nuiton.i18n.I18n.t;
+
+/**
+ * Created by davidcosse on 03/06/14.
+ */
+@Stateless
+(a)Remote(NewImportService.class)
+@TransactionAttribute
+public class NewImportServiceImpl extends AbstractLimaService implements NewImportService {
+
+ @EJB
+ private EntryBookService entryBookService;
+
+ @EJB
+ private AccountService accountService;
+
+ @EJB
+ private FinancialTransactionService financialTransactionService;
+
+ @Override
+ public void importAccountAsCSV(String contents) throws LimaException {
+ InputStream contentStream = IOUtils.toInputStream(contents);
+
+ try {
+ ImportModel<Account> model = new AccountModel();
+ AccountTopiaDao dao = getDaoHelper().getAccountDao();
+ Import<Account> result = Import.newImport(model, contentStream);
+
+ List<Account> newAccounts = Lists.newArrayList();
+ Account oldAccount;
+ for (Account account : result) {
+ oldAccount = dao.forAccountNumberEquals(account.getAccountNumber()).findUniqueOrNull();
+ if (oldAccount == null) {
+ newAccounts.add(account);
+ }
+ }
+ dao.createAll(newAccounts);
+ } finally {
+ IOUtils.closeQuietly(contentStream);
+ }
+
+ }
+
+ @Override
+ public void importEntryBooksAsCSV(String contents) throws LimaException {
+ InputStream contentStream = IOUtils.toInputStream(contents);
+ try {
+ ImportModel<EntryBook> model = new EntryBookModel();
+
+ EntryBookTopiaDao dao = getDaoHelper().getEntryBookDao();
+ Import<EntryBook> result = Import.newImport(model, contentStream);
+ dao.createAll(result);
+ } finally {
+ IOUtils.closeQuietly(contentStream);
+ }
+ }
+
+ @Override
+ public void importFiscalPeriodsAsCSV(String contents) throws LimaException {
+ InputStream contentStream = IOUtils.toInputStream(contents);
+ try {
+ ImportModel<FiscalPeriod> model = new FiscalPeriodModel();
+
+ FiscalPeriodTopiaDao dao = getDaoHelper().getFiscalPeriodDao();
+ Import<FiscalPeriod> result = Import.newImport(model, contentStream);
+ dao.createAll(result);
+ } finally {
+ IOUtils.closeQuietly(contentStream);
+ }
+ }
+
+ @Override
+ public void importFinancialTransactionsAsCSV(String contents) throws LimaException {
+ // import and save FinancialTransactions
+ InputStream contentStream = IOUtils.toInputStream(contents);
+ try {
+ ImportModel<FinancialTransaction> model = new FinancialTransactionModel(entryBookService);
+
+ FinancialTransactionTopiaDao dao = getDaoHelper().getFinancialTransactionDao();
+ Import<FinancialTransaction> result = Import.newImport(model, contentStream);
+ dao.createAll(result);
+ } finally {
+ IOUtils.closeQuietly(contentStream);
+ }
+ }
+
+ protected static final Function<TopiaEntity, String> GET_TOPIA_ID = new Function<TopiaEntity, String>() {
+ @Override
+ public String apply(TopiaEntity input) {
+ return input == null ? null : input.getTopiaId();
+ }
+ };
+
+ @Override
+ public void importEntriesAsCSV(String contents) throws LimaException {
+ // import and save entries
+ InputStream contentStream = IOUtils.toInputStream(contents);
+ try {
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+
+ ImportModel<Entry> model = new EntryModel(accountService, financialTransactionService);
+ Import<Entry> result = Import.newImport(model, contentStream);
+
+ Collection<FinancialTransaction> financialTransactions = financialTransactionTopiaDao.findAll();
+ ImmutableMap<String, FinancialTransaction> indexedFinancialTransactions = Maps.uniqueIndex(financialTransactions, GET_TOPIA_ID);
+
+ for (Entry entry : result) {
+ FinancialTransaction financialTransaction = entry.getFinancialTransaction();
+ financialTransaction = indexedFinancialTransactions.get(financialTransaction.getTopiaId());
+ Collection<Entry> fEntries = financialTransaction.getEntry();
+ if(fEntries == null) {
+ fEntries = Lists.newArrayList();
+ financialTransaction.setEntry(fEntries);
+ }
+ fEntries.add(entry);
+ }
+
+ financialTransactionTopiaDao.updateAll(indexedFinancialTransactions.values());
+
+ } finally {
+ IOUtils.closeQuietly(contentStream);
+ }
+ }
+
+ @Override
+ public void importAllAsCSV(String path) throws LimaException {
+ FileInputStream contentStream;
+ ZipInputStream zipInputStream = null;
+ try {
+ contentStream = new FileInputStream(path);
+ zipInputStream = new ZipInputStream(contentStream);
+
+ ZipEntry entry;
+ while ((entry = zipInputStream.getNextEntry()) != null) {
+ byte[] buffer = new byte[2048];
+ FileOutputStream fileoutputstream = null;
+
+ if (entry.getName().equalsIgnoreCase(t("lima-business.document.accounts") + ".csv")) {
+ fileoutputstream = new FileOutputStream(t("lima-business.document.accounts"));
+ } else if (entry.getName().equalsIgnoreCase(t("lima-business.document.entryBooks") + ".csv")) {
+ fileoutputstream = new FileOutputStream(t("lima-business.document.entryBooks"));
+ } else if (entry.getName().equalsIgnoreCase(t("lima-business.document.fiscalPeriods") + ".csv")) {
+ fileoutputstream = new FileOutputStream(t("lima-business.document.fiscalPeriods"));
+ } else if (entry.getName().equalsIgnoreCase(t("lima-business.document.financialTransactions") + ".csv")) {
+ fileoutputstream = new FileOutputStream(t("lima-business.document.financialTransactions"));
+ } else if (entry.getName().equalsIgnoreCase(t("lima-business.document.entries") + ".csv")) {
+ fileoutputstream = new FileOutputStream(t("lima-business.document.entries"));
+ }
+ int n;
+
+ if (fileoutputstream != null) {
+ while ((n = zipInputStream.read(buffer, 0, 2048)) > -1) {
+ fileoutputstream.write(buffer, 0, n);
+ }
+ fileoutputstream.close();
+ }
+
+ zipInputStream.closeEntry();
+ }
+
+ InputStream transactionsStream = new FileInputStream(t("lima-business.document.financialTransactions"));
+ String transactionsStreamString = IOUtils.toString(transactionsStream);
+ importFinancialTransactionsAsCSV(transactionsStreamString);
+
+ InputStream entryBooksStream = new FileInputStream(t("lima-business.document.entryBooks"));
+ String entryBooksStreamString = IOUtils.toString(entryBooksStream);
+ importEntryBooksAsCSV(entryBooksStreamString);
+
+ InputStream fiscalPeriodsStream = new FileInputStream(t("lima-business.document.fiscalPeriods"));
+ String fiscalPeriodsStreamString = IOUtils.toString(fiscalPeriodsStream);
+ importFiscalPeriodsAsCSV(fiscalPeriodsStreamString);
+
+ InputStream entriesStream = new FileInputStream(t("lima-business.document.entries"));
+ String entriesStreamString = IOUtils.toString(entriesStream);
+ importEntriesAsCSV(entriesStreamString);
+
+ InputStream accountsStream = new FileInputStream(t("lima-business.document.accounts"));
+ String accountsStreamString = IOUtils.toString(accountsStream);
+ importAccountAsCSV(accountsStreamString);
+
+ } catch (Exception e) {
+ throw new LimaException("Could not import", e);
+ } finally {
+ IOUtils.closeQuietly(zipInputStream);
+ }
+ }
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AbstractLimaModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AbstractLimaModel.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AbstractLimaModel.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,298 @@
+package org.chorem.lima.business.ejb.csv;
+
+import com.google.common.base.Strings;
+import org.apache.commons.lang3.StringUtils;
+import org.chorem.lima.business.api.AccountService;
+import org.chorem.lima.business.api.EntryBookService;
+import org.chorem.lima.business.api.FinancialTransactionService;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.nuiton.csv.ValueFormatter;
+import org.nuiton.csv.ValueParser;
+import org.nuiton.csv.ext.AbstractImportModel;
+
+import javax.ejb.EJB;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Created by davidcosse on 03/06/14.
+ */
+public abstract class AbstractLimaModel<E> extends AbstractImportModel<E> {
+
+
+ protected static EntryBookService entryBookService;
+
+ protected static FinancialTransactionService financialTransactionService;
+
+ protected static AccountService accountService;
+
+ public AbstractLimaModel(char separator) {
+ super(separator);
+ }
+
+ /**
+ * String to integer converter.
+ */
+ protected static final ValueParser<Integer> INT_PARSER = new ValueParser<Integer>() {
+ @Override
+ public Integer parse(String value) throws ParseException {
+ int result = 0;
+ if (!Strings.isNullOrEmpty(value)) {
+ result = Integer.valueOf(value);
+ }
+ return result;
+ }
+ };
+
+ /**
+ * String to integer converter (null allowed).
+ */
+ protected static final ValueParser<Integer> INTEGER_WITH_NULL_PARSER = new ValueParser<Integer>() {
+ @Override
+ public Integer parse(String value) throws ParseException {
+ Integer result = null;
+ if (!Strings.isNullOrEmpty(value)) {
+ result = Integer.valueOf(value);
+ }
+ return result;
+ }
+ };
+
+ /**
+ * String to double converter.
+ * Can handle , or . as decimal separator and ' ' as thousand separator
+ */
+ protected static final ValueParser<Double> DOUBLE_PARSER = new ValueParser<Double>() {
+ @Override
+ public Double parse(String value) throws ParseException {
+ double result = 0;
+ if (!value.isEmpty()) {
+ // " " est un espace insécable, pas un " "
+ result = Double.valueOf(value.replace(',','.').replace(" ", ""));
+ }
+ return result;
+ }
+ };
+
+ /**
+ * String to double converter (null allowed).
+ * Can handle , or . as decimal separator and ' ' as thousand separator
+ */
+ protected static final ValueParser<Double> DOUBLE_WITH_NULL_PARSER = new ValueParser<Double>() {
+ @Override
+ public Double parse(String value) throws ParseException {
+ Double result = null;
+ if (!value.isEmpty()) {
+ // " " est un espace insécable, pas un " "
+ result = Double.valueOf(value.replace(',','.').replace(" ", ""));
+ }
+ return result;
+ }
+ };
+
+ /**
+ * Zero to empty string converter.
+ */
+ protected static final ValueParser<String> ZERO_TO_EMPTY_PARSER = new ValueParser<String>() {
+ @Override
+ public String parse(String value) throws ParseException {
+ String result = value.trim();
+ result = result.replaceAll("\\s{2,}", " "); // replace multiple spaces
+ if (result.equals("0")) {
+ result = "";
+ }
+ return result;
+ }
+ };
+
+ /**
+ * Date converter converter.
+ */
+ protected static final ValueParser<Date> DATE_PARSER = new ValueParser<Date>() {
+ @Override
+ public Date parse(String value) throws ParseException {
+ Date result = null;
+ if (!Strings.isNullOrEmpty(value)) {
+ SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
+ result = format.parse(value);
+ }
+ return result;
+ }
+ };
+
+ /**
+ * O/N boolean parser.
+ */
+ protected static final ValueParser<Boolean> O_N_PARSER = new ValueParser<Boolean>() {
+ @Override
+ public Boolean parse(String value) throws ParseException {
+ Boolean result;
+ if ("O".equalsIgnoreCase(value)) {
+ result = Boolean.TRUE;
+ } else {
+ result = Boolean.FALSE;
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueFormatter<Boolean> O_N_FORMATTER = new ValueFormatter<Boolean>() {
+ @Override
+ public String format(Boolean value) {
+ String result = value ? "O" : "N";
+ return result;
+ }
+ };
+
+ protected static final ValueFormatter<Integer> INTEGER_FORMATTER = new ValueFormatter<Integer>() {
+ @Override
+ public String format(Integer value) {
+ String result;
+ if (value != null) {
+ result = String.valueOf(value);
+ } else {
+ result = "";
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueFormatter<Double> DOUBLE_FORMATTER = new ValueFormatter<Double>() {
+ @Override
+ public String format(Double value) {
+ String result;
+ if (value != null) {
+ result = String.valueOf(value);
+ } else {
+ result = "";
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueFormatter<Date> DATE_FORMATTER = new ValueFormatter<Date>() {
+ @Override
+ public String format(Date value) {
+ String result;
+ if (value != null) {
+ SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
+ result = format.format(value);
+ } else {
+ result = "";
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueFormatter<EntryBook> ENTRY_BOOK_TO_ENTRY_BOOK_CODE_FORMATTER = new ValueFormatter<EntryBook>() {
+ @Override
+ public String format(EntryBook value) {
+ String result;
+ if (value != null) {
+ result = value.getCode();
+ } else {
+ result = "";
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueParser<EntryBook> ENTRY_BOOK_CODE_TO_ENTRY_BOOK_PARSER = new ValueParser<EntryBook>() {
+
+ @Override
+ public EntryBook parse(String value) {
+ EntryBook result;
+ if (StringUtils.isNotBlank(value)) {
+ result = entryBookService.getEntryBookByCode(value);
+ } else {
+ result = null;
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueParser<BigDecimal> BIG_DECIMAL_WITH_NULL_PARSER = new ValueParser<BigDecimal>() {
+ @Override
+ public BigDecimal parse(String value) throws ParseException {
+ BigDecimal result = null;
+ if (!value.isEmpty()) {
+ // " " est un espace insécable, pas un " "
+ Double dval = Double.valueOf(value.replace(',', '.').replace(" ", ""));
+ result = BigDecimal.valueOf(dval);
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueFormatter<BigDecimal> BIG_DECIMAL_FORMATTER = new ValueFormatter<BigDecimal>() {
+ @Override
+ public String format(BigDecimal value) {
+ String result;
+ if (value != null) {
+ result = String.valueOf(value);
+ } else {
+ result = "";
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueFormatter<Account> ACCOUNT_TO_ACCOUNT_NUMBER_FORMATTER = new ValueFormatter<Account>() {
+ @Override
+ public String format(Account value) {
+ String result;
+ if (value != null) {
+ result = value.getAccountNumber();
+ } else {
+ result = "";
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueParser<Account> ACCOUNT_NUMBER_TO_ACCOUNT_TRANSACTION_PARSER = new ValueParser<Account>() {
+
+ @Override
+ public Account parse(String value) {
+ Account result;
+ if (StringUtils.isNotBlank(value)) {
+ result = accountService.getAccountByNumber(value);
+ } else {
+ result = null;
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueFormatter<FinancialTransaction> FINANCIAL_TRANSACTION_TO_FINANCIAL_TRANSACTION_ID_FORMATTER = new ValueFormatter<FinancialTransaction>() {
+ @Override
+ public String format(FinancialTransaction value) {
+ String result;
+ if (value != null) {
+ result = value.getTopiaId();
+ } else {
+ result = "";
+ }
+ return result;
+ }
+ };
+
+ protected static final ValueParser<FinancialTransaction> FINANCIAL_TRANSACTION_ID_TO_FINANCIAL_TRANSACTION_PARSER = new ValueParser<FinancialTransaction>() {
+
+ @Override
+ public FinancialTransaction parse(String value) {
+ FinancialTransaction result;
+ if (StringUtils.isNotBlank(value)) {
+ result = financialTransactionService.getFinancialTransactionWithId(value);
+ } else {
+ result = null;
+ }
+ return result;
+ }
+ };
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AccountModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AccountModel.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AccountModel.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,34 @@
+package org.chorem.lima.business.ejb.csv;
+
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountImpl;
+import org.nuiton.csv.ExportModel;
+import org.nuiton.csv.ExportableColumn;
+import org.nuiton.csv.ModelBuilder;
+
+/**
+ * Created by davidcosse on 03/06/14.
+ */
+public class AccountModel extends AbstractLimaModel<Account> implements ExportModel<Account> {
+
+ public AccountModel() {
+ super(';');
+ newMandatoryColumn("accountNumber", Account.PROPERTY_ACCOUNT_NUMBER);
+ newOptionalColumn("label", Account.PROPERTY_LABEL);
+ newOptionalColumn("thirdParty", Account.PROPERTY_THIRD_PARTY);
+ }
+
+ @Override
+ public Iterable<ExportableColumn<Account, Object>> getColumnsForExport() {
+ ModelBuilder<Account> modelBuilder = new ModelBuilder<Account>();
+ modelBuilder.newColumnForExport("accountNumber", Account.PROPERTY_ACCOUNT_NUMBER);
+ modelBuilder.newColumnForExport("label", Account.PROPERTY_LABEL);
+ modelBuilder.newColumnForExport("thirdParty", Account.PROPERTY_THIRD_PARTY);
+ return (Iterable) modelBuilder.getColumnsForExport();
+ }
+
+ @Override
+ public Account newEmptyInstance() {
+ return new AccountImpl();
+ }
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryBookModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryBookModel.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryBookModel.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,32 @@
+package org.chorem.lima.business.ejb.csv;
+
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookImpl;
+import org.nuiton.csv.ExportModel;
+import org.nuiton.csv.ExportableColumn;
+import org.nuiton.csv.ModelBuilder;
+
+/**
+ * Created by davidcosse on 03/06/14.
+ */
+public class EntryBookModel extends AbstractLimaModel<EntryBook> implements ExportModel<EntryBook> {
+
+ public EntryBookModel() {
+ super(';');
+ newMandatoryColumn("code", EntryBook.PROPERTY_CODE);
+ newOptionalColumn("label", EntryBook.PROPERTY_LABEL);
+ }
+
+ @Override
+ public Iterable<ExportableColumn<EntryBook, Object>> getColumnsForExport() {
+ ModelBuilder<EntryBook> modelBuilder = new ModelBuilder<EntryBook>();
+ modelBuilder.newColumnForExport("code", EntryBook.PROPERTY_CODE);
+ modelBuilder.newColumnForExport("label", EntryBook.PROPERTY_LABEL);
+ return (Iterable) modelBuilder.getColumnsForExport();
+ }
+
+ @Override
+ public EntryBook newEmptyInstance() {
+ return new EntryBookImpl();
+ }
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryModel.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryModel.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,52 @@
+package org.chorem.lima.business.ejb.csv;
+
+import org.chorem.lima.business.api.AccountService;
+import org.chorem.lima.business.api.FinancialTransactionService;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryImpl;
+import org.nuiton.csv.ExportModel;
+import org.nuiton.csv.ExportableColumn;
+import org.nuiton.csv.ModelBuilder;
+
+/**
+ * Created by davidcosse on 03/06/14.
+ */
+public class EntryModel extends AbstractLimaModel<Entry> implements ExportModel<Entry> {
+
+ public EntryModel(AccountService accountService, FinancialTransactionService financialTransactionService) {
+ super(';');
+ AbstractLimaModel.accountService = accountService;
+ AbstractLimaModel.financialTransactionService = financialTransactionService;
+
+ newMandatoryColumn("account", Entry.PROPERTY_ACCOUNT, ACCOUNT_NUMBER_TO_ACCOUNT_TRANSACTION_PARSER);
+ newOptionalColumn("amount", Entry.PROPERTY_AMOUNT, BIG_DECIMAL_WITH_NULL_PARSER);
+ newOptionalColumn("debit", Entry.PROPERTY_DEBIT, O_N_PARSER);
+ newOptionalColumn("detail", Entry.PROPERTY_DETAIL);
+ newOptionalColumn("position", Entry.PROPERTY_POSITION);
+ newOptionalColumn("voucher", Entry.PROPERTY_VOUCHER);
+ newOptionalColumn("description", Entry.PROPERTY_DESCRIPTION);
+ newOptionalColumn("lettering", Entry.PROPERTY_LETTERING);
+ newOptionalColumn("financialTransaction", Entry.PROPERTY_FINANCIAL_TRANSACTION, FINANCIAL_TRANSACTION_ID_TO_FINANCIAL_TRANSACTION_PARSER);
+ }
+
+ @Override
+ public Iterable<ExportableColumn<Entry, Object>> getColumnsForExport() {
+ ModelBuilder<Entry> modelBuilder = new ModelBuilder<Entry>();
+ modelBuilder.newColumnForExport("account", Entry.PROPERTY_ACCOUNT, ACCOUNT_TO_ACCOUNT_NUMBER_FORMATTER);
+ modelBuilder.newColumnForExport("amount", Entry.PROPERTY_AMOUNT, BIG_DECIMAL_FORMATTER);
+ modelBuilder.newColumnForExport("debit", Entry.PROPERTY_DEBIT, O_N_FORMATTER);
+ modelBuilder.newColumnForExport("detail", Entry.PROPERTY_DETAIL);
+ modelBuilder.newColumnForExport("position", Entry.PROPERTY_POSITION);
+ modelBuilder.newColumnForExport("voucher", Entry.PROPERTY_VOUCHER);
+ modelBuilder.newColumnForExport("description", Entry.PROPERTY_DESCRIPTION);
+ modelBuilder.newColumnForExport("lettering", Entry.PROPERTY_LETTERING);
+ modelBuilder.newColumnForExport("financialTransaction", Entry.PROPERTY_FINANCIAL_TRANSACTION, FINANCIAL_TRANSACTION_TO_FINANCIAL_TRANSACTION_ID_FORMATTER);
+
+ return (Iterable) modelBuilder.getColumnsForExport();
+ }
+
+ @Override
+ public Entry newEmptyInstance() {
+ return new EntryImpl();
+ }
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FinancialTransactionModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FinancialTransactionModel.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FinancialTransactionModel.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,37 @@
+package org.chorem.lima.business.ejb.csv;
+
+import org.chorem.lima.business.api.EntryBookService;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionImpl;
+import org.nuiton.csv.ExportModel;
+import org.nuiton.csv.ExportableColumn;
+import org.nuiton.csv.ModelBuilder;
+
+/**
+ * Created by davidcosse on 03/06/14.
+ */
+public class FinancialTransactionModel extends AbstractLimaModel<FinancialTransaction> implements ExportModel<FinancialTransaction> {
+
+ public FinancialTransactionModel(EntryBookService entryBookService) {
+ super(';');
+ AbstractLimaModel.entryBookService = entryBookService;
+ newMandatoryColumn("id", FinancialTransaction.PROPERTY_TOPIA_ID);
+ newOptionalColumn("transactionDate", FinancialTransaction.PROPERTY_TRANSACTION_DATE, DATE_PARSER);
+ newOptionalColumn("entryBook", FinancialTransaction.PROPERTY_ENTRY_BOOK, ENTRY_BOOK_CODE_TO_ENTRY_BOOK_PARSER);
+ }
+
+ @Override
+ public Iterable<ExportableColumn<FinancialTransaction, Object>> getColumnsForExport() {
+ ModelBuilder<FinancialTransaction> modelBuilder = new ModelBuilder<FinancialTransaction>();
+ modelBuilder.newColumnForExport("id", FinancialTransaction.PROPERTY_TOPIA_ID);
+ modelBuilder.newColumnForExport("transactionDate", FinancialTransaction.PROPERTY_TRANSACTION_DATE, DATE_FORMATTER);
+ modelBuilder.newColumnForExport("entryBook", FinancialTransaction.PROPERTY_ENTRY_BOOK, ENTRY_BOOK_TO_ENTRY_BOOK_CODE_FORMATTER);
+ return (Iterable) modelBuilder.getColumnsForExport();
+ }
+
+ @Override
+ public FinancialTransactionImpl newEmptyInstance() {
+ return new FinancialTransactionImpl();
+ }
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FiscalPeriodModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FiscalPeriodModel.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FiscalPeriodModel.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,34 @@
+package org.chorem.lima.business.ejb.csv;
+
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.entity.FiscalPeriodImpl;
+import org.nuiton.csv.ExportModel;
+import org.nuiton.csv.ExportableColumn;
+import org.nuiton.csv.ModelBuilder;
+
+/**
+ * Created by davidcosse on 03/06/14.
+ */
+public class FiscalPeriodModel extends AbstractLimaModel<FiscalPeriod> implements ExportModel<FiscalPeriod> {
+
+ public FiscalPeriodModel() {
+ super(';');
+ newMandatoryColumn("beginDate", FiscalPeriod.PROPERTY_BEGIN_DATE, DATE_PARSER);
+ newMandatoryColumn("endDate", FiscalPeriod.PROPERTY_END_DATE, DATE_PARSER);
+ newMandatoryColumn("locked", FiscalPeriod.PROPERTY_LOCKED, O_N_PARSER);
+ }
+
+ @Override
+ public Iterable<ExportableColumn<FiscalPeriod, Object>> getColumnsForExport() {
+ ModelBuilder<FiscalPeriod> modelBuilder = new ModelBuilder<FiscalPeriod>();
+ modelBuilder.newColumnForExport("beginDate", FiscalPeriod.PROPERTY_BEGIN_DATE, DATE_FORMATTER);
+ modelBuilder.newColumnForExport("endDate", FiscalPeriod.PROPERTY_END_DATE, DATE_FORMATTER);
+ modelBuilder.newColumnForExport("locked", FiscalPeriod.PROPERTY_LOCKED, O_N_FORMATTER);
+ return (Iterable) modelBuilder.getColumnsForExport();
+ }
+
+ @Override
+ public FiscalPeriod newEmptyInstance() {
+ return new FiscalPeriodImpl();
+ }
+}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/migration/DatabaseMigrationClass.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/migration/DatabaseMigrationClass.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/migration/DatabaseMigrationClass.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -26,10 +26,15 @@
import org.chorem.lima.entity.LimaCallaoTopiaPersistenceContext;
import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG;
+import org.nuiton.topia.persistence.TopiaApplicationContext;
+import org.nuiton.topia.persistence.TopiaMigrationService;
+import org.nuiton.topia.persistence.TopiaMigrationServiceException;
+import org.nuiton.topia.persistence.TopiaService;
import org.nuiton.topia.persistence.support.TopiaSqlSupport;
import org.nuiton.util.Version;
import java.util.List;
+import java.util.Map;
import java.util.Set;
public class DatabaseMigrationClass extends TopiaMigrationCallbackByClassNG<LimaCallaoTopiaPersistenceContext> {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0V0_5.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0V0_5.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0V0_5.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -32,6 +32,10 @@
public class MigrationV0V0_5 extends MigrationCallBackForVersion {
+ public MigrationV0V0_5() {
+ this.callBack = new DatabaseMigrationClass();
+ }
+
@Override
protected void prepareMigrationScript(TopiaPersistenceContext tx,
List queries,
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_6.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_6.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_6.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -47,6 +47,10 @@
/** Logger. */
private static final Log log = LogFactory.getLog(MigrationV0_6.class);
+ public MigrationV0_6() {
+ this.callBack = new DatabaseMigrationClass();
+ }
+
@Override
protected void prepareMigrationScript(TopiaPersistenceContext tx,
List queries,
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_8.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_8.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_8.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -22,6 +22,10 @@
/** Logger. */
private static final Log log = LogFactory.getLog(MigrationV0_8.class);
+ public MigrationV0_8() {
+ this.callBack = new DatabaseMigrationClass();
+ }
+
@Override
protected void prepareMigrationScript(TopiaPersistenceContext tx,
List queries,
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2014-06-10 13:23:09 UTC (rev 3827)
@@ -19,6 +19,7 @@
lima-business.defaultaccountingrules.missingentrybook=Can't block financialperiod / missing EntryBook in transactions
lima-business.document.account=
lima-business.document.accountnumber=Account N°
+lima-business.document.accounts=Accounts
lima-business.document.adress=
lima-business.document.adresssuite=
lima-business.document.amount=
@@ -38,10 +39,14 @@
lima-business.document.dateformat=%1$tm/%1$te/%1$tY
lima-business.document.debit=Debit
lima-business.document.description=Description
+lima-business.document.entries=Entries
+lima-business.document.entryBooks=Entry books
lima-business.document.entrybook=EntryBook
lima-business.document.entrybooks=
lima-business.document.entrybooktitle=%s\n%2$tB %2$tY
+lima-business.document.financialTransactions=Financial transactions
lima-business.document.financialstatement=FinancialStatement
+lima-business.document.fiscalPeriods=Fiscal periods
lima-business.document.generalentrybook=General EntryBook
lima-business.document.grossamount=Gross Amount
lima-business.document.label=Label
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2014-06-10 13:23:09 UTC (rev 3827)
@@ -19,6 +19,7 @@
lima-business.defaultaccountingrules.missingentrybook=Impossible de bloquer la période financière / il manque un journal dans une transaction (%1$te/%1$tm/%1$tY)
lima-business.document.account=Compte
lima-business.document.accountnumber=N° Compte
+lima-business.document.accounts=Comptes
lima-business.document.adress=Adresse
lima-business.document.adresssuite=Adresse - suite
lima-business.document.amount=Total
@@ -39,10 +40,14 @@
lima-business.document.dateformat=%1$te/%1$tm/%1$tY
lima-business.document.debit=Débit
lima-business.document.description=Description
+lima-business.document.entries=entrées
+lima-business.document.entryBooks=
lima-business.document.entrybook=Journal
lima-business.document.entrybooks=Journaux
lima-business.document.entrybooktitle=%s\n%2$tB %2$tY
+lima-business.document.financialTransactions=transactions financières
lima-business.document.financialstatement=Bilan et compte de résultat
+lima-business.document.fiscalPeriods=Périodes ficales
lima-business.document.generalentrybook=Journal Général
lima-business.document.grossamount=Brut
lima-business.document.label=Libellé
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -33,6 +33,7 @@
import java.util.Properties;
import java.util.UUID;
+import com.google.common.collect.Lists;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
@@ -41,10 +42,13 @@
import org.chorem.lima.business.accountingrules.TestAccountingRules;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
+import org.chorem.lima.business.api.EntryService;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.business.api.NewExportService;
+import org.chorem.lima.business.api.NewImportService;
import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
@@ -78,7 +82,7 @@
*/
public abstract class AbstractLimaTest {
- private static final Log log = LogFactory.getLog(AbstractLimaTest.class);
+ protected static final Log log = LogFactory.getLog(AbstractLimaTest.class);
protected static final Function<Properties, LimaCallaoTopiaApplicationContext> CREATE_CONTEXT_FUNCTION = new Function<Properties, LimaCallaoTopiaApplicationContext>() {
@Override
public LimaCallaoTopiaApplicationContext apply(Properties input) {
@@ -95,6 +99,9 @@
protected FiscalPeriodService fiscalPeriodService;
protected ReportService reportService;
protected ImportService importService;
+ protected EntryService entryService;
+ protected NewImportService newImportService;
+ protected NewExportService newExportService;
/**
* This is a before class method, but junit will fail to run inherited
@@ -119,13 +126,19 @@
* @throws IOException
*/
protected void initServices() throws IOException {
- accountService = LimaServiceFactory.getService(AccountService.class);
- entryBookService = LimaServiceFactory.getService(EntryBookService.class);
- financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
- financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class);
- fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
- reportService = LimaServiceFactory.getService(ReportService.class);
- importService = LimaServiceFactory.getService(ImportService.class);
+ if(accountService == null) {
+ accountService = LimaServiceFactory.getService(AccountService.class);
+ entryBookService = LimaServiceFactory.getService(EntryBookService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
+ financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class);
+ fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ reportService = LimaServiceFactory.getService(ReportService.class);
+ importService = LimaServiceFactory.getService(ImportService.class);
+ entryService = LimaServiceFactory.getService(EntryService.class);
+
+ newImportService = LimaServiceFactory.getService(NewImportService.class);
+ newExportService = LimaServiceFactory.getService(NewExportService.class);
+ }
}
/**
@@ -162,7 +175,7 @@
String testDir = System.getProperty("java.io.tmpdir") + File.separator + "lima-business-" + UUID.randomUUID().toString();
testProperties.setProperty(Option.DATA_DIR.getKey(), testDir);
testProperties.setProperty("hibernate.connection.url", "jdbc:h2:file:" + testDir + File.separator + "data");
- //testProperties.setProperty("hibernate.hbm2ddl.auto", "update");
+ testProperties.setProperty("hibernate.hbm2ddl.auto", "update");
instance.setOptions(testProperties);
instance.setOption("topia.persistence.classes", LimaCallaoEntityEnum.getImplementationClassesAsString());
@@ -179,7 +192,7 @@
}
@After
- public void cleanDatabase() throws IOException {
+ public void cleanDatabase() throws Exception {
LimaConfig config = LimaConfig.getInstance();
FileUtils.deleteDirectory(config.getDataDir());
}
@@ -197,7 +210,24 @@
}
/**
- * Create a basic database with some objects to reuse then in subtests.
+ * Method to use only for class that need a context to be tester.
+ * Only for DOA for now.
+ *
+ * @return a topia context
+ */
+ protected LimaCallaoTopiaApplicationContext getTestContext() {
+ LimaConfig config = LimaConfig.getInstance();
+ Properties options = config.getFlatOptions();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Opening context to database : " + options.getProperty("hibernate.connection.url"));
+ }
+ LimaCallaoTopiaApplicationContext result = TopiaApplicationContextCache.getContext(options, CREATE_CONTEXT_FUNCTION);
+ return result;
+ }
+
+ /**
+ * Create a basic database.
*
* Not called by default (<code>@Before</code>) to allow init test with
* CSV or EBP import.
@@ -205,23 +235,19 @@
* @throws LimaException
* @throws ParseException
*/
- protected void initTestDatabase() throws LimaException, ParseException {
+ protected void initTestDatabase() throws Exception {
- // clear database
-// clearService.clearDatabase();
getTestContext().createSchema();
- initTestAccounts();
- initTestTransactions();
}
/**
* Create a basic account plan.
- *
- * @throws LimaException
- * @throws ParseException
+ *
+ * @throws org.chorem.lima.business.LimaException
+ * @throws java.text.ParseException
*/
- protected void initTestAccounts() throws LimaException, ParseException {
+ protected void initTestWithAccounts() throws Exception {
// creation d'un plan compatble de test
Account classFinancier = new AccountImpl();
@@ -233,12 +259,12 @@
accountVmp.setAccountNumber("50");
accountVmp.setLabel("Valeurs mobilières de placement");
accountService.createAccount(accountVmp);
-
+
Account accountPel = new AccountImpl();
accountPel.setAccountNumber("501");
accountPel.setLabel("Parts dans des entreprises liées");
accountService.createAccount(accountPel);
-
+
Account accountAP = new AccountImpl();
accountAP.setAccountNumber("502");
accountAP.setLabel("Actions propres");
@@ -258,13 +284,48 @@
accountBanques.setAccountNumber("512");
accountBanques.setLabel("Banques");
accountService.createAccount(accountBanques);
-
+ }
+
+ /**
+ * Create some EntryBooks.
+ *
+ * @throws LimaException
+ * @throws ParseException
+ */
+ protected void initTestWithEntryBooks() throws Exception {
// creation d'un journal
EntryBook journalDesVentes = new EntryBookImpl();
journalDesVentes.setLabel("Journal des ventes");
journalDesVentes.setCode("jdv");
entryBookService.createEntryBook(journalDesVentes);
-
+
+ EntryBook journalDesAchats = new EntryBookImpl();
+ journalDesAchats.setLabel("Journal des achats");
+ journalDesAchats.setCode("jda");
+ entryBookService.createEntryBook(journalDesAchats);
+
+ EntryBook myEntryBook = new EntryBookImpl();
+ myEntryBook.setCode("JRN");
+ myEntryBook.setLabel("MyJournal");
+ entryBookService.createEntryBook(myEntryBook);
+
+ }
+
+ /**
+ * Create a FiscalPeriod with an EntryBook.
+ *
+ * @throws LimaException
+ * @throws ParseException
+ */
+ protected void initTestWithFiscalPeriod() throws Exception {
+ initTestWithAccounts();
+
+ // creation d'un journal
+ EntryBook journalDesVentes = new EntryBookImpl();
+ journalDesVentes.setLabel("Journal des ventes");
+ journalDesVentes.setCode("jdv");
+ entryBookService.createEntryBook(journalDesVentes);
+
// creation d'un exercice fiscal
FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
fiscalPeriod.setBeginDate(df.parse("January 1, 2012"));
@@ -273,16 +334,14 @@
}
/**
- * Create some transaction in previous accounts.
- *
- * @throws LimaException
- * @throws ParseException
+ * Create FinancialTransaction with 2 entries
+ * @throws Exception
*/
- protected void initTestTransactions() throws LimaException, ParseException {
- // add some transactions
- // FIXME echatellier 20120221 fix test, following instance already in current method
+ protected void initTestWithFinancialTransaction() throws Exception {
+
+ initTestWithFiscalPeriod();
+ Account accountVmpVae = accountService.getAccountByNumber("511");
EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv");
- Account accountVmpVae = accountService.getAccountByNumber("511");
FinancialTransaction transaction1 = new FinancialTransactionImpl();
transaction1.setTransactionDate(df.parse("April 4, 2012"));
@@ -295,8 +354,8 @@
tr1Entry1.setFinancialTransaction(transaction1);
tr1Entry1.setDescription("test desc");
tr1Entry1.setVoucher("voucher");
- financialTransactionService.createEntry(tr1Entry1);
-
+ tr1Entry1 = financialTransactionService.createEntry(tr1Entry1);
+
Entry tr1Entry2 = new EntryImpl();
tr1Entry2.setAmount(BigDecimal.valueOf(42.0));
tr1Entry2.setDebit(true);
@@ -304,23 +363,9 @@
tr1Entry2.setFinancialTransaction(transaction1);
tr1Entry2.setDescription("test desc");
tr1Entry2.setVoucher("voucher");
- financialTransactionService.createEntry(tr1Entry2);
- }
+ tr1Entry2 = financialTransactionService.createEntry(tr1Entry2);
- /**
- * Method to use only for class that need a context to be tester.
- * Only for DOA for now.
- *
- * @return a topia context
- */
- protected LimaCallaoTopiaApplicationContext getTestContext() {
- LimaConfig config = LimaConfig.getInstance();
- Properties options = config.getFlatOptions();
-
- if (log.isDebugEnabled()) {
- log.debug("Opening context to database : " + options.getProperty("hibernate.connection.url"));
- }
- LimaCallaoTopiaApplicationContext result = TopiaApplicationContextCache.getContext(options, CREATE_CONTEXT_FUNCTION);
- return result;
+ transaction1.setEntry(Lists.newArrayList(tr1Entry1, tr1Entry2));
+ financialTransactionService.updateFinancialTransaction(transaction1);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -47,7 +47,7 @@
@Before
public void initTest() throws Exception {
- initTestDatabase();
+ initTestWithAccounts();
}
/**
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -27,10 +27,16 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookImpl;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionImpl;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.entity.FiscalPeriodImpl;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import java.text.ParseException;
+
/**
* Tests pour la gestion des journaux.
* <p/>
@@ -45,7 +51,7 @@
@Before
public void initTest() throws Exception {
- initTestDatabase();
+ initTestWithEntryBooks();
}
/**
@@ -74,9 +80,22 @@
* @throws LimaException
*/
@Test(expected=LimaBusinessException.class)
- public void deleteUsedEntryBook() throws LimaException {
+ public void deleteUsedEntryBook() throws LimaException, ParseException {
EntryBook entryBook = entryBookService.getAllEntryBooks().get(0); // VTE
Assert.assertNotNull(entryBook);
+
+ // make transaction used
+ // creation d'un exercice fiscal
+ FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
+ fiscalPeriod.setBeginDate(df.parse("January 1, 2012"));
+ fiscalPeriod.setEndDate(df.parse("December 31, 2012"));
+ fiscalPeriodService.createFiscalPeriod(fiscalPeriod);
+
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ financialTransaction.setTransactionDate(df.parse("January 1, 2012"));
+ financialTransaction.setEntryBook(entryBook);
+ financialTransactionService.createFinancialTransaction(financialTransaction);
+
entryBookService.removeEntryBook(entryBook);
}
@@ -88,13 +107,15 @@
*/
@Test
public void deleteNonUsedEntryBookTest() throws LimaException {
+
EntryBook myEntryBook = new EntryBookImpl();
myEntryBook.setCode("JRN");
myEntryBook.setLabel("MyJournal");
myEntryBook = entryBookService.createEntryBook(myEntryBook);
+ int nbEntryBooks = entryBookService.getAllEntryBooks().size();
entryBookService.removeEntryBook(myEntryBook);
- Assert.assertEquals(1, entryBookService.getAllEntryBooks().size());
+ Assert.assertEquals(nbEntryBooks -1, entryBookService.getAllEntryBooks().size());
}
}
\ No newline at end of file
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -59,21 +59,23 @@
@Test
public void blockClosedPeriodicEntryBookTest() throws Exception {
+ initTestWithFinancialTransaction();
+
// find one closed to close
LimaCallaoTopiaPersistenceContext context = getTestContext().newPersistenceContext();
ClosedPeriodicEntryBookTopiaDao dao = context.getClosedPeriodicEntryBookDao();
ClosedPeriodicEntryBook closedPeriodic = dao.findAll().get(0);
- context.closeContext();
+ context.close();
// block it
Assert.assertFalse(closedPeriodic.isLocked());
- closedPeriodic = financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodic);
+ financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodic);
// check it's blocked
context = getTestContext().newPersistenceContext();
dao = context.getClosedPeriodicEntryBookDao();
closedPeriodic = dao.findAll().get(0);
- context.closeContext();
+ context.close();
Assert.assertFalse(closedPeriodic.isLocked());
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -53,8 +53,8 @@
public class FinancialTransactionServiceImplTest extends AbstractLimaTest {
@Before
- public void initTest() throws LimaException, ParseException {
- initTestDatabase();
+ public void initTest() throws Exception {
+ initTestWithFinancialTransaction();
}
/**
@@ -122,7 +122,7 @@
* @throws LimaException
*/
@Test
- public void testGetUnbalancedTransactionNotAllGood() throws ParseException, LimaException {
+ public void testGetUnbalancedTransactionNotAllGood() throws Exception {
EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv");
Account accountVmpVae = accountService.getAccountByNumber("511");
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -50,7 +50,6 @@
@Before
public void initTest() throws Exception {
- initTestDatabase();
}
/**
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -55,8 +55,6 @@
*/
protected void importEBPData() throws IOException, LimaException, ParseException {
- getTestContext().createSchema();
-
// create fiscal period (mandatory for import)
FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
fiscalPeriod.setBeginDate(df.parse("January 1, 2012"));
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,216 @@
+package org.chorem.lima.business;
+
+import com.google.common.collect.Lists;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.nio.charset.Charset;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Created by davidcosse on 03/06/14.
+ */
+public class NewExportServiceTest extends AbstractLimaTest {
+
+ @Test
+ public void testExportImportAccounts() throws Exception {
+ initTestWithFiscalPeriod();
+ // make sure they are some accounts.
+ List<Account> accounts = accountService.getAllAccounts();
+ Assert.assertTrue(accountService.getAllAccounts().size() > 0);
+
+
+ // export accounts
+ File file = newExportService.exportAccountsAsCSV("export-accounts.csv", Charset.defaultCharset().name());
+ log.info("Account File path:" + file.getAbsolutePath());
+
+ // remove accounts
+ int nbEntities = accounts.size();
+ for (Account account : accounts) {
+ accountService.removeAccount(account);
+ }
+ Assert.assertEquals(0, accountService.getAllAccounts().size());
+
+ // import accounts
+ FileInputStream contentStream = null;
+ try {
+ contentStream = new FileInputStream(file.getPath());
+ String stream = IOUtils.toString(contentStream);
+ newImportService.importAccountAsCSV(stream);
+
+ // make sure all account have been created
+ Assert.assertEquals(nbEntities, accountService.getAllAccounts().size());
+ } finally {
+ IOUtils.closeQuietly(contentStream);
+ FileUtils.forceDelete(file);
+ }
+
+
+ }
+
+ @Test
+ public void testExportImportEntryBooks() throws Exception {
+ initTestWithEntryBooks();
+ File file = newExportService.exportEntryBooksAsCSV("export-entry-books.csv", Charset.defaultCharset().name());
+ Assert.assertNotNull(file);
+
+ List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
+ int nbEntities = entryBooks.size();
+ Assert.assertEquals(3, nbEntities);
+
+ for (EntryBook entryBook : entryBooks) {
+ entryBookService.removeEntryBook(entryBook);
+ }
+
+ Assert.assertEquals(0, entryBookService.getAllEntryBooks().size());
+
+ FileInputStream contentStream = null;
+ try {
+ contentStream = new FileInputStream(file.getPath());
+ String stream = IOUtils.toString(contentStream);
+ newImportService.importEntryBooksAsCSV(stream);
+ } finally {
+ IOUtils.closeQuietly(contentStream);
+ }
+
+ Assert.assertEquals(nbEntities, entryBookService.getAllEntryBooks().size());
+ FileUtils.forceDelete(file);
+ }
+
+ @Test
+ public void testExportImportFinancialTransactions() throws Exception {
+ initTestWithFinancialTransaction();
+
+ File file = newExportService.exportFinancialTransactionsAsCSV("export-financial-transactions.csv", Charset.defaultCharset().name());
+ Assert.assertNotNull(file);
+
+ List<FinancialTransaction> financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("January 1, 2012"),df.parse("December 31, 2012"));
+ int nbEntities = financialTransactions.size();
+ Assert.assertEquals(1, nbEntities);
+
+ for (FinancialTransaction financialTransaction : financialTransactions) {
+ financialTransactionService.removeFinancialTransaction(financialTransaction);
+ }
+
+ Assert.assertEquals(0, financialTransactionService.getAllFinancialTransactions(df.parse("January 1, 2012"), df.parse("December 31, 2012")).size());
+
+ FileInputStream contentStream = null;
+ try {
+ contentStream = new FileInputStream(file.getPath());
+ String stream = IOUtils.toString(contentStream);
+ newImportService.importFinancialTransactionsAsCSV(stream);
+ } finally {
+ IOUtils.closeQuietly(contentStream);
+ }
+
+ Assert.assertEquals(nbEntities, financialTransactionService.getAllFinancialTransactions(df.parse("January 1, 2012"),df.parse("December 31, 2012")).size());
+ FileUtils.forceDelete(file);
+ }
+
+ @Test
+ public void testExportImportEntries() throws Exception {
+ initTestWithFinancialTransaction();
+
+ List<FinancialTransaction> financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("April 4, 2012"),df.parse("December 31, 2012"));
+ List<Entry> entries = Lists.newArrayList();
+ Assert.assertFalse(financialTransactions.isEmpty());
+ for (FinancialTransaction financialTransaction : financialTransactions) {
+ entries.addAll(financialTransaction.getEntry());
+ }
+ int nbEntities = entries.size();
+ Assert.assertEquals(2,nbEntities);
+
+ //test export
+ File file = newExportService.exportEntriesAsCSV("export-entries.csv", Charset.defaultCharset().name());
+ Assert.assertNotNull(file);
+
+
+ for (Entry entry : entries) {
+ FinancialTransaction financialTransaction = entry.getFinancialTransaction();
+ financialTransactionService.removeEntry(entry);
+ financialTransactionService.updateFinancialTransaction(financialTransaction);
+ }
+
+ // check all entries have been cleared
+ entries.clear();//
+
+ financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("April 4, 2012"),df.parse("December 31, 2012"));
+ for (FinancialTransaction financialTransaction : financialTransactions) {
+ entries.addAll(financialTransaction.getEntry());
+ }
+ Assert.assertTrue(entries.isEmpty());
+
+ // test import
+ FileInputStream contentStream = null;
+ try {
+ contentStream = new FileInputStream(file.getPath());
+ String stream = IOUtils.toString(contentStream);
+ newImportService.importEntriesAsCSV(stream);
+ } finally {
+ IOUtils.closeQuietly(contentStream);
+ }
+
+ // valid import
+ financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("April 4, 2012"),df.parse("December 31, 2012"));
+ Assert.assertEquals(1, financialTransactions.size());
+ for (FinancialTransaction financialTransaction : financialTransactions) {
+ entries.addAll(financialTransaction.getEntry());
+ }
+
+ Assert.assertEquals(nbEntities, entries.size());
+ FileUtils.forceDelete(file);
+ }
+
+ @Test
+ public void testExportImportFiscalPeriodsAsCSV() throws Exception {
+ initTestWithFiscalPeriod();
+ File file = newExportService.exportFiscalPeriodAsCSV("export-fiscal-periods.csv", Charset.defaultCharset().name());
+ Assert.assertNotNull(file);
+
+
+ List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllFiscalPeriods();
+ int nbEntities = fiscalPeriods.size();
+ Assert.assertEquals(1, nbEntities);
+
+ initAbstractTest();
+
+ Assert.assertEquals(0, fiscalPeriodService.getAllFiscalPeriods().size());
+
+ FileInputStream contentStream = null;
+ try {
+ contentStream = new FileInputStream(file.getPath());
+ String stream = IOUtils.toString(contentStream);
+ newImportService.importFiscalPeriodsAsCSV(stream);
+ } finally {
+ IOUtils.closeQuietly(contentStream);
+ }
+
+ Assert.assertEquals(nbEntities, fiscalPeriodService.getAllFiscalPeriods().size());
+ FileUtils.forceDelete(file);
+ }
+
+ @Test
+ public void exportAllAsCSVTest() throws Exception {
+ initTestWithFinancialTransaction();
+ String tmpDir = System.getProperty("java.io.tmpdir")+"/";
+ String path = newExportService.exportAllAsCSV(tmpDir, "UTF-8");
+
+ initAbstractTest();
+
+ Collection<FinancialTransaction> financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("January 1, 2012"),df.parse("December 31, 2012"));
+ Assert.assertTrue(financialTransactions.isEmpty());
+
+ newImportService.importAllAsCSV(path);
+ FileUtils.deleteDirectory(new File(tmpDir));
+ }
+}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -51,7 +51,7 @@
@Before
public void initTest() throws Exception {
- initTestDatabase();
+ initTestWithFinancialTransaction();
}
/**
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -63,18 +63,4 @@
Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules);
}
- /**
- * Création d'un compte dans le plan comptable.
- *
- * @throws LimaException
- */
- @Ignore
- @Test(expected=LimaException.class)
- public void testCreateAccountWrongStart() throws LimaException {
- // TODO DCossé 17/02/14 this test is no more valid as count with account number with letters are now accepted
- // there is just a warning about it
- Account myAccount = new AccountImpl();
- myAccount.setAccountNumber("10TEST");
- accountService.createAccount(myAccount);
- }
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -76,8 +76,7 @@
//check the new fiscal period adjoining the last
Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
- dateLastFiscalPeriod = DateUtils.
- addDays(dateLastFiscalPeriod, 1);
+ dateLastFiscalPeriod = DateUtils.addDays(dateLastFiscalPeriod, 1);
dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
@@ -86,8 +85,7 @@
//We can create a new fiscal period meantime the last fiscal period was not locked
//But not the ante periodfiscal
- int unblockedFiscalPeriod =
- fiscalPeriodDAO.findAllByLocked(false).size();
+ int unblockedFiscalPeriod = fiscalPeriodDAO.forLockedEquals(false).findAll().size();
if (unblockedFiscalPeriod > 1) {
throw new LimaBusinessException(t("lima-business.franceaccountingrules.antefiscalperiodnotblocked"));
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -52,9 +52,11 @@
* @throws TopiaException
*/
@Test
- public void testStringToListAccounts() throws TopiaException {
+ public void testStringToListAccounts() throws Exception {
LimaCallaoTopiaPersistenceContext context = getTestContext().newPersistenceContext();
+ initTestWithAccounts();
+
AccountTopiaDao accountDAO = context.getAccountDao();
List<Account> accounts = accountDAO.stringToListAccounts("50..511", false);
@@ -63,6 +65,6 @@
accounts = accountDAO.stringToListAccounts("60..99", false);
Assert.assertEquals(0, accounts.size());
- context.closeContext();
+ context.close();
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -53,8 +53,10 @@
* @throws LimaException
*/
@Test
- public void testFindAllUnbalancedTransactions() throws TopiaException, LimaException {
+ public void testFindAllUnbalancedTransactions() throws Exception {
+ initTestWithFinancialTransaction();
+
FinancialPeriod financialPeriod = financialPeriodService.getAllFinancialPeriods().get(0);
EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv");
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -56,6 +56,8 @@
void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+ FinancialTransaction getFinancialTransactionWithId(String id) throws LimaException;
+
List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period) throws LimaException;
List<FinancialTransaction> getAllFinancialTransactions(Date beginDate, Date endDate) throws LimaException;
Copied: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java (from rev 3825, trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java)
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,56 @@
+/*
+ * #%L
+ * Lima business
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.business.api;
+
+import org.chorem.lima.business.LimaException;
+
+import java.io.File;
+
+/**
+ * Import export service.
+ * <p/>
+ * Currently import and export as XML.
+ *
+ * @author chatellier
+ * @version $Revision$
+ * <p/>
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface NewExportService {
+
+ String exportAllAsCSV(String path, String charset) throws LimaException;
+
+ File exportAccountsAsCSV(String path, String charset) throws LimaException;
+
+ File exportEntryBooksAsCSV(String path, String charset) throws LimaException;
+
+ File exportFiscalPeriodAsCSV(String path, String charset) throws LimaException;
+
+ File exportFinancialTransactionsAsCSV(String path, String charset) throws LimaException;
+
+ File exportEntriesAsCSV(String path, String charset) throws LimaException;
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -0,0 +1,21 @@
+package org.chorem.lima.business.api;
+
+import org.chorem.lima.business.LimaException;
+
+/**
+ * Created by davidcosse on 03/06/14.
+ */
+public interface NewImportService {
+
+ void importAccountAsCSV(String contents) throws LimaException;
+
+ void importEntryBooksAsCSV(String contents) throws LimaException;
+
+ void importFiscalPeriodsAsCSV(String contents) throws LimaException;
+
+ void importFinancialTransactionsAsCSV(String contents) throws LimaException;
+
+ void importEntriesAsCSV(String contents) throws LimaException;
+
+ void importAllAsCSV(String contents) throws LimaException;
+}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/DefaultServiceContext.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/DefaultServiceContext.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/DefaultServiceContext.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -46,7 +46,7 @@
// try to close non closed persistence context (false to not reopen it)
AbstractTopiaPersistenceContext context = getPersistenceContext(false);
if (context != null) {
- context.closeContext();
+ context.close();
}
}
@@ -97,11 +97,6 @@
}
@Override
- public void closeContext() {
-
- }
-
- @Override
public boolean isClosed() {
return false;
}
Modified: trunk/lima-callao/src/main/xmi/accounting-model.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting-model.properties 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-callao/src/main/xmi/accounting-model.properties 2014-06-10 13:23:09 UTC (rev 3827)
@@ -61,3 +61,6 @@
org.chorem.lima.entity.VatStatement.attribute.subVatStatements.tagvalue.lazy=false
org.chorem.lima.entity.VatStatement.attribute.masterVatStatement.tagvalue.lazy=false
+
+org.chorem.lima.entity.EntryBook.attribute.code.tagvalue.naturalId=true
+org.chorem.lima.entity.EntryBook.attribute.code.tagvalue.notNull=true
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -41,6 +41,7 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
+import java.nio.charset.Charset;
import java.util.concurrent.ExecutionException;
import javax.swing.JComboBox;
@@ -50,6 +51,7 @@
import javax.swing.JPanel;
import javax.swing.SwingWorker;
+import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
@@ -57,6 +59,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.api.ExportService;
import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.business.api.NewExportService;
import org.chorem.lima.business.utils.ImportExportEntityEnum;
import org.chorem.lima.enums.EncodingEnum;
import org.chorem.lima.enums.ImportExportEnum;
@@ -86,6 +89,8 @@
protected ExportService exportService;
+ protected NewExportService newExportService;
+
private ImportExportWaitView waitView;
public ImportExport(Component view) {
@@ -94,6 +99,7 @@
//services
importService = LimaServiceFactory.getService(ImportService.class);
exportService = LimaServiceFactory.getService(ExportService.class);
+ newExportService = LimaServiceFactory.getService(NewExportService.class);
//create the wait dialog panel
waitView = new ImportExportWaitView();
@@ -113,13 +119,12 @@
*/
public void importExport(ImportExportEnum importExportMethode, String file, boolean verbose) {
final ImportExportEnum importExportMethodeF = importExportMethode;
- encodingEnum = EncodingEnum.UTF8;
+ final Charset charset = Charsets.UTF_8;
if (Strings.isNullOrEmpty(file)) {
file = chooseFile(importExportMethode.getImportMode(), importExportMethode);
}
//if export cancel
if (!Strings.isNullOrEmpty(file)) {
- final EncodingEnum charset = encodingEnum;
final String filePath = file;
final Boolean verboseMode = verbose;
final Boolean importMode = importExportMethode.getImportMode();
@@ -130,24 +135,23 @@
String result = "";
switch (importExportMethodeF) {
case CSV_ALL_EXPORT:
- datas = exportService.exportAsCSV();
- createFile(filePath, charset.getEncoding(), datas);
+ newExportService.exportAllAsCSV(filePath, charset.name());
break;
case CSV_ACCOUNTCHARTS_EXPORT:
datas = exportService.exportAccountsChartAsCSV();
- createFile(filePath, charset.getEncoding(), datas);
+ createFile(filePath, charset.name(), datas);
break;
case CSV_ENTRYBOOKS_EXPORT:
datas = exportService.exportEntryBookChartAsCSV();
- createFile(filePath, charset.getEncoding(), datas);
+ createFile(filePath, charset.name(), datas);
break;
case CSV_FINANCIALSTATEMENTS_EXPORT:
datas = exportService.exportFinancialStatementChartAsCSV();
- createFile(filePath, charset.getEncoding(), datas);
+ createFile(filePath, charset.name(), datas);
break;
case CSV_VAT_EXPORT:
datas = exportService.exportVatStatementChartAsCSV();
- createFile(filePath, charset.getEncoding(), datas);
+ createFile(filePath, charset.name(), datas);
break;
case EBP_ACCOUNTCHARTS_EXPORT:
//For windows ebp
@@ -160,34 +164,34 @@
createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
break;
case CSV_ALL_IMPORT:
- datas = extractFile(filePath, charset.getEncoding());
+ datas = extractFile(filePath, charset.name());
result = importService.importAllAsCSV(datas);
break;
case CSV_ACCOUNTCHARTS_IMPORT:
- datas = extractFile(filePath, charset.getEncoding());
+ datas = extractFile(filePath, charset.name());
result = importService.importAsCSV(datas, ImportExportEntityEnum.ACCOUNT);
break;
case CSV_ENTRYBOOKS_IMPORT:
- datas = extractFile(filePath, charset.getEncoding());
+ datas = extractFile(filePath, charset.name());
result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRYBOOK);
break;
case CSV_FINANCIALSTATEMENTS_IMPORT:
- datas = extractFile(filePath, charset.getEncoding());
+ datas = extractFile(filePath, charset.name());
result = importService.importAsCSV(datas, ImportExportEntityEnum.FINANCIALSTATEMENT);
break;
case CSV_VAT_IMPORT:
- datas = extractFile(filePath, charset.getEncoding());
+ datas = extractFile(filePath, charset.name());
result = importService.importAsCSV(datas, ImportExportEntityEnum.VATSTATEMENT);
break;
case CSV_ENTRIES_IMPORT:
- datas = extractFile(filePath, charset.getEncoding());
+ datas = extractFile(filePath, charset.name());
result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRY);
break;
case PDF_VAT_IMPORT:
int response = JOptionPane.showConfirmDialog(waitView,
t("lima.importexport.usevatpdf"),
t("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
- extractFile(filePath, charset.getEncoding());
+ extractFile(filePath, charset.name());
result = importService.importAsPDF(filePath, ImportExportEntityEnum.VATPDF, response == JOptionPane.YES_OPTION);
break;
case EBP_ACCOUNTCHARTS_IMPORT:
@@ -297,34 +301,41 @@
//Encoding option
JComboBox comboBox = new JComboBox(EncodingEnum.descriptions());
- if (importExportMethode.getEncodingOption()) {
- JPanel panel = new JPanel();
- panel.setLayout(new BorderLayout());
- panel.add(new JLabel(t("lima.importexport.choiceencoding")), BorderLayout.WEST);
- panel.add(comboBox, BorderLayout.CENTER);
- ((Container) chooser.getComponent(2)).add(panel, BorderLayout.SOUTH);
- }
- String approveButtonText;
- if (importMode) {
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- approveButtonText = t("lima.ui.importexport.import");
- chooser.setDialogTitle(approveButtonText);
- chooser.setApproveButtonText(approveButtonText);
+ if(importExportMethode.equals(ImportExportEnum.CSV_ALL_EXPORT)){
+
} else {
- approveButtonText = t("lima.ui.importexport.export");
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- chooser.setDialogTitle(approveButtonText);
- chooser.setApproveButtonText(approveButtonText);
- }
- if (chooser.showOpenDialog(viewComponent) == JFileChooser.APPROVE_OPTION) {
- filePath = chooser.getSelectedFile().getAbsolutePath();
-
if (importExportMethode.getEncodingOption()) {
- encodingEnum = EncodingEnum.valueOfDescription((String) comboBox.getSelectedItem());
+ JPanel panel = new JPanel();
+ panel.setLayout(new BorderLayout());
+ panel.add(new JLabel(t("lima.importexport.choiceencoding")), BorderLayout.WEST);
+ panel.add(comboBox, BorderLayout.CENTER);
+ ((Container) chooser.getComponent(2)).add(panel, BorderLayout.SOUTH);
}
+
+ String approveButtonText;
+ if (importMode) {
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ approveButtonText = t("lima.ui.importexport.import");
+ chooser.setDialogTitle(approveButtonText);
+ chooser.setApproveButtonText(approveButtonText);
+ } else {
+ approveButtonText = t("lima.ui.importexport.export");
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ chooser.setDialogTitle(approveButtonText);
+ chooser.setApproveButtonText(approveButtonText);
+ }
+ if (chooser.showOpenDialog(viewComponent) == JFileChooser.APPROVE_OPTION) {
+ filePath = chooser.getSelectedFile().getAbsolutePath();
+
+ if (importExportMethode.getEncodingOption()) {
+ encodingEnum = EncodingEnum.valueOfDescription((String) comboBox.getSelectedItem());
+ }
+ }
}
+
+
return filePath;
}
@@ -362,30 +373,20 @@
* @return
*/
public String extractFile(String filePath, String charset) {
- StringWriter sw = new StringWriter();
- BufferedReader in = null;
+ String result = null;
+ InputStream is = null;
try {
- InputStream is;
+ is = new FileInputStream(filePath);
+ result = IOUtils.toString(is, charset);
- // FIXME echatellier 20101129 remove this hack and modify resources reading mecanism
- if (filePath != null && filePath.indexOf(".jar!") > 0) {
- String resourcesPath = filePath.substring(filePath.indexOf(".jar!") + 5);
- is = ImportExport.class.getResourceAsStream(resourcesPath);
- } else {
- is = new FileInputStream(filePath);
- }
-
- in = new BufferedReader(new InputStreamReader(is, charset));
- IOUtils.copy(in, sw);
- in.close();
} catch (IOException eee) {
if (log.isErrorEnabled()) {
log.error("Can't read file " + filePath, eee);
}
} finally {
- IOUtils.closeQuietly(in);
+ IOUtils.closeQuietly(is);
}
- return sw.toString();
+ return result;
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2014-06-10 13:23:09 UTC (rev 3827)
@@ -108,7 +108,7 @@
/* @Override
public void notifyMethod(String serviceName, String methodName) {
if (serviceName.contains("FinancialTransaction") ||
- methodName.contains("importAccount") ||
+ methodName.contains("importAccountAsCSV") ||
methodName.contains("importAll")) {
refreshData();
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-06-03 09:36:17 UTC (rev 3826)
+++ trunk/pom.xml 2014-06-10 13:23:09 UTC (rev 3827)
@@ -167,7 +167,8 @@
<nuitonConfigVersion>3.0-alpha-2</nuitonConfigVersion>
<nuitonDecoratorVersion>3.0-alpha-3</nuitonDecoratorVersion>
<nuitonProfilingVersion>2.7.1</nuitonProfilingVersion>
- <eugeneVersion>2.9</eugeneVersion>
+ <nuitonCsvVersion>3.0-rc-1</nuitonCsvVersion>
+ <eugeneVersion>2.10</eugeneVersion>
<nuitonI18nVersion>3.1</nuitonI18nVersion>
<topiaVersion>3.0-SNAPSHOT</topiaVersion>
@@ -323,6 +324,12 @@
</dependency>
<dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-csv</artifactId>
+ <version>${nuitonCsvVersion}</version>
+ </dependency>
+
+ <dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2Version}</version>
1
0
03 Jun '14
See <http://ci.chorem.org/jenkins/job/lima-nightly/22/changes>
Changes:
[echatellier] fixes #1026: Update to openejb 4.6.0.2
------------------------------------------
[...truncated 770 lines...]
[INFO] Copying serp-1.14.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying activemq-broker-5.9.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying xbean-bundleutils-3.15.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openwebbeans-el22-1.2.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openejb-loader-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying activemq-protobuf-1.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-dbcp-1.4.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying nuiton-decorator-3.0-alpha-3.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying h2-1.3.176.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying hawtbuf-1.9.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openejb-api-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying bval-core-0.5.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-jxpath-1.3.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jaxb-impl-2.2.6.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jetty-util-8.1.14.v20131031.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openwebbeans-ee-common-1.2.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying activemq-openwire-legacy-5.9.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying nuiton-config-3.0-alpha-2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-logging-1.1.3.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jboss-transaction-api_1.2_spec-1.0.0.Final.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying activemq-jdbc-store-5.9.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying activemq-client-5.9.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-cli-1.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying bval-jsr303-0.5.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying nuiton-utils-3.0-rc-2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying junit-4.11.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying mbean-annotation-api-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying geronimo-transaction-3.1.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jetty-server-8.1.14.v20131031.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jboss-logging-3.1.3.GA.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying topia-persistence-2.9-rc-1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying xbean-naming-3.15.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jboss-logging-annotations-1.2.0.Beta1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jandex-1.1.0.Final.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying xbean-finder-shaded-3.15.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openwebbeans-ejb-1.2.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jansi-1.8.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openejb-ejbd-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying ehcache-core-2.4.3.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying pdfbox-1.8.4.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jetty-http-8.1.14.v20131031.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-io-2.4.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying dom4j-1.6.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying topia-service-migration-2.9-rc-1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-primitives-1.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying fontbox-1.8.4.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openwebbeans-web-1.2.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jetty-continuation-8.1.14.v20131031.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying javax.servlet-3.0.0.v201112011016.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying lima-business-api-0.8-SNAPSHOT.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-pool-1.5.7.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openejb-jee-accessors-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying sxc-jaxb-core-0.8.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying swizzle-stream-1.6.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openejb-jee-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jetty-security-8.1.14.v20131031.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-lang-2.6.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying hsqldb-2.3.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying quartz-2.2.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying howl-1.0.1-1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jempbox-1.8.4.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying slf4j-api-1.7.7.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jetty-io-8.1.14.v20131031.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openjpa-2.3.0-nonfinal-1540826.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying log4j-1.2.17.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openejb-server-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying xml-apis-1.0.b2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying activemq-ra-5.9.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying antlr-2.7.7.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying javaee-api-6.0-5.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openwebbeans-spi-1.2.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying hibernate-commons-annotations-4.0.4.Final.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying xbean-reflect-3.15.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying nuiton-i18n-3.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying geronimo-connector-3.1.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying hibernate-ehcache-4.3.5.Final.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-beanutils-1.9.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying geronimo-javamail_1.4_mail-1.8.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying sxc-runtime-0.8.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openejb-core-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying slf4j-log4j12-1.7.7.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-collections4-4.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying xbean-asm4-shaded-3.15.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-lang3-3.3.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying hamcrest-core-1.3.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openejb-jpa-integration-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openejb-javaagent-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying commons-collections-3.2.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openejb-client-4.6.0.2.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying guava-16.0.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying geronimo-j2ee-connector_1.6_spec-1.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openwebbeans-impl-1.2.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying hibernate-jpa-2.1-api-1.0.0.Final.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying nuiton-csv-3.0-alpha-3.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying javacsv-2.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying opencsv-2.3.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying openwebbeans-ee-1.2.1.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying jetty-servlet-8.1.14.v20131031.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying activemq-kahadb-store-5.9.0.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Copying hibernate-core-4.3.5.Final.jar to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO]
[INFO] --- license-maven-plugin:1.6:update-project-license (attach-licenses) @ lima-business ---
[INFO]
[INFO] --- license-maven-plugin:1.6:add-third-party (attach-licenses) @ lima-business ---
[WARNING] No license name defined for org.apache.xbean--xbean-asm4-shaded--3.15
[WARNING] No license name defined for org.apache.xbean--xbean-asm4-shaded--3.15
[INFO] Load missing file <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/src/li…>
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/mbea…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/mbean-annotation-api…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/open…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/openejb-api/4.6.0.2/…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/open…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/openejb-client/4.6.0…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/open…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/openejb-core/4.6.0.2…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/open…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/openejb-ejbd/4.6.0.2…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/open…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/openejb-javaagent/4.…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/open…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/openejb-jee/4.6.0.2/…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/open…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/openejb-jee-accessor…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/open…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/openejb-jpa-integrat…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/open…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/openejb-loader/4.6.0…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/apache/openejb/open…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/openejb/openejb-server/4.6.0…
[INFO] Detects third party descriptor <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business-api/sr…>
[INFO] Load missing file <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business-api/sr…>
[INFO] Detects third party descriptor <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-callao/src/lice…>
[INFO] Load missing file <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-callao/src/lice…>
[INFO] Detects third party descriptor /var/local/forge/data/chorem.org/maven/repository/org/nuiton/nuiton-config/3.0-alpha-2/nuiton-config-3.0-alpha-2-third-party.properties
[INFO] Load missing file /var/local/forge/data/chorem.org/maven/repository/org/nuiton/nuiton-config/3.0-alpha-2/nuiton-config-3.0-alpha-2-third-party.properties
[INFO] Detects third party descriptor /var/local/forge/data/chorem.org/maven/repository/org/nuiton/nuiton-csv/3.0-alpha-3/nuiton-csv-3.0-alpha-3-third-party.properties
[INFO] Load missing file /var/local/forge/data/chorem.org/maven/repository/org/nuiton/nuiton-csv/3.0-alpha-3/nuiton-csv-3.0-alpha-3-third-party.properties
[INFO] Detects third party descriptor /var/local/forge/data/chorem.org/maven/repository/org/nuiton/nuiton-utils/3.0-rc-2/nuiton-utils-3.0-rc-2-third-party.properties
[INFO] Load missing file /var/local/forge/data/chorem.org/maven/repository/org/nuiton/nuiton-utils/3.0-rc-2/nuiton-utils-3.0-rc-2-third-party.properties
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/nui…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/i18n/nuiton-…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/nuiton/i18n/nuiton-i18n/3.1/nuiton-…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/nui…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/nui… (3 KB at 50.4 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-… (3 KB at 79.5 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/nuiton/topia/topia-persistence/2.9-…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/nuiton/topia/topia-persistence/2.9-… (3 KB at 6.6 KB/sec)
[INFO] Detects third party descriptor /var/local/forge/data/chorem.org/maven/repository/org/nuiton/topia/topia-persistence/2.9-rc-1/topia-persistence-2.9-rc-1-third-party.properties
[INFO] Load missing file /var/local/forge/data/chorem.org/maven/repository/org/nuiton/topia/topia-persistence/2.9-rc-1/topia-persistence-2.9-rc-1-third-party.properties
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/nui…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/nui… (2 KB at 12.0 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-… (2 KB at 85.2 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/nuiton/topia/topia-service-migratio…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/nuiton/topia/topia-service-migratio… (2 KB at 6.8 KB/sec)
[INFO] Detects third party descriptor /var/local/forge/data/chorem.org/maven/repository/org/nuiton/topia/topia-service-migration/2.9-rc-1/topia-service-migration-2.9-rc-1-third-party.properties
[INFO] Load missing file /var/local/forge/data/chorem.org/maven/repository/org/nuiton/topia/topia-service-migration/2.9-rc-1/topia-service-migration-2.9-rc-1-third-party.properties
[INFO] Missing file <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/src/li…> is up-to-date.
[WARNING] There is 2 dependencies with no license :
[WARNING] - org.metatype.sxc--sxc-jaxb-core--0.8
[WARNING] - org.metatype.sxc--sxc-runtime--0.8
[INFO] Writing third-party file to <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/target…>
[INFO] Regenerate missing license file <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/src/li…>
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Lima .............................................. SUCCESS [ 11.754 s]
[INFO] Lima :: callao .................................... SUCCESS [ 22.440 s]
[INFO] Lima :: business API .............................. SUCCESS [ 4.175 s]
[INFO] Lima :: business .................................. FAILURE [ 36.549 s]
[INFO] Lima :: Swing ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:17 min
[INFO] Finished at: 2014-05-15T00:55:57+01:00
[INFO] Final Memory: 84M/1009M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.codehaus.mojo:license-maven-plugin:1.6:add-third-party (attach-licenses) on project lima-business: There is some dependencies with no license, please fill the file <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/src/li…> -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:license-maven-plugin:1.6:add-third-party (attach-licenses) on project lima-business: There is some dependencies with no license, please fill the file <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/src/li…>
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.plugin.MojoFailureException: There is some dependencies with no license, please fill the file <http://ci.chorem.org/jenkins/job/lima-nightly/ws/trunk/lima-business/src/li…>
at org.codehaus.mojo.license.AddThirdPartyMojo.doAction(AddThirdPartyMojo.java:253)
at org.codehaus.mojo.license.AbstractLicenseMojo.execute(AbstractLicenseMojo.java:207)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 30 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :lima-business
Failed to send e-mail to echatellier because no e-mail address is known, and no default e-mail domain is configured
Sending e-mails to: lima-commits(a)list.chorem.org
channel stopped
Skipping sonar analysis due to bad build status FAILURE
Failed to send e-mail to echatellier because no e-mail address is known, and no default e-mail domain is configured
1
7
Build failed in Jenkins: lima-nightly » Lima :: callao #29
by admin+ci-chorem.org@codelutin.com 03 Jun '14
by admin+ci-chorem.org@codelutin.com 03 Jun '14
03 Jun '14
See <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/2…>
------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Lima :: callao 0.8-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top… (2 KB at 8.7 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-… (2 KB at 3.7 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top… (4 KB at 144.1 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-… (4 KB at 138.4 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/3.0-SN…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top… (806 B at 30.3 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/3.0-SN… (806 B at 5.4 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top… (15 KB at 511.0 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/nui…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/nui… (2 KB at 42.0 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (2 KB at 9.7 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top… (207 KB at 3030.0 KB/sec)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ lima-callao ---
[INFO] Deleting <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (ensure-no-container-api) @ lima-callao ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ lima-callao ---
[INFO]
[INFO] --- helper-maven-plugin:2.1:share-server-secret (get-redmine-login) @ lima-callao ---
[INFO] Exporting server [redmine-forge.chorem.org] privateKey in ${redmine.apiKey}
[INFO]
[INFO] --- eugene-maven-plugin:2.9:generate (generate-entities) @ lima-callao ---
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top… (2 KB at 31.9 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-… (2 KB at 7.6 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top… (6 KB at 222.4 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/topia/topia-… (6 KB at 213.5 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/top… (97 KB at 2185.7 KB/sec)
[INFO] Process phase [zargo]
[INFO] Generate one file in 38.36ms.
[INFO] Process phase [xmi]
[INFO] Generate one file in 1.843s.
[INFO] Process phase [model]
WARN [pool-1-thread-1 for channel] (AbstractObjectModelReader.java:340) loadModelTagValue - Invalid model tag value [model.tagvalue.copyright] : the tagvalue 'copyright' is unknown.
[INFO] Process phase [generator]
[INFO] Apply generator TopiaMetaTransformer
WARN [pool-1-thread-1 for channel] (TopiaMetaTransformer.java:110) validateModel - [VALIDATION] [getHeaderAmount([])<<[]>> throws [] tagvalue: {}] Operation name getHeaderAmount is already reserved for a getter of an entity attribute
WARN [pool-1-thread-1 for channel] (TopiaMetaTransformer.java:110) validateModel - [VALIDATION] [getSubAmount([])<<[]>> throws [] tagvalue: {}] Operation name getSubAmount is already reserved for a getter of an entity attribute
WARN [pool-1-thread-1 for channel] (TopiaMetaTransformer.java:110) validateModel - [VALIDATION] [org.chorem.lima.beans.FinancialTransactionSearch#account] Cet attribut n'a pas d'inverse.
WARN [pool-1-thread-1 for channel] (TopiaMetaTransformer.java:110) validateModel - [VALIDATION] [org.chorem.lima.beans.FinancialTransactionSearch#entryBook] Cet attribut n'a pas d'inverse.
WARN [pool-1-thread-1 for channel] (TopiaMetaTransformer.java:110) validateModel - [VALIDATION] [org.chorem.lima.beans.FinancialTransactionSearch#amountWayEnum] Cet attribut n'a pas d'inverse.
WARN [pool-1-thread-1 for channel] (TopiaMetaTransformer.java:110) validateModel - [VALIDATION] [org.chorem.lima.beans.LetteringFilter#account] Cet attribut n'a pas d'inverse.
WARN [pool-1-thread-1 for channel] (TopiaMetaTransformer.java:110) validateModel - [VALIDATION] [org.chorem.lima.entity.FinancialStatement#way] Cet attribut n'a pas d'inverse.
WARN [pool-1-thread-1 for channel] (TopiaMetaTransformer.java:110) validateModel - [VALIDATION] [org.chorem.lima.beans.ReportsDatas#account] Cet attribut n'a pas d'inverse.
[INFO] Apply generator EntityTransformer
[INFO] Apply generator JavaBeanTransformer
[INFO] Generate 128 files in 524.479ms.
[INFO]
[INFO] --- license-maven-plugin:1.7:update-project-license (attach-licenses) @ lima-callao ---
[INFO]
[INFO] --- license-maven-plugin:1.7:add-third-party (attach-licenses) @ lima-callao ---
[INFO] Load missing file <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>
[INFO] Missing file <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…> is up-to-date.
[INFO] Writing third-party file to <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>
[INFO] Will attach third party file from <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lima-callao ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 2 resources
[INFO] Copying 10 resources
[INFO] Copying 2 resources
[INFO]
[INFO] --- license-maven-plugin:1.7:update-file-header (update-file-header) @ lima-callao ---
[INFO] Will search files to update from root <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>
[INFO] Will search files to update from root <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>
[INFO] Scan 159 files header done in 224.06ms.
[INFO]
* uptodate header on 56 files.
* add header on 103 files.
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ lima-callao ---
[INFO] Compiling 145 source files to <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING] bootstrap class path not set in conjunction with -source 1.6
[WARNING] <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>: Recompile with -Xlint:unchecked for details.
[INFO] 3 warnings
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>:[49,20] cannot find symbol
symbol: method closeContext()
location: variable context of type org.nuiton.topia.persistence.internal.AbstractTopiaPersistenceContext
[ERROR] <http://ci.chorem.org/jenkins/job/lima-nightly/org.chorem.lima$lima-callao/w…>:[99,5] method does not override or implement a method from a supertype
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[JENKINS] Archiving disabled
1
0