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
- 1853 discussions
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
Author: echatellier
Date: 2014-06-03 11:36:17 +0200 (Tue, 03 Jun 2014)
New Revision: 3826
Url: http://forge.chorem.org/projects/lima/repository/revisions/3826
Log:
Fix snapshot name in lib/ directory
Modified:
trunk/lima-swing/pom.xml
Modified: trunk/lima-swing/pom.xml
===================================================================
--- trunk/lima-swing/pom.xml 2014-06-02 09:26:13 UTC (rev 3825)
+++ trunk/lima-swing/pom.xml 2014-06-03 09:36:17 UTC (rev 3826)
@@ -302,6 +302,7 @@
<overWriteIfNewer>true</overWriteIfNewer>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<silent>true</silent>
+ <useBaseVersion>false</useBaseVersion>
</configuration>
</execution>
</executions>
1
0