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
March 2010
- 2 participants
- 29 discussions
r2811 - in trunk/lima-business/src/main/java/org/chorem/lima/business: . ejb
by echatellier@users.chorem.org 23 Mar '10
by echatellier@users.chorem.org 23 Mar '10
23 Mar '10
Author: echatellier
Date: 2010-03-23 16:26:54 +0100 (Tue, 23 Mar 2010)
New Revision: 2811
Log:
Move service implementation into subfolder.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.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/FilesServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/JournalServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/LogServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/PeriodServiceImpl.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/TimeSpanServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java
Removed:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/EntryServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FilesServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/JournalServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LogServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/PeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/TimeSpanServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/UserServiceImpl.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -18,10 +18,12 @@
package org.chorem.lima.business;
+import java.util.List;
+
import org.chorem.lima.entity.Account;
/**
- * TODO add comment here.
+ * Account service.
*
* @author chatellier
* @version $Revision$
@@ -31,5 +33,19 @@
*/
public interface AccountService {
- public void createAccount(Account account) throws LimaException;
+ List<Account> getAllAccounts() throws LimaException;
+
+ /**
+ * Create new account. If {@code masterAccount} is not null, {@code account}
+ * is added in {@code masterAccount}'s subAccounts.
+ *
+ * @param masterAccount master account (can be null)
+ * @param account account
+ * @throws LimaException
+ */
+ void createAccount(Account masterAccount, Account account) throws LimaException;
+
+ void updateAccount(Account account) throws LimaException;
+
+ void removeAccount(Account account) throws LimaException;
}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -1,802 +0,0 @@
-/*
- * *##% Callao AccountServiceImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.business;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Stateless;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.AccountDAO;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-
-/**
- * Permet d'implémenter le Plan Comptable Général.
- * Un compte ne peut être supprimé si il contient des écritures comptables.
- * Un compte peut devenir père et avoir des comptes fils. Chaque compte créé doit
- * renseigné si il appartient à un compte père avec le numéro de compte père.
- *
- * @author Rémi Chapelet
- */
-@Stateless
-public class AccountServiceImpl implements AccountService {
-
- private static final Log log = LogFactory.getLog(AccountServiceImpl.class);
-
- private TopiaContext rootContext;
-
- //private ConvertAccount convertAccount = new ConvertAccount();
-
- public AccountServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- /**
- * Permet de créer un nouveau compte dans le PCG de l'application.
- * Il ne peut exister deux numéros identiques. Pour chaque nouveau compte,
- * il est vérifié si il n'existe pas un compte avec le numéro donné. Dans ce
- * cas présent, le compte n'est pas créé.
- * ATTENTION : le compte masterAccount, c'est à dire le compte père, doit
- * exister, sinon le compte n'est pas créé. Si le compte n'a pas de père, alors
- * mettre masterAccount à null.
- *
- * @param account account to create
- * @throws LimaException
- */
- public void createAccount(Account account) throws LimaException {
-
- // test la validite du numero de compte
- if (StringUtils.isBlank(account.getAccountNumber())) {
- throw new LimaBusinessException("Invalid AccountNumber : " + account.getAccountNumber());
- }
-
- TopiaContext transaction = null;
- try {
- // basic check done, make check in database
- // TODO move it into JTA
- transaction = rootContext.beginTransaction();
-
- // test si le numero de compte existe deja
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- List<Account> existingAccounts = accountDAO.findAllByAccountNumber(account.getAccountNumber());
- if (CollectionUtils.isNotEmpty(existingAccounts)) {
- throw new LimaBusinessException(_("An account already exists with this number : %s", account.getAccountNumber()));
- }
-
- // test si le compte parent existe
- Account masterAcount = account.getMasterAccount();
- if (masterAcount != null) {
- accountDAO.update(masterAcount);
- }
- else {
- accountDAO.create(account);
- }
-
- // commit
- transaction.commitTransaction();
- }
- catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't create account", ex);
- }
- finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't create account", ex);
- }
- }
- }
- }
- /*public String createAccount (String accountNumber, String label,Account masterAccount,String type)
- {
- String result = ServiceHelper.RESPOND_ERROR;
- // Détermine si le compte existe déjà ou non
- boolean existAccount = existAccount(accountNumber);
- // Si le numéro de compte existe
- if (existAccount)
- {
- if (log.isWarnEnabled()) {
- log.warn("Le compte numéro "+accountNumber+" existe deja !");
- }
- result = ServiceHelper.ACCOUNT_DOUBLE;
- } else {
- // Création du compte
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
-
- //Le compte a un père
-
- if ( masterAccount != null )
- {
- // Vérification que le compte père existe dans la base de données
- boolean existMasterAccount = existAccount(masterAccount.getAccountNumber());
- // Si le compte père n'existe pas
- if (!existMasterAccount)
- {
- if (log.isWarnEnabled()) {
- log.warn("Le compte père numéro "+accountNumber+" n'existe pas !");
- }
- result = ServiceHelper.ACCOUNT_NOT_MASTER;
- } else {
- // Creation du compte
- Account newAccount = accountDAO.create();
- newAccount.setAccountNumber(accountNumber);
- newAccount.setLabel(label);
- newAccount.setMasterAccount(masterAccount);
- newAccount.setType(type);
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- } else {
- // Le compte n'a pas de père
- // Creation du compte
- Account newAccount = accountDAO.create();
- newAccount.setAccountNumber(accountNumber);
- newAccount.setLabel(label);
- newAccount.setType(type);
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- }catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
-
- /*
- * Permet de créer un compte à partir du numéro de compte père. Il appelle
- * ensuite createAccount avec le compte père.
- * @param accountNumber numéro du compte à créer
- * @param label label pour le compte
- * @param maserAccountNumber numéro du compte père, si il en a pas, mettre 0.
- * @return
- *
- public String createAccount(String accountNumber, String label,
- String masterAccountNumber, String type) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Recherche le compte Master
- Account masterAccount = searchAccount(masterAccountNumber);
- // Si le compte père n'existe pas
- if (masterAccount == null && !masterAccountNumber.equals("0")) {
- if (log.isWarnEnabled()) {
- log.warn("Le compte père numéro " + masterAccountNumber
- + " n'existe pas !");
- }
- result = ServiceHelper.ACCOUNT_NOT_MASTER;
- } else {
- // Création du compte
- result = createAccount(accountNumber, label, masterAccount, type);
- }
- return result;
- }*/
-
- /*
- * Permet de creer un compte à partir d'un objet DTO
- * @param accountDTO compte au format DTO
- * @return
- *
- public String createAccount(AccountDTO accountDTO) {
- String result;
- String result_final;
- boolean error = false; // Si il y a eu une erreur pour créer les enfants
-
- // Création du compte père
- result = createAccount(accountDTO.getAccountNumber(), accountDTO
- .getLabel(), accountDTO.getMasterAccount(), accountDTO
- .getType());
- // Création des comptes enfants
-
- // Pour chaque enfant
- for (AccountDTO accountChildDTO : accountDTO.getAccountChildDTO()) {
- // Création de l'enfant
- result = createAccount(accountChildDTO);
- // Si il y a eu une erreur
- if (!result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- if (log.isWarnEnabled()) {
- log.warn("Le compte numéro " + accountChildDTO.getLabel()
- + " n'a pu être créé !");
- }
- error = true;
- result_final = result;
- }
- }
- // Si il y a eu une erreur lors de la création d'un enfant, il est envoyé une erreur.
- if (error) {
- result = ServiceHelper.RESPOND_ERROR;
- }
- return result;
- }*/
-
- /*
- * Recherche un compte DTO. Il est recherché dans la base de données et est
- * converti avec ConvertAccount. ConvertAccount recherche dans la liste de
- * ses enfants pour les convertir également, et ainsi de suite.
- * @param accountNumber numéro du compte qu'on souhait rechercher
- * @return
- *
- public AccountDTO searchAccountDTO(String accountNumber) {
- AccountDTO accountDTO = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche du compte
- Account account = accountDAO.findByAccountNumber(accountNumber);
- // Converti entity en DTO
- convertAccount.setTransaction(topiaContext);
- accountDTO = convertAccount.accountEntityToDto(account, null);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return accountDTO;
- }*/
-
- /*
- * Permet de rechercher un compte à partir d'un numéro de compte.
- * @param accountNumber numéro du compte à rechercher
- * @return
- *
- public Account searchAccount(String accountNumber) {
- Account accountResult = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche du compte
- accountResult = accountDAO.findByAccountNumber(accountNumber);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return accountResult;
- }*/
-
- /*
- * Permet de renvoyer tous les enfants du compte.
- * Cette fonction permet de renvoyer les enfants, mais PAS les enfants des
- * enfants (et ainsi de suite). Cette méthode descend donc uniquement d'un
- * niveau sur la hiérarchie.
- * @param account compte dont on souhaite obtenir ses enfants.
- * @return
- *
- public List<Account> searchListChildAccount(Account account) {
- List<Account> ListAccount = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche des comptes enfants
- ListAccount = accountDAO.findAllByMasterAccount(account);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return ListAccount;
- }*/
-
- /*
- * Permet de renvoyer tous les enfants du compte. Elle se base sur la fonction
- * searchListChildAccount(Account account).
- * Cette fonction permet de renvoyer les enfants, mais PAS les enfants des
- * enfants (et ainsi de suite). Cette méthode descend donc uniquement d'un
- * niveau sur la hiérarchie.
- * @param account numéro de compte dont on souhaite obtenir ses enfants.
- * @return
- *
- public List<Account> searchListChildAccount(String accountNumber) {
- List<Account> ListAccount = null;
- // Recherche le compte
- Account account = searchAccount(accountNumber);
- // Si le compte n'existe pas
- if (account == null) {
- if (log.isWarnEnabled()) {
- log.warn("Le compte numéro " + accountNumber
- + " n'existe pas !");
- }
- } else {
- // Recherche des comptes enfants
- ListAccount = searchListChildAccount(account);
- }
- return ListAccount;
- }*/
-
- /**
- * Permet de convertir tous les comptes en DTO. Il recherche dans un premier
- * temps tous les comptes "master".
- *
- * @return
- * @throws LimaException
- */
- public List<Account> getAllAccount() throws LimaException {
- /*ArrayList<AccountDTO> listAccountDTO = new ArrayList<AccountDTO>();
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche des comptes enfants
- List<Account> listAccount = accountDAO.findAll();
- // Pour chaque compte
- // Converti entity en DTO
- convertAccount.setTransaction(topiaContext);
- for (Account account : listAccount) {
- // Pour les comptes sans père
- if (account.getMasterAccount() == null) {
- AccountDTO accountDTO = convertAccount.accountEntityToDto(
- account, null);
- listAccountDTO.add(accountDTO);
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listAccountDTO;*/
-
- List<Account> accountsList = new ArrayList<Account>();
-
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- List<Account> accounts = accountDAO.findAll();
- accountsList.addAll(accounts);
-
- transaction.closeContext();
- }
- catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't create account", ex);
- }
- finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't create account", ex);
- }
- }
- }
-
- return accountsList;
- }
-
- /*
- * Renvoie vrai si le compte avec son numéro existe déjà dans la base de
- * données.
- * @param accountNumber numéro du compte recherché
- * @return
- *
- public boolean existAccount(String accountNumber) {
- // Recherche du compte
- Account accountSearch = searchAccount(accountNumber);
- boolean result = false;
- // Si le compte est trouvé
- if (accountSearch != null) {
- result = true;
- }
- return result;
- }*/
-
- /**
- * Permet d'effacer un compte dans la base de données.
- *
- * Il est vérifié dans un premier temps si le compte existe bien.
- * ATTENTION : si il existe une entrée comptable associée au numéro de
- * compte, il est alors impossible de supprimer le compte.
- *
- * @param account
- * @throws LimaException
- */
- public void removeAccount(Account account) throws LimaException {
- /*String result = ServiceHelper.RESPOND_ERROR;
- Account deleteAccount = searchAccount(accountNumber);
- // Si le compte n'existe pas
- if (deleteAccount == null) {
- if (log.isWarnEnabled()) {
- log.warn("Le compte numéro " + accountNumber
- + " n'existe pas !");
- }
- result = ServiceHelper.ACCOUNT_NOT_EXIST;
- } else // Sinon on efface le compte
- {
- // Vérifie si une entrée ne possède pas ce numéro de compte.
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper
- .getEntryDAO(topiaContext);
- // Recherche au moins une entry avec ce compte.
- Entry entry = entryDAO.findByAccount(deleteAccount);
- // Il existe au moins une entrée
- if (entry != null) {
- if (log.isWarnEnabled()) {
- log.warn("Le compte numéro " + accountNumber
- + " possède des entrées comptable !");
- }
- result = ServiceHelper.ACCOUNT_WITH_ENTRIES;
- } else {
- // On efface tous les comptes enfants
- List<Account> listAccountChild = searchListChildAccount(deleteAccount);
- boolean ErrorRemoveChild = false;
- for (Account accountChild : listAccountChild) {
- // Si on souhaite supprimer les comptes enfants
- result = removeAccount(accountChild.getAccountNumber());
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- ErrorRemoveChild = true;
- if (log.isErrorEnabled()) {
- log.error("Le compte fils numéro "
- + accountChild.getAccountNumber()
- + " n'a pas été supprimé !");
- }
- }
- //
- // Si on ne souhaite pas supprimer les comptes enfants, tous les
- // comptes enfants se retrouvent sans père. Commenter removeAccountChildTest
- // dans le fichier AccountServiceImplTest dans ce cas.
-
- //modifyAccount(accountChild.getAccountNumber(),accountChild.getLabel(),null);
- }
- // Si il n'a jamais eu d'erreur pour supprimer ses fils
- if (!ErrorRemoveChild) {
-
- //// Efface le compte père
-
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Supprime le compte
- accountDAO.delete(deleteAccount);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- result = ServiceHelper.RESPOND_SUCCESS;
- if (log.isInfoEnabled()) {
- log.info("Le compte numéro " + accountNumber
- + " a ete supprimé avec succès.");
- }
- }
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;*/
-
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- // Vérifie si une entrée ne possède pas ce numéro de compte.
- // FIXME !IMPORTANT! check that subaccounts have no entries too
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
- Entry firstEntry = entryDAO.findByAccount(account);
-
- if (firstEntry != null) {
- throw new LimaBusinessException("Can't delete account with entries");
- }
-
- // remove account
- // FIXME !IMPORTANT! check that subaccounts are also deleted
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- accountDAO.delete(account);
-
- transaction.closeContext();
- }
- catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't delete account", ex);
- }
- finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't delete account", ex);
- }
- }
- }
- }
-
- /*
- * Permet d'effacer un compte à partir d'un compte DTO. Il appelle la
- * méthode removeAccount, qui effacera également les enfants (et ainsi de
- * suite dans la hiérarchie du compte).
- * @param accountDTO Compte au format DTO qu'on souhaite supprimer.
- * @return
- *
- public String removeAccount(AccountDTO accountDTO) {
- String result;
- result = removeAccount(accountDTO.getAccountNumber());
- return result;
- }*/
-
- /**
- * Permet de modifier un compte sur son label et son compte père.
- *
- * Il n'est pas possible de modifier un numéro de compte.
- * Si le compte n'existe pas, il envoie alors un message d'avertissement.
- *
- * @param accountNumber numéro de compte à modifier
- * @param label label à modifier
- * @param masterAccountNumber compte père à modifier
-
- * @throws LimaException
- */
- public void modifyAccount(Account account) throws LimaException {
- /*String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche du compte
- Account modifyAccount = accountDAO
- .findByAccountNumber(accountNumber);
- // Si le compte n'existe pas
- if (modifyAccount == null) {
- if (log.isWarnEnabled()) {
- log.warn("Le compte numéro " + accountNumber
- + " n'existe pas !");
- }
- result = ServiceHelper.ACCOUNT_NOT_EXIST;
- } else {
-
- // Modifie le compte
- modifyAccount.setLabel(label);
- modifyAccount.setType(type);
- // Recherche du compte père
- // Si il possède un compte père
- if (masterAccount != null) {
- modifyAccount.setMasterAccount(masterAccount);
- }
- modifyAccount.update();
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;*/
-
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- // update account
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- accountDAO.update(account);
-
- transaction.closeContext();
- }
- catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't update account", ex);
- }
- finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't update account", ex);
- }
- }
- }
- }
-
- /*
- * Permet de modifier un compte sur son label et son compte père.
- * Il recherche le compte père avec le numéro de compte fourni. Appel ensuite
- * la méthode modifyAccount avec pour paramètre le compte père trouvé.
- * @param accountNumber numéro de compte à modifier
- * @param label label à modifier
- * @param masterAccountNumber le numéro du compte père
- * @return
- *
- public String modifyAccount(String accountNumber, String label,
- String type, String masterAccountNumber) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
-
- // Modifie le compte
- // Recherche du compte père
- Account masterAccount = accountDAO
- .findByAccountNumber(masterAccountNumber);
- result = modifyAccount(accountNumber, label, type, masterAccount);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Permet de modifier un compte à partir d'un compte DTO.
- * @param accountDTO compte au format DTO qu'on souhaire modifier.
- * @return
- *
- public String modifyAccount(AccountDTO accountDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche du compte père
- Account masterAccount = accountDAO.findByAccountNumber(accountDTO
- .getMasterAccount());
- result = modifyAccount(accountDTO.getAccountNumber(), accountDTO
- .getLabel(), accountDTO.getType(), masterAccount);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Permet de mettre à jour le compte DTO ainsi que tous ses fils.
- * Cette méthode permet d'ajouter, modifier, et supprimer un compte et
- * ses enfants (et ainsi de suite).
- * @param accountDTO
- * @return
- *
- public String updateDTO(AccountDTO accountDTO) {
- String result;
- // Si le compte DTO père existe
- if (existAccount(accountDTO.getAccountNumber())) {
- // Modification du compte père
- result = modifyAccount(accountDTO);
- } else {
- // Création du compte père
- result = createAccount(accountDTO);
- }
- // Pour chaque enfant on lance l'update
- for (AccountDTO accountChildDTO : accountDTO.getAccountChildDTO()) {
- updateDTO(accountChildDTO);
- }
-
- // On recherche les comptes DTO effacés
- List<Account> listAccountChild = searchListChildAccount(accountDTO
- .getAccountNumber());
- for (Account account : listAccountChild) {
- // Si le compte n'est pas dans la liste, alors on efface
- if (!accountDTO.existAccountChild(account.getAccountNumber())) {
- result = removeAccount(account.getAccountNumber());
- }
- }
- return result;
- }*/
-
-}
\ No newline at end of file
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/EntryServiceImpl.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/EntryServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -1,381 +0,0 @@
-/*
- * *##% Callao EntryServiceImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.business;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Entry;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaNotFoundException;
-
-/**
- * Cette classe permet de contrôler les différentes saisies possibles dans
- * Callao. Ces saisies sont transmises à la base de données par la classe
- * Entry. Chaque action sur une entrée déclenche une création d'un log.
- * Chaque opération comptable doit faire appel également au contrôl de la
- * période comptable sur laquelle l'entry repose. Ainsi il n'est possible
- * d'ajouter/modifier/supprimer une entrée si la période est bloquée.
- *
- * @author Rémi Chapelet
- */
-public class EntryServiceImpl { // implements EntryService {
-
- private static final Log log = LogFactory.getLog(EntryServiceImpl.class);
-
- private TopiaContext rootContext;
-
- private LogServiceImpl logServiceImpl = new LogServiceImpl();
-
- // TODO A revoir car transaction a besoin de entry et vice versa
- private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
-
- private AccountServiceImpl accountServiceImpl = new AccountServiceImpl();
-
- public EntryServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- /**
- * Création d'une entrée comptable.
- * La période ne doit PAS être bloquée.
- *
- * @return
- */
- public void createEntry(Entry entry /*String description, String amount, boolean debit,
- String lettering, String detail, Transaction transaction,
- Account account*/) {
- /*String result = isCorrectEntry(transaction, account);
- if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper
- .getEntryDAO(topiaContext);
- // Creation de l'entrée comptable
- Entry newEntry = entryDAO.create();
- newEntry.setDescription(description);
- // On formate le nombre
- newEntry.setAmount(numberUtil.format(amount));
- newEntry.setDebit(debit);
- newEntry.setLettering(lettering);
- newEntry.setDetail(detail);
- newEntry.setTransaction(transaction);
- newEntry.setAccount(account);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Ajout avec succes de l'entrée comptable.");
- }
- // Création du log
- Date logDate = new Date();
- logServiceImpl.addLog(logDate, transaction.getTransDate(),
- ServiceHelper.LOG_ADD, transaction.getVoucherRef(),
- transaction.getDescription(), detail, amount, debit,
- lettering);
-
- // Il renvoie soit l'identifiant topiaId ou SUCCESS.
- result = newEntry.getTopiaId();
- //result = ServiceHelper.RESPOND_SUCCESS;
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;*/
- }
-
- /*
- * Permet de créer une entrée comptable à partir de son DTO.
- * @param entryDTO
- * @return
- *
- public String createEntry(EntryDTO entryDTO) {
- // Recherche TransactionDTO
- TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
- Transaction transaction = transactionServiceImpl
- .searchTransactionWithTopiaId(transactonDTO);
- // Recherche AccountDTO
- AccountDTO accountDTO = entryDTO.getAccountDTO();
- Account account = accountServiceImpl.searchAccount(accountDTO
- .getAccountNumber());
- // Création entry
- String result = createEntry(entryDTO.getDescription(), entryDTO
- .getAmount(), entryDTO.isDebit(), entryDTO.getLettering(),
- entryDTO.getDetail(), transaction, account);
- return result;
- }*/
-
- /*
- * Vérifie que les objets transaction et account ne sont pas nulls.
- * @param transaction
- * @param account
- * @return
- *
- public String isCorrectEntry(Transaction transaction, Account account) {
- String result = ServiceHelper.RESPOND_SUCCESS;
- // Vérification si timeSpan et Journal existe bien
- if (account == null) {
- if (log.isErrorEnabled()) {
- log.error("Création entry : Le account n'existe pas.");
- }
- result = ServiceHelper.ACCOUNT_NOT_EXIST;
- }
- if (transaction == null) {
- if (log.isErrorEnabled()) {
- log.error("Création entry : La transaction n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_EXIST;
- }
- return result;
- }*/
-
- /*
- * Recherche toutes les entrées comptables d'une transaction.
- * @param transaction
- * @return
- *
- public List<Entry> searchEntryWithTransaction(Transaction transaction) {
- List<Entry> listEntry = null;
- if (transaction != null) {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper
- .getEntryDAO(topiaContext);
- // Recherche
- listEntry = entryDAO.findAllByTransaction(transaction);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return listEntry;
- }*/
-
- /*
- * Recherche toutes les entrées comptables d'une transaction, et renvoie
- * au format DTO.
- * @param transaction
- * @return
- *
- public List<EntryDTO> searchEntryDTOWithTransaction(Transaction transaction) {
- List<EntryDTO> listEntryDTO = new ArrayList<EntryDTO>();
- // Si la transaction est trouvée
- if (transaction != null) {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper
- .getEntryDAO(topiaContext);
- // Recherche toutes les entrées comptables de la transaction
- List<Entry> listEntry = entryDAO
- .findAllByTransaction(transaction);
- // Pour chaque entry, on fait appel au convertisseur pour avoir en DTO
- convertEntry.setTransaction(topiaContext);
- for (Entry entry : listEntry) {
- EntryDTO entryDTO = convertEntry.entryEntityToDto(entry);
- // On ajoute le nouvel DTO
- listEntryDTO.add(entryDTO);
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return listEntryDTO;
- }*/
-
- /*
- * Recherche les entrées comptables pour une transaction donnée au format DTO.
- * @param transactionTopiaId identifiant de la transaction
- * @return
- *
- public List<EntryDTO> searchEntryDTOWithTransaction(
- String transactionTopiaId) {
- List<EntryDTO> listEntryDTO = new ArrayList<EntryDTO>();
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- // Recherche de la transaction
- Transaction transaction = transactionServiceImpl
- .searchTransactionWithTopiaId(transactionTopiaId);
- // Si la transaction est trouvée
- if (transaction != null) {
- // Recherche toutes les entrées comptables de la transaction
- List<Entry> listEntry = entryDAO
- .findAllByTransaction(transaction);
- // Pour chaque entry, on fait appel au convertisseur pour avoir en DTO
- convertEntry.setTransaction(topiaContext);
- for (Entry entry : listEntry) {
- EntryDTO entryDTO = convertEntry.entryEntityToDto(entry);
- // On ajoute l'entrée DTO
- listEntryDTO.add(entryDTO);
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listEntryDTO;
- }*/
-
- /*
- * Recherche les entrées comptables pour une transaction donnée au format DTO.
- * @param transactionDTO
- * @return
- *
- public List<EntryDTO> searchEntryDTOWithTransaction(
- TransactionDTO transactionDTO) {
- List<EntryDTO> listEntryOfTransaction = searchEntryDTOWithTransaction(transactionDTO
- .getId());
- return listEntryOfTransaction;
- }*/
-
- /*
- * Permet d'effacer une entrée comptable à partir de son identifiant topia.
- * @param topiaId
- * @return
- *
- public String removeEntry(String topiaId) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- // Recherche de l'entry
- Entry entryDelete = entryDAO.findByTopiaId(topiaId);
- // Si l'entry existe alors on supprime
- if (entryDelete != null) {
- // Supprime
- entryDAO.delete(entryDelete);
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- } else {
- result = ServiceHelper.ENTRY_NOT_EXIST;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Permet d'effacer une entrée comptable au format DTO.
- * @param entryDTO
- * @return
- *
- public String removeEntry(EntryDTO entryDTO) {
- String result = removeEntry(entryDTO.getId());
- return result;
- }*/
-
- /*
- * Modification d'une entrée comptable.
- * @param topiaId
- * @param description
- * @param amount
- * @param debit
- * @param lettering
- * @param detail
- * @param transaction
- * @param account
- * @return
- *
- public String modifyEntry(String topiaId, String description,
- String amount, boolean debit, String lettering, String detail,
- Account account) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- // Recherche Entry
- Entry entry = entryDAO.findByTopiaId(topiaId);
- entry.setDescription(description);
- // On formate le nombre
- entry.setAmount(numberUtil.format(amount));
- entry.setDebit(debit);
- entry.setLettering(lettering);
- entry.setDetail(detail);
- entry.setAccount(account);
- entry.update();
- // Création BDD
- topiaContext.commitTransaction();
- // Chargement DAO transaction
- Transaction transaction = entry.getTransaction();
- if (log.isInfoEnabled()) {
- log.info("Edit avec succes de l'entrée comptable.");
- }
- // Création du log
- Date logDate = new Date();
- logServiceImpl.addLog(logDate, transaction.getTransDate(),
- ServiceHelper.LOG_MODIFY, transaction.getVoucherRef(),
- transaction.getDescription(), detail, amount, debit,
- lettering);
- result = ServiceHelper.RESPOND_SUCCESS;
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une entrée comptable.
- * @param entryDTO
- * @return
- *
- public String modifyEntry(EntryDTO entryDTO) {
- // Recherche AccountDTO
- AccountDTO accountDTO = entryDTO.getAccountDTO();
- Account account = accountServiceImpl.searchAccount(accountDTO
- .getAccountNumber());
- // Modification entry
- String result = modifyEntry(entryDTO.getId(),
- entryDTO.getDescription(), entryDTO.getAmount(), entryDTO
- .isDebit(), entryDTO.getLettering(), entryDTO
- .getDetail(), account);
- return result;
- }*/
-}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/FilesServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FilesServiceImpl.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FilesServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -1,667 +0,0 @@
-/*
- * *##% Callao FilesServiceImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.business;
-
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.dto.AccountDTO;
-import org.chorem.lima.business.dto.EntryDTO;
-import org.chorem.lima.business.dto.JournalDTO;
-import org.chorem.lima.business.dto.PeriodDTO;
-import org.chorem.lima.business.dto.TimeSpanDTO;
-import org.chorem.lima.business.dto.TransactionDTO;
-import org.chorem.lima.business.utils.DateUtil;
-import org.chorem.lima.business.utils.ServiceHelper;
-import org.jdom.Attribute;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-import org.jdom.output.Format;
-import org.jdom.output.XMLOutputter;
-import org.jdom.xpath.XPath;
-import org.nuiton.topia.TopiaContext;
-
-/**
- * Cette classe permet d'importer et exporter des données comptables. Ces données
- * sont au format xml.
- *
- * @author Rémi Chapelet
- */
-public class FilesServiceImpl { // implements FilesService {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(FilesServiceImpl.class);
-
- static Element racine = new Element("Callao");
-
- static org.jdom.Document document = new Document(racine);
-
- private static DateUtil dateUtil = new DateUtil();
-
- private AccountServiceImpl accountServiceImpl = new AccountServiceImpl();
-
- private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
-
- private JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
-
- private PeriodServiceImpl periodServiceImpl = new PeriodServiceImpl();
-
- private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
-
- private TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
-
- /**
- * Cete méthode permet d'exporter des données de Callao vers un fichier au
- * format xml.
- *
- * @param nameFile
- */
- public void exportDatas(String nameFile) {
- /*if (log.isDebugEnabled()) {
- log.debug("Save file XML : ");
- }
-
- // Partie Informations
- Element info = new Element("informations");
- racine.addContent(info);
- Attribute date = new Attribute("date", new Date().toString());
- info.setAttribute(date);
- Attribute user = new Attribute("user", "Name user");
- info.setAttribute(user);
- Attribute company = new Attribute("company", "Name company");
- info.setAttribute(company);
-
- // Partie Save
-
- // Création Element save
- Element save = new Element("save");
- racine.addContent(save);
-
- // Period
-
- // Création élément liste de périods
- Element periods = new Element("periods");
- // Création élément liste de timespans
- Element timeSpans = new Element("timespans");
- save.addContent(periods);
- save.addContent(timeSpans);
- // Recherche de la liste de toutes les périodes et leurs timeSpans en DTO
- List<PeriodDTO> listPeriodDTO = periodServiceImpl.getAllPeriod();
- // Pour chaque période
- for (PeriodDTO periodDTO : listPeriodDTO) {
- // Création élément périod
- Element period = new Element("period");
- periods.addContent(period);
- // Identifiant période
- Attribute id = new Attribute("id", periodDTO.getId());
- period.setAttribute(id);
- // BeginPeriod
- // Découpage date
- String dateTab[] = dateUtil.arrayDate(periodDTO.getBeginPeriod());
- Attribute beginYear = new Attribute("beginYear", dateTab[0]);
- period.setAttribute(beginYear);
- Attribute beginMonth = new Attribute("beginMonth", dateTab[1]);
- period.setAttribute(beginMonth);
- Attribute beginDay = new Attribute("beginDay", dateTab[2]);
- period.setAttribute(beginDay);
- // EndPeriod
- dateTab = dateUtil.arrayDate(periodDTO.getEndPeriod());
- Attribute endYear = new Attribute("endYear", dateTab[0]);
- period.setAttribute(endYear);
- Attribute endMonth = new Attribute("endMonth", dateTab[1]);
- period.setAttribute(endMonth);
- Attribute endDay = new Attribute("endDay", dateTab[2]);
- period.setAttribute(endDay);
- // Locked Period
- if (periodDTO.isLocked()) {
- Attribute locked = new Attribute("locked", "true");
- period.setAttribute(locked);
- } else {
- Attribute locked = new Attribute("locked", "false");
- period.setAttribute(locked);
- }
-
- // TimeSpan
-
- // Recherche des timeSpans de la période
- List<TimeSpanDTO> listTimeSpanDTO = periodDTO.getListTimeSpan();
- // Pour chaque timeSpan
- for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
- Element timeSpan = new Element("timespan");
- timeSpans.addContent(timeSpan);
- // Identifiant timeSpan
- Attribute idTimeSpan = new Attribute("id", timeSpanDTO.getId());
- timeSpan.setAttribute(idTimeSpan);
- Attribute idPeriod = new Attribute("idPeriod", periodDTO
- .getId());
- timeSpan.setAttribute(idPeriod);
- // Begin TimeSpan
- // Découpage date
- dateTab = dateUtil.arrayDate(timeSpanDTO.getBeginTimeSpan());
- Attribute beginYearTimeSpan = new Attribute("beginYear",
- dateTab[0]);
- timeSpan.setAttribute(beginYearTimeSpan);
- Attribute beginMonthTimeSpan = new Attribute("beginMonth",
- dateTab[1]);
- timeSpan.setAttribute(beginMonthTimeSpan);
- Attribute beginDayTimeSpan = new Attribute("beginDay",
- dateTab[2]);
- timeSpan.setAttribute(beginDayTimeSpan);
- // End TimeSpan
- dateTab = dateUtil.arrayDate(timeSpanDTO.getEndTimeSpan());
- Attribute endYearTimeSpan = new Attribute("endYear", dateTab[0]);
- timeSpan.setAttribute(endYearTimeSpan);
- Attribute endMonthTimeSpan = new Attribute("endMonth",
- dateTab[1]);
- timeSpan.setAttribute(endMonthTimeSpan);
- Attribute endDayTimeSpan = new Attribute("endDay", dateTab[2]);
- timeSpan.setAttribute(endDayTimeSpan);
- // Lock timeSpan
- if (timeSpanDTO.isLocked()) {
- Attribute locked = new Attribute("locked", "true");
- timeSpan.setAttribute(locked);
- } else {
- Attribute locked = new Attribute("locked", "false");
- timeSpan.setAttribute(locked);
- }
- }
- }
-
- // Journal
-
- Element journals = new Element("journals");
- save.addContent(journals);
- List<JournalDTO> listJournalDTO = journalServiceImpl.getAllJournal();
- for (JournalDTO journalDTO : listJournalDTO) {
- Element journal = new Element("journal");
- journals.addContent(journal);
- // Identification du journal
- Attribute idJournal = new Attribute("id", journalDTO.getId());
- journal.setAttribute(idJournal);
- // Label
- Attribute label = new Attribute("label", journalDTO.getLabel());
- journal.setAttribute(label);
- // Prefix
- Attribute prefix = new Attribute("prefix", journalDTO.getPrefix());
- journal.setAttribute(prefix);
- // Description
- Attribute description = new Attribute("description", journalDTO
- .getDescription());
- journal.setAttribute(description);
- }
-
- // Account
-
- Element accounts = new Element("accounts");
- save.addContent(accounts);
- List<AccountDTO> listAccountDTO = accountServiceImpl.getAllAccount();
- // Appel une fonction récursive pour parcourir l'arborescence des comptes
- accountXML(listAccountDTO, accounts);
-
- // Transaction
- Element transactions = new Element("transactions");
- save.addContent(transactions);
- Element entries = new Element("entries");
- save.addContent(entries);
- // Recherche de toutes les transactions
- List<TransactionDTO> listTransactionDTO = transactionServiceImpl
- .getAllTransactionDTO();
- // Pour chaque transaction
- for (TransactionDTO transactionDTO : listTransactionDTO) {
- Element transaction = new Element("transaction");
- transactions.addContent(transaction);
- // Identification de la transaction
- Attribute idTransaction = new Attribute("id", transactionDTO
- .getId());
- transaction.setAttribute(idTransaction);
- // EntryDate
- String dateTab[] = dateUtil
- .arrayDate(transactionDTO.getEntryDate());
- Attribute entryDateYear = new Attribute("entryDateYear", dateTab[0]);
- transaction.setAttribute(entryDateYear);
- Attribute entryDateMonth = new Attribute("entryDateMonth",
- dateTab[1]);
- transaction.setAttribute(entryDateMonth);
- Attribute entryDateDay = new Attribute("entryDateDay", dateTab[2]);
- transaction.setAttribute(entryDateDay);
- // VoucherRef
- Attribute voucherRef = new Attribute("voucherRef", transactionDTO
- .getVoucherRef());
- transaction.setAttribute(voucherRef);
- // Description
- Attribute description = new Attribute("description", transactionDTO
- .getDescription());
- transaction.setAttribute(description);
- // Id journal
- Attribute IdJournal = new Attribute("idJournal", transactionDTO
- .getJournalDTO().getId());
- transaction.setAttribute(IdJournal);
- // Id timeSpan
- Attribute IdTimeSpan = new Attribute("idTimeSpan", transactionDTO
- .getTimeSpanDTO().getId());
- transaction.setAttribute(IdTimeSpan);
-
- // Entry
- List<EntryDTO> listEntryDTO = entryServiceImpl
- .searchEntryDTOWithTransaction(transactionDTO);
- for (EntryDTO entryDTO : listEntryDTO) {
- Element entry = new Element("entry");
- entries.addContent(entry);
- // Identification du entry
- Attribute idEntry = new Attribute("id", entryDTO.getId());
- entry.setAttribute(idEntry);
- // Description
- Attribute descriptionEntry = new Attribute("description",
- entryDTO.getDescription());
- entry.setAttribute(descriptionEntry);
- // Amount
- Attribute amount = new Attribute("amount", entryDTO.getAmount());
- entry.setAttribute(amount);
- // Lettering
- Attribute lettering = new Attribute("lettering", entryDTO
- .getLettering());
- entry.setAttribute(lettering);
- // Detail
- Attribute detail = new Attribute("detail", entryDTO.getDetail());
- entry.setAttribute(detail);
- // Debit / crédit
- if (entryDTO.isDebit()) {
- Attribute debit = new Attribute("debit", "true");
- entry.setAttribute(debit);
- } else {
- Attribute debit = new Attribute("debit", "false");
- entry.setAttribute(debit);
- }
- // Transaction
- Attribute idrefTransaction = new Attribute("idTransaction",
- transactionDTO.getId());
- entry.setAttribute(idrefTransaction);
- // Account
- Attribute idAccount = new Attribute("idAccount", entryDTO
- .getAccountDTO().getId());
- entry.setAttribute(idAccount);
- }
- }
- //affiche();
- enregistre(nameFile);
- return ServiceHelper.RESPOND_SUCCESS;*/
- }
-
- /**
- * Converti la liste des comptes pour être ajouté au document xml.
- * @param listAccountDTO
- * @param accounts
- */
- protected void accountXML(List<AccountDTO> listAccountDTO, Element accounts) {
- /*for (AccountDTO accountDTO : listAccountDTO) {
- Element account = new Element("account");
- accounts.addContent(account);
- // Identification du account
- Attribute idAccount = new Attribute("id", accountDTO.getId());
- account.setAttribute(idAccount);
- // Label
- Attribute label = new Attribute("label", accountDTO.getLabel());
- account.setAttribute(label);
- // Type
- Attribute type = new Attribute("type", accountDTO.getType());
- account.setAttribute(type);
- // AccountNumber
- Attribute accountNumber = new Attribute("accountNumber", accountDTO
- .getAccountNumber());
- account.setAttribute(accountNumber);
- // MasterAccountNumber
- Attribute masterAccountNumber = new Attribute("masterAccount",
- accountDTO.getMasterAccount());
- account.setAttribute(masterAccountNumber);
- // Ajoute les comptes enfants à la liste
- accountXML(accountDTO.getAccountChildDTO(), accounts);
- }*/
- }
-
- // Affiche le fichier xml
- /*static void affiche() {
- try {
- XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
- sortie.output(document, System.out);
- } catch (java.io.IOException e) {
- }
- }*/
-
- /**
- * Permet d'enregistrer le fichier xml.
- * @param fichier
- */
- /*static void enregistre(String fichier) {
- try {
- XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
- sortie.output(document, new FileOutputStream(fichier));
- } catch (java.io.IOException e) {
- }
- }*/
-
- /**
- * Permet d'importer un fichier de données au format xml dans Callao. Si le
- * fichier n'est pas disponible, il est alors renvoyé un message d'erreur.
- * @param file
- * @return
- */
- public void importDatas(String file) {
- /*if (log.isDebugEnabled()) {
- log.debug("Load file XML : ");
- }
- String result = ServiceHelper.RESPOND_ERROR;
- boolean existError = false;
-
-
- // Chargement du fichier et construction du Dom
- try {
- // On crée une instance de SAXBuilder
- SAXBuilder sxb = new SAXBuilder();
- document = sxb.build(file);
- } catch (IOException e) {
- log.error("Erreur lors de la lecture du fichier " + e.getMessage());
- e.printStackTrace();
- } catch (JDOMException e) {
- log.error("Erreur lors de la construction du fichier JDOM "
- + e.getMessage());
- e.printStackTrace();
- }
-
-
- // Ecriture dans la base de données
- try {
- // Recherche de la racine
- Element racine = document.getRootElement();
-
- // Journal
- XPath requeteXpath = XPath.newInstance("//journal");
- List results = requeteXpath.selectNodes(racine);
-
- Iterator iter = results.iterator();
- // Pour tous les journaux
- while (iter.hasNext()) {
- Element noeudCourant = (Element) iter.next();
- // Recherche attributs
- String label = noeudCourant.getAttribute("label").getValue();
- String prefix = noeudCourant.getAttribute("prefix").getValue();
- String description = noeudCourant.getAttribute("description")
- .getValue();
- // Création bdd
- result = journalServiceImpl.createJournal(label, prefix,
- description);
- // Control erreur
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- existError = true;
- }
- }
-
- // Account
- requeteXpath = XPath.newInstance("//account");
- results = requeteXpath.selectNodes(racine);
-
- iter = results.iterator();
- // Pour tous les accounts
- while (iter.hasNext()) {
- Element noeudCourant = (Element) iter.next();
- // Recherche attributs
- String label = noeudCourant.getAttribute("label").getValue();
- String accountNumber = noeudCourant.getAttribute(
- "accountNumber").getValue();
- String masterAccount = noeudCourant.getAttribute(
- "masterAccount").getValue();
- String typeAccount = noeudCourant.getAttribute("type")
- .getValue();
- // Création bdd
- result = accountServiceImpl.createAccount(accountNumber, label,
- masterAccount, typeAccount);
- // Control erreur
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- existError = true;
- }
- }
-
- // Period
- requeteXpath = XPath.newInstance("//period");
- results = requeteXpath.selectNodes(racine);
-
- iter = results.iterator();
- // Pour tous les periods
- while (iter.hasNext()) {
- Element noeudCourant = (Element) iter.next();
- // Recherche attributs
- String idPeriod = noeudCourant.getAttribute("id").getValue();
- int year = Integer.parseInt(noeudCourant.getAttribute(
- "beginYear").getValue());
- int month = Integer.parseInt(noeudCourant.getAttribute(
- "beginMonth").getValue());
- int day = Integer.parseInt(noeudCourant
- .getAttribute("beginDay").getValue());
- Date beginPeriod = new Date(year - 1900, month, day);
- year = Integer.parseInt(noeudCourant.getAttribute("endYear")
- .getValue());
- month = Integer.parseInt(noeudCourant.getAttribute("endMonth")
- .getValue());
- day = Integer.parseInt(noeudCourant.getAttribute("endDay")
- .getValue());
- Date endPeriod = new Date(year - 1900, month, day);
- // Création bdd
- result = periodServiceImpl.createPeriod(beginPeriod, endPeriod,
- false);
- // Control erreur
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- existError = true;
- }
-
- // Transaction
- requeteXpath = XPath
- .newInstance("//transaction[@idTimeSpan=//timespan[@idPeriod='"
- + idPeriod + "']/@id]");
- List resultsTransaction = requeteXpath.selectNodes(racine);
- Iterator iterTrans = resultsTransaction.iterator();
- // Pour tous les transactions
- while (iterTrans.hasNext()) {
- Element noeudCourantTrans = (Element) iterTrans.next();
-
- // Recherche attributs
-
- // Id transaction XMl
- String idTransactionXML = noeudCourantTrans.getAttribute(
- "id").getValue();
- // Recherche du journal en DTO
- String idJournal = noeudCourantTrans.getAttribute(
- "idJournal").getValue();
- requeteXpath = XPath.newInstance("//journal[@id='"
- + idJournal + "']/@label");
- String label = requeteXpath.valueOf(racine);
- JournalDTO journalDTO = journalServiceImpl
- .searchJournalDTOWithLabel(label);
- // Recherche du timeSpan en DTO
- String idtimeSpan = noeudCourantTrans.getAttribute(
- "idTimeSpan").getValue();
- requeteXpath = XPath.newInstance("//timespan[@id='"
- + idtimeSpan + "']/@beginYear");
- year = Integer.parseInt(requeteXpath.valueOf(racine));
- requeteXpath = XPath.newInstance("//timespan[@id='"
- + idtimeSpan + "']/@beginMonth");
- month = Integer.parseInt(requeteXpath.valueOf(racine));
- requeteXpath = XPath.newInstance("//timespan[@id='"
- + idtimeSpan + "']/@beginDay");
- day = Integer.parseInt(requeteXpath.valueOf(racine));
- Date beginTimeSpan = new Date(year - 1900, month, day);
- TimeSpanDTO timeSpanDTO = timeSpanServiceImpl
- .searchTimeSpanDTOByDate(beginTimeSpan);
-
- // Création de transaction DTO
- TransactionDTO transactionDTO = new TransactionDTO();
- transactionDTO.setJournalDTO(journalDTO);
- transactionDTO.setTimeSpanDTO(timeSpanDTO);
- // entryDate
- year = Integer.parseInt(noeudCourantTrans.getAttribute(
- "entryDateYear").getValue());
- month = Integer.parseInt(noeudCourantTrans.getAttribute(
- "entryDateMonth").getValue());
- day = Integer.parseInt(noeudCourantTrans.getAttribute(
- "entryDateDay").getValue());
- Date entryDate = new Date(year - 1900, month, day);
- transactionDTO.setEntryDate(entryDate);
- // voucherRef
- String voucherRef = noeudCourantTrans.getAttribute(
- "voucherRef").getValue();
- transactionDTO.setVoucherRef(voucherRef);
- // description
- String description = noeudCourantTrans.getAttribute(
- "description").getValue();
- transactionDTO.setDescription(description);
-
- // Création bdd
- String idTransactionCallao = transactionServiceImpl
- .createTransaction(transactionDTO);
-
- // Entry
- requeteXpath = XPath.newInstance("//entry[@idTransaction='"
- + idTransactionXML + "']");
- List resultsEntry = requeteXpath.selectNodes(racine);
-
- Iterator iterEntry = resultsEntry.iterator();
- // Pour tous les entries
- while (iterEntry.hasNext()) {
- Element noeudEntry = (Element) iterEntry.next();
-
- // Recherche attributs
-
- // Transaction DTO
- transactionDTO = transactionServiceImpl
- .searchTransactionDTO(idTransactionCallao);
- // Account DTO
- String idAccount = noeudEntry.getAttribute("idAccount")
- .getValue();
- requeteXpath = XPath.newInstance("//account[@id='"
- + idAccount + "']/@accountNumber");
- String accountNumber = requeteXpath.valueOf(racine);
- AccountDTO accountDTO = accountServiceImpl
- .searchAccountDTO(accountNumber);
- // Entry DTO
- EntryDTO entryDTO = new EntryDTO();
- entryDTO.setAccountDTO(accountDTO);
- entryDTO.setTransactionDTO(transactionDTO);
- // Description
- description = noeudEntry.getAttribute("description")
- .getValue();
- entryDTO.setDescription(description);
- // Amount
- String amount = noeudEntry.getAttribute("amount")
- .getValue();
- entryDTO.setAmount(amount);
- // Debit
- boolean debit = noeudEntry.getAttribute("debit")
- .getValue().equals("true");
- entryDTO.setDebit(debit);
- // Lettering
- String lettering = noeudEntry.getAttribute("lettering")
- .getValue();
- entryDTO.setLettering(lettering);
- // Detail
- String detail = noeudEntry.getAttribute("detail")
- .getValue();
- entryDTO.setDetail(detail);
- // Création bdd
- result = transactionServiceImpl.addEntry(entryDTO);
- // Control erreur
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- existError = true;
- }
- }
- }
-
-
- // Bloquer Period
- boolean lock = noeudCourant.getAttribute("locked").getValue()
- .equals("true");
- // Si la période est bloquée
- if (lock) {
- // Bloque tous ses timeSpans
- result = periodServiceImpl
- .blockAllTimeSpanOfPeriod(periodServiceImpl
- .searchPeriodWithDate(beginPeriod));
- // Control erreur
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- existError = true;
- }
- // bloque la période
- result = periodServiceImpl.blockPeriod(periodServiceImpl
- .searchPeriodWithDate(beginPeriod));
-
- } else {
- // On regarde si il y a besoin de bloquer les timeSpans
- requeteXpath = XPath.newInstance("//timespan[@idPeriod = '"
- + idPeriod + "']");
- List resultsTimeSpan = requeteXpath.selectNodes(racine);
- Iterator iterTimeSpan = resultsTimeSpan.iterator();
- // Pour tous les timeSpans
- while (iterTimeSpan.hasNext()) {
- Element noeudCourantTimeSpan = (Element) iterTimeSpan
- .next();
- // Recherche attributs
- year = Integer.parseInt(noeudCourantTimeSpan
- .getAttribute("beginYear").getValue());
- month = Integer.parseInt(noeudCourantTimeSpan
- .getAttribute("beginMonth").getValue());
- day = Integer.parseInt(noeudCourantTimeSpan
- .getAttribute("beginDay").getValue());
- Date beginTimeSpan = new Date(year - 1900, month, day);
- lock = noeudCourantTimeSpan.getAttribute("locked")
- .getValue().equals("true");
- // Bloque le timeSpan
- if (lock) {
- timeSpanServiceImpl
- .blockTimeSpan(timeSpanServiceImpl
- .searchTimeSpanByDate(beginTimeSpan));
- }
- // Control erreur
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- existError = true;
- }
- }
- }
-
- }
-
- } catch (JDOMException e) {
- log.error("Erreur JDOM " + e.getMessage());
- e.printStackTrace();
- }
-
- // Détection des erreurs
- if (!existError) {
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- return result;*/
- }
-
-}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/JournalServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/JournalServiceImpl.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/JournalServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -1,470 +0,0 @@
-/*
- * *##% Callao JournalServiceImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.business;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Journal;
-import org.chorem.lima.entity.JournalDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.Transaction;
-import org.chorem.lima.entity.TransactionDAO;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-
-/**
- * Implémente la fonction multi-journal. Il est possible de créer ici le
- * journal des ventes, le journal des achats, etc.
- *
- * @author Rémi Chapelet
- */
-public class JournalServiceImpl {
-
- private static final Log log = LogFactory.getLog(JournalServiceImpl.class);
-
- private TopiaContext rootContext;
-
- //private ConvertJournal convertJournal = new ConvertJournal();
-
- public JournalServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- /**
- * Création d'un journal. Il peut être unique sur son label (au choix).
- *
- * @param journal journal
- * @throws LimaException
- */
- public void createJournal(Journal journal) throws LimaException {
- /*String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- JournalDAO journalDAO = LimaCallaoDAOHelper
- .getJournalDAO(topiaContext);
-
- // Si on souhaite avoir un journal unique avec son label
-
- Journal journal = searchJournalWithLabel(label);
- // Si un journal existe déjà avec ce label
- if (journal != null) {
- if (log.isWarnEnabled()) {
- log.warn("Un journal avec le label " + label
- + " existe déjà !");
- }
- result = ServiceHelper.JOURNAL_DOUBLE;
- } else {
- // Creation du journal
- Journal newJournal = journalDAO.create();
- newJournal.setLabel(label);
- newJournal.setPrefix(prefix);
- newJournal.setDescription(description);
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;*/
-
- TopiaContext transaction = null;
- try {
- // basic check done, make check in database
- // TODO move it into JTA
- transaction = rootContext.beginTransaction();
-
- // test si un journal de ce nom existe deja
- JournalDAO journalDAO = LimaCallaoDAOHelper.getJournalDAO(transaction);
- Journal existingJournal = journalDAO.findByLabel(journal.getLabel());
- if (existingJournal != null) {
- throw new LimaBusinessException(_("An journal already exists with this label : %s", journal.getLabel()));
- }
-
- // creation du journal
- journalDAO.create(journal);
-
- // commit
- transaction.commitTransaction();
- }
- catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't create journal", ex);
- }
- finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't create journal", ex);
- }
- }
- }
- }
-
- /*
- * Création d'un journal à partir de son DTO.
- * @param journalDTO Journal au format DTO.
- * @return
- *
- public String createJournal(JournalDTO journalDTO) {
- String result;
- result = createJournal(journalDTO.getLabel(), journalDTO.getPrefix(),
- journalDTO.getDescription());
- return result;
- }*/
-
- public List<Journal> getAllJournal() throws LimaException {
- /*List<JournalDTO> listJournalDTO = new ArrayList<JournalDTO>();
-
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- JournalDAO journalDAO = LimaCallaoDAOHelper
- .getJournalDAO(topiaContext);
- // Creation du journal
- List<Journal> listJournal = journalDAO.findAll();
- // Pour chaque journal, on le transforme en DTO
- for (Journal journal : listJournal) {
- // Converti en DTO
- JournalDTO journalDTO = convertJournal
- .journalEntityToDto(journal);
- // Ajoute à la liste
- listJournalDTO.add(journalDTO);
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listJournalDTO;*/
-
- List<Journal> journalsList = new ArrayList<Journal>();
- TopiaContext transaction = null;
- try {
- // basic check done, make check in database
- // TODO move it into JTA
- transaction = rootContext.beginTransaction();
-
- // test si un journal de ce nom existe deja
- JournalDAO journalDAO = LimaCallaoDAOHelper.getJournalDAO(transaction);
- List<Journal> journals = journalDAO.findAll();
- journalsList.addAll(journals);
-
- // commit
- transaction.commitTransaction();
- }
- catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't create journal", ex);
- }
- finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't create journal", ex);
- }
- }
- }
-
- return journalsList;
- }
-
- /*
- * Permet de rechercher un journal existant à partir de son label.
- * ATTENTION : il est possible que plusieurs journaux existent avec ce
- * même label. La méthode renvoie le premier trouvé.
- * @param prefix préfixe du journal recherché
- * @return
- *
- public Journal searchJournalWithLabel(String label) {
- Journal journalResult = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- JournalDAO journalDAO = LimaCallaoDAOHelper
- .getJournalDAO(topiaContext);
- // Creation du journal
- journalResult = journalDAO.findByLabel(label);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return journalResult;
- }*/
-
- /*
- * Permet de rechercher un journal existant à partir du label.
- * Le journal recherché est converti automatiquement en format DTO.
- * @param prefix préfixe du journal recherché
- * @return
- *
- public JournalDTO searchJournalDTOWithLabel(String label) {
- Journal journal = searchJournalWithLabel(label);
- JournalDTO journalDTO = convertJournal.journalEntityToDto(journal);
- return journalDTO;
- }*/
-
- /*
- * Permet de rechercher un journal unique identifé par son topiaId.
- * @param topiaId identifiant du journal recherché
- * @return
- *
- public Journal searchJournalWithTopiaId(String topiaId) {
- Journal journalResult = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- JournalDAO journalDAO = LimaCallaoDAOHelper
- .getJournalDAO(topiaContext);
- // Creation du journal
- journalResult = journalDAO.findByTopiaId(topiaId);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return journalResult;
- }*/
-
- /*
- * Permet de rechercher un journal existant à partir du topiaId.
- * Le journal recherché est converti automatiquement en format DTO.
- * @param prefix préfixe du journal recherché
- * @return
- *
- public JournalDTO searchJournalDTOWithTopiaId(String topiaId) {
- Journal journal = searchJournalWithTopiaId(topiaId);
- JournalDTO journalDTO = convertJournal.journalEntityToDto(journal);
- return journalDTO;
- }*/
-
- /*
- * Permet de modifier un journal.
- * @param label
- * @param prefix
- * @return
- *
- public String modifyJournal(String topiaId, String label, String prefix,
- String description) {
- String result = ServiceHelper.RESPOND_ERROR;
- Journal journalModify = searchJournalWithTopiaId(topiaId);
- // Si le journal n'existe pas
- if (journalModify == null) {
- if (log.isWarnEnabled()) {
- log.warn("Le journal " + label + " n'existe pas !");
- }
- result = ServiceHelper.JOURNAL_NOT_EXIST;
- } else // Sinon on modifie le journal
- {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- JournalDAO journalDAO = LimaCallaoDAOHelper
- .getJournalDAO(topiaContext);
- // Modifie le journal
- journalModify.setPrefix(prefix);
- journalModify.setDescription(description);
- journalDAO.update(journalModify);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- result = ServiceHelper.RESPOND_SUCCESS;
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
- /**
- * Permet d'effacer un journal dans la base de données.
- *
- * ATTENTION : si un journal est associé avec des transactions, il est alors
- * impossible de supprimer celui-ci.
- *
- * @param prefix préfixe du journal à supprimer
- * @return
- * @throws LimaException
- */
- public void removeJournal(Journal journal) throws LimaException {
- /*String result = ServiceHelper.RESPOND_ERROR;
- Journal journalDelete = searchJournalWithTopiaId(topiaId);
- // Si le journal n'existe pas
- if (journalDelete == null) {
- if (log.isWarnEnabled()) {
- log.warn("Le journal " + topiaId + " n'existe pas !");
- }
- result = ServiceHelper.JOURNAL_NOT_EXIST;
- } else // Sinon on efface le journal
- {
-
- // Vérifie si une transaction n'appartient pas à ce journal.
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche au moins une transaction avec ce journal.
- Transaction transaction = transactionDAO
- .findByJournal(journalDelete);
- // Il existe au moins une transaction
- if (transaction != null) {
- if (log.isWarnEnabled()) {
- log.warn("Le journal " + topiaId
- + " possède des transactions comptables !");
- }
- result = ServiceHelper.JOURNAL_WITH_TRANSACTIONS;
- } else {
-
- // Efface le journal
- // Chargement du DAO
- JournalDAO journalDAO = LimaCallaoDAOHelper
- .getJournalDAO(topiaContext);
- // Supprime le journal
- journalDAO.delete(journalDelete);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;*/
-
- TopiaContext topiaTransaction = null;
- try {
- // basic check done, make check in database
- // TODO move it into JTA
- topiaTransaction = rootContext.beginTransaction();
-
- // Vérifie si une transaction n'appartient pas à ce journal.
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
- Transaction transaction = transactionDAO.findByJournal(journal);
- if (transaction != null) {
- throw new LimaBusinessException("Can't delete journal with transactions");
- }
-
- // test si un journal de ce nom existe deja
- JournalDAO journalDAO = LimaCallaoDAOHelper.getJournalDAO(topiaTransaction);
- journalDAO.delete(journal);
-
- // commit
- topiaTransaction.commitTransaction();
- }
- catch (TopiaException ex) {
- if (topiaTransaction != null) {
- try {
- topiaTransaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't create journal", ex);
- }
- finally {
- if (topiaTransaction != null) {
- try {
- topiaTransaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't create journal", ex);
- }
- }
- }
- }
-
- /*
- * Permet d'effacer un journal dans la base de données.
- * ATTENTION : si un journal est associé avec des transactions, il est alors
- * impossible de supprimer celui-ci.
- * @param journalDTO journal au format DTO à supprimer
- * @return
- *
- public String removeJournal(JournalDTO journalDTO) {
- String result = removeJournal(journalDTO.getId());
- return result;
- }*/
-
-}
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 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -20,6 +20,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
@@ -53,6 +54,9 @@
log.error("Can't read configuration", ex);
}
}
+
+ // FIXME put this in another place
+ instance.setOption("topia.persistence.classes", LimaCallaoDAOHelper.getImplementationClassesAsString());
}
return instance;
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/LogServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LogServiceImpl.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LogServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -1,364 +0,0 @@
-/*
- * *##% Callao LogServiceImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.business;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.EntryLog;
-import org.chorem.lima.entity.EntryLogDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-
-/**
- * Permet d'ajouter des logs au systeme.
- *
- * ATTENTION on ne peut supprimer un log.
- *
- * @author Rémi Chapelet
- */
-public class LogServiceImpl { //implements LogService {
-
- /** log */
- private static final org.apache.commons.logging.Log log = LogFactory
- .getLog(LogServiceImpl.class);
-
- private TopiaContext rootContext;
-
-
- public LogServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- /**
- * Création d'un log dans le systeme.
- *
- * @param entryLog date de creation du log
- * @throws LimaException
- */
- public void addLog(EntryLog entryLog) throws LimaException {
- /*String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryLogDAO logDAO = LimaCallaoDAOHelper.getEntryLogDAO(topiaContext);
- // Creation du log
- EntryLog newlog = logDAO.create();
- newlog.setLogDate(logDate);
- newlog.setTransDate(transDate);
- newlog.setVoucherRef(voucherRef);
- newlog.setType(type);
- newlog.setTransDesc(transDesc);
- newlog.setEntryDesc(entryDesc);
- newlog.setAmount(amount);
- newlog.setDebit(debit);
- newlog.setLettering(lettering);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- // Affichage pour les logs
- String topiaId = newlog.getTopiaId();
- if (log.isInfoEnabled()) {
- log.info("Log created: "+ topiaId);
- }
- result = ServiceHelper.RESPOND_SUCCESS;
- }catch (TopiaException e) {
- log.error(e);
- }
- return result;*/
-
- TopiaContext transaction = null;
- try {
- // basic check done, make check in database
- // TODO move it into JTA
- transaction = rootContext.beginTransaction();
-
- // creation
- EntryLogDAO entryLogDAO = LimaCallaoDAOHelper
- .getEntryLogDAO(transaction);
- entryLogDAO.create(entryLog);
-
- // commit
- transaction.commitTransaction();
- } catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't create entry log", ex);
- } finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't create entry log", ex);
- }
- }
- }
- }
-
- /*
- * Création d'un log à partir d'un log DTO.
- * @param logDTO log en format DTO qu'on souhaite créer
- * @return
- *
- public String addLog (LogDTO logDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Vérifie si logDTO existe
- if (logDTO != null)
- {
- result = addLog(logDTO.getLogDate(),logDTO.getTransDate(),logDTO.getType(),
- logDTO.getVoucherRef(),logDTO.getTransDesc(),logDTO.getEntryDesc(),
- logDTO.getAmount(),logDTO.isDebit(),logDTO.getLettering());
- }
- return result;
- }*/
-
- /**
- * Recherche tous les logs dans la base de donnees.
- *
- * @return la liste des logs
- * @throws LimaException
- */
- public List<EntryLog> listeAllLog() throws LimaException {
- /*List<EntryLog> listelog = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryLogDAO logDAO = LimaCallaoDAOHelper
- .getEntryLogDAO(topiaContext);
- // recherche des log
- listelog = logDAO.findAll();
- // Fermeture BDD
- topiaContext.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Search all logs");
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- return listelog;*/
-
- List<EntryLog> entryLogsList = new ArrayList<EntryLog>();
- TopiaContext transaction = null;
- try {
- // basic check done, make check in database
- // TODO move it into JTA
- transaction = rootContext.beginTransaction();
-
- // creation
- EntryLogDAO entryLogDAO = LimaCallaoDAOHelper
- .getEntryLogDAO(transaction);
- List<EntryLog> entryLogs = entryLogDAO.findAll();
- entryLogsList.addAll(entryLogs);
-
- // commit
- transaction.commitTransaction();
- } catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't create entry log", ex);
- } finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't create entry log", ex);
- }
- }
- }
-
- return entryLogsList;
- }
-
- /*
- * Permet de renvoyer tous les logs au format DTO.
- * @return
- *
- public List<LogDTO> listeAllLogDTO() {
- List<LogDTO> listLogDTO = new ArrayList<LogDTO>();
- // On recherche tous les logs.
- List<EntryLog> listLog = listeAllLog();
- // Pour chaque log, on le converti en logDTO et on l'ajoute à la nouvelle liste de DTO
- for (EntryLog log : listLog) {
- // conerti de l'entity en DTO
- LogDTO logDTO = convertLog.logEntityToDto(log);
- // Ajoute à la liste des logs DTO
- listLogDTO.add(logDTO);
- }
- return listLogDTO;
- }*/
-
- /*
- * Renvoie une liste de tous les logs suivant la date de creation
- * @param datecreate date de creation des logs recherchés
- * @return une liste des logs trouves
- *
- public List<EntryLog> searchLogWithDateCreate(Date dateCreate) {
- List<EntryLog> listelog = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryLogDAO logDAO = LimaCallaoDAOHelper
- .getEntryLogDAO(topiaContext);
- // recherche des log
- listelog = logDAO.findAllByLogDate(dateCreate);
- // Fermeture BDD
- topiaContext.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Log(s) find : " + listelog.size() + "log(s)");
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- return listelog;
- }*/
-
- /*
- * Permet de rechercher tous les logs suivant la date de création, c'est à
- * dire de l'opération effectuée sur une entry à un jour précis, et qui a
- * déclenchée automatiquement une création de log.
- * La méthode renvoie sous forme de liste, en convertissant les objets
- * entitys en DTO.
- * @param dateCreate date de création des logs recherchés
- * @return
- *
- public List<LogDTO> searchLogDTOWithDateCreate(Date dateCreate) {
- List<LogDTO> listLogDTO = new ArrayList<LogDTO>();
- // On recherche tous les logs suivant la date de création.
- List<EntryLog> listLog = searchLogWithDateCreate(dateCreate);
- // Pour chaque log, on le converti en logDTO et on l'ajoute à la nouvelle liste de DTO
- for (EntryLog log : listLog) {
- // conerti de l'entity en DTO
- LogDTO logDTO = convertLog.logEntityToDto(log);
- // Ajoute à la liste des logs DTO
- listLogDTO.add(logDTO);
- }
- return listLogDTO;
- }*/
-
- /*
- * Recherche un log avec son identifiant topiaId.
- * @param topiaId identifiant d'un log
- * @return
- *
- public EntryLog searchLogWithTopiaId(String topiaId) {
- EntryLog logSearch = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryLogDAO logDAO = LimaCallaoDAOHelper
- .getEntryLogDAO(topiaContext);
- // Creation du journal
- logSearch = logDAO.findByTopiaId(topiaId);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return logSearch;
- }*/
-
- /*
- * Efface un log : uniquement utilisé pour supprimer les logs dans les tests
- * unitaires.
- * @param topiaId identifiant du log à supprimer
- * @return
- *
- public String removeLog(String topiaId) {
- String result = ServiceHelper.RESPOND_ERROR;
- EntryLog logDelete = searchLogWithTopiaId(topiaId);
- // Si le log n'existe pas
- if (logDelete == null) {
- if (log.isWarnEnabled()) {
- log.warn("Le log " + topiaId + " n'existe pas !");
- }
- } else // Sinon on efface le log
- {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryLogDAO logDAO = LimaCallaoDAOHelper
- .getEntryLogDAO(topiaContext);
- // Supprime le log
- logDAO.delete(logDelete);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- result = ServiceHelper.RESPOND_SUCCESS;
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
- /*
- * Permet de supprimer un log à partir de son DTO.
- * @param logDTO log à supprimer
- * @return
- *
- public String removeLog(LogDTO logDTO) {
- String result = removeLog(logDTO.getId());
- return result;
- }*/
-}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/PeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/PeriodServiceImpl.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/PeriodServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -1,504 +0,0 @@
-/*
- * *##% Callao PeriodServiceImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.business;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Period;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaNotFoundException;
-
-/**
- * Gestion des périodes.
- * Chaque période doit posséder 12 timespans mensuels.
- * Une période ne peut être supprimée et débloquée.
- *
- * @author Rémi Chapelet
- */
-public class PeriodServiceImpl { //implements PeriodService {
-
- private static final Log log = LogFactory.getLog(PeriodServiceImpl.class);
-
- private TopiaContext rootContext;
-
- private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
-
- public PeriodServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- /**
- * Permet de créer une période principale. Elle a une durée de un an,
- * composées de 12 périodes mensuelles. Elle correspond à l'exercice
- * comptable. Pour créer une nouvelle période, la précédente doit être
- * obligatoirement clôturée.
- * @param beginTimeSpan date début de période
- * @param endTimeSpan date fin de période
- * @param lock Vrai si la période est bloquée
- * @return
- */
- public void createPeriod(Period period /*Date beginTimeSpan, Date endTimeSpan, boolean lock*/) {
- /*// Par défaut lock est à false
- lock = false;
- String result = ServiceHelper.RESPOND_ERROR;
-
- try {
- boolean correctPeriod = false;
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Creation de la periodDate
- PeriodDates newPeriod = new PeriodDates(beginTimeSpan, endTimeSpan);
-
- // Creation de la période
- Period period = periodDAO.create();
- period.setBeginPeriod(newPeriod.getFromDate());
- period.setEndPeriod(newPeriod.getThruDate());
- period.setLocked(lock);
- // Vérification si la période est correcte
- correctPeriod = isCorrectPeriod(period);
- if (correctPeriod) {
- // Si elle est correcte : Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Ajout exercice du " + beginTimeSpan.toString()
- + " au " + endTimeSpan.toString());
- }
-
- //Ajout des timeSpans mensuels
- //Par défaut, il prend seulement la date beginTimeSpan, et calcule
- //la date de fin, c'est pourquoi il est laissé deux fois "beginTimeSpan"
- TimeSpanServiceImpl timeSpanImpl = new TimeSpanServiceImpl();
- boolean stop = false; // En cas d'erreur lors de la création d'un timeSpan.
-
- List<Date> monthList = newPeriod.getMonths();
-
- int max = monthList.size();
- log.debug("la periode fait:" + max);
- for (int i = 0; i < max; i++) {
- // Création timeSpan
- result = timeSpanImpl.createTimeSpan(monthList.get(i),
- monthList.get(i), period, false);
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- stop = true;
- if (log.isErrorEnabled()) {
- log.error("Erreur lors de la création des " + max
- + " timeSpans");
- }
- result = ServiceHelper.PERIOD_CREATE_TIMESPANS;
- }
- // Supprimer la periode si stop = true
- }
- if (stop == false) {
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result; */
- }
-
- /*
- * Permet de créer une période à partir d'une période DTO.
- * @param periodDTO période à créer au format DTO.
- * @return
- *
- public String createPeriod(PeriodDTO periodDTO) {
- String result = createPeriod(periodDTO.getBeginPeriod(), periodDTO
- .getEndPeriod(), false);
- // Tous les timeSpans sont automatiquement créés avec la méthode createPeriod
- return result;
- }*/
-
- /*
- * Permet de vérifier si la période est correcte (aucun chevauchement avec
- * les autres périodes, période(s) précédente(s) bloquée(s), formée de 1 à 24
- * mois).
- * @param period période à tester si elle est correcte
- * @return
- *
- private boolean isCorrectPeriod(Period period) {
- // Calcul du nombre de mois pour que la période soit valide (12 mois)
- int number_months = dateUtil.numberOfMonths(period.getBeginPeriod(),
- period.getEndPeriod());
- boolean result = true;
-
- if (number_months == 0 && number_months >= 24) // Periode de 1mois a 24 mois
- {
- if (log.isErrorEnabled()) {
- log.error("Période du "
- + period.getBeginPeriod()
- + " au "
- + period.getEndPeriod()
- + " : L'exercice doit faire au minimum 1 mois et au maximum 24 mois");
- }
- result = false;
- } else {
- // Période(s) précédente(s) bloquée(s).
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Recherche les périodes qui ne sont pas bloquées.
- List<Period> listePeriod = periodDAO.findAllByLocked(false);
- // Recherche la dernière période, les dates doivent se suivre
- Date date_search = period.getBeginPeriod();
- Period previousPeriod = periodDAO.findByEndPeriod(dateUtil
- .previousDay(date_search));
- // Nombre de périodes dans la base
- int number_period = periodDAO.findAll().size();
- // Fermeture BDD
- topiaContext.closeContext();
- // Si il y a au moins une période trouvée
- if (!(listePeriod.isEmpty())) {
- if (log.isErrorEnabled()) {
- log.error("Il existe au moins une période précédente non bloquée !");
- }
- result = false;
- }
- // Si la période précédente correspond au jour précédent
- // et vérifie si ce n'est pas la première période
- if (previousPeriod == null && number_period != 0) {
- if (log.isErrorEnabled()) {
- log.error("Votre période doit être collée "
- + "aux autres périodes !"
- + date_search.toString() + " PPP "
- + dateUtil.previousDay(date_search).toString());
- }
- result = false;
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
- /*
- * Cette méthode permet de bloquer une période. Elle doit vérifier que
- * tous les timeSpans mensuels sont bloqués.
- * @param
- * @return
- *
- public String blockPeriod(Period period) {
- String result = ServiceHelper.RESPOND_ERROR;
- // La période ne doit pas être nulle
- if (period != null) {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Recherche tous les timeSpans de la période non bloquées
- List<TimeSpan> listeTimeSpan = timeSpanDAO
- .findAllByPeriod(period);
- boolean existTimeSpanNotBlock = false;
- for (TimeSpan timeSpan : listeTimeSpan) {
- // Si timeSpan non bloqué
- if (!timeSpan.getLocked()) {
- existTimeSpanNotBlock = true;
- if (log.isErrorEnabled()) {
- log.error("Le timeSpan du "
- + timeSpan.getBeginTimeSpan().toString()
- + " au "
- + timeSpan.getEndTimeSpan().toString()
- + " non bloqué !");
- }
- result = ServiceHelper.PERIOD_TIMESPAN_NOT_BLOCK;
- }
- }
- // Si il n'existe pas de timeSpan non bloqué
- if (!(existTimeSpanNotBlock)) {
- // Bloque la période
- period.setLocked(true);
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- periodDAO.update(period);
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- if (log.isInfoEnabled()) {
- log.info("Période "
- + period.getBeginPeriod().toString() + " au "
- + period.getEndPeriod().toString()
- + " bloquée avec succès.");
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
- /*
- * Permet de bloquer une période. Avec la périodeDTO passée en paramètre, on
- * effectue une recherche avec la date de début pour récupérer la période
- * dans la base de données. Il est possible de l'identifier avec son topiaId,
- * mais il y a plus de risque que cette mentien ne soit pas renseignée dans
- * l'objet periodDTO.
- * @param periodDTO
- * @return
- *
- public String blockPeriod(PeriodDTO periodDTO) {
- // Recherche de la période
- Period period = searchPeriodWithDate(periodDTO.getBeginPeriod());
- String result = blockPeriod(period);
- return result;
- }*/
-
- /*
- * Permet de bloquer TOUS les timeSpans de la période
- * @param period
- * @return
- *
- public String blockAllTimeSpanOfPeriod(Period period) {
- String result = ServiceHelper.RESPOND_ERROR;
- if (period == null) {
- if (log.isErrorEnabled()) {
- log.error("La période ne peut bloquer ses périodes mensuelles, "
- + "il faut une période en entrée.");
- }
- } else {
- // On bloque chaque timeSpan
- boolean ErrorBlockTimeSpan = false;
- List<TimeSpanDTO> listTimeSpanDTO = timeSpanServiceImpl
- .searchListTimeSpanDTO(period);
- // tri la liste des timeSpans dans l'ordre croissant des dates
- Collections.sort(listTimeSpanDTO);
- for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
- result = timeSpanServiceImpl.blockTimeSpan(timeSpanDTO);
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- ErrorBlockTimeSpan = true;
- }
- }
- // Si il n'y a pas eu d'erreurs pour bloquer les timespans
- if (!ErrorBlockTimeSpan) {
- result = ServiceHelper.RESPOND_SUCCESS;
- } else {
- if (log.isErrorEnabled()) {
- log.error("Impossible de bloquer tous les timeSpans.");
- }
- result = ServiceHelper.PERIOD_ALL_TIMESPAN;
- }
- }
- return result;
- }*/
-
- /*
- * Cette méthode est semblable à searchPeriodWithDateFirst. Elle permet
- * de rechercher une période sans forcément connaître la date de départ. On
- * donne une date quelconque, et elle retourne la période correspondante.
- * @param d
- * @return
- *
- public Period searchPeriodWithDate(Date d) {
- Period period = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Recherche de toutes les périodes
- List<Period> listePeriod = periodDAO.findAll();
- // Fermeture BDD
- topiaContext.closeContext();
- // Recherche de la période
- for (Period periodSearch : listePeriod) {
- // Recherche si la date d est entre la date de début et fin de la période
- boolean periodBetweenDate = dateUtil.betweenDate(d,
- periodSearch.getBeginPeriod(), periodSearch
- .getEndPeriod());
- // Si la date est comprise dans les limites de la période
- if (periodBetweenDate) {
- period = periodSearch;
- }
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- return period;
- }*/
-
- /*
- * Permet de rechercher une période au format DTO avec une date. Cette date
- * peut être quelconque (pas obligatoire d'être le premier jour de la période
- * par exemple).
- * @param d date comprise dans la période qu'on souhaite rechercher
- * @return
- *
- public PeriodDTO searchPeriodDTOWithDate(Date d) {
- Period period = searchPeriodWithDate(d);
- // Converti la période en PeriodDTO
- PeriodDTO periodDTO = convertPeriod.periodEntityToDto(period);
- return periodDTO;
- }*/
-
- /*
- * Permet de renvoyer tous les périodes en format DTO, avec tous les timeSpans
- * en format DTO également.
- * @return
- *
- public List<PeriodDTO> getAllPeriod() {
- ArrayList<PeriodDTO> listAllPeriodDTO = new ArrayList<PeriodDTO>();
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Recherche de toutes les périodes
- List<Period> listePeriod = periodDAO.findAll();
- // Transforme les périodes en DTO
- for (Period period : listePeriod) {
- PeriodDTO periodDTO = convertPeriod.periodEntityToDto(period);
- listAllPeriodDTO.add(periodDTO);
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listAllPeriodDTO;
- }*/
-
- /*
- * Recherche une période précise, avec son identifiant topiaId.
- * @param topiaId identifiant de la période
- * @return
- *
- public Period searchPeriodWithTopiaId(String topiaId) {
- Period periodSearch = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Creation du journal
- periodSearch = periodDAO.findByTopiaId(topiaId);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return periodSearch;
- }*/
-
-
- /*
- * Efface une période dans la base de données. Tous les timeSpans sont
- * également effacés. Cette méthode est uniquement utilisée pour les tests
- * unitaires.
- * @param period
- * @return
- *
- public String removePeriod(String topiaId) {
- String result = ServiceHelper.RESPOND_ERROR;
- Period periodDelete = searchPeriodWithTopiaId(topiaId);
- // Si la période n'existe pas
- if (periodDelete == null) {
- if (log.isWarnEnabled()) {
- log.warn("La période " + topiaId + " n'existe pas !");
- }
- result = ServiceHelper.PERIOD_NOT_EXIST;
- } else // Sinon on efface la période
- {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Débloque la période
- periodDelete.setLocked(false);
- // Mise à jour dans la bdd
- periodDAO.update(periodDelete);
- // Création BDD
- topiaContext.commitTransaction();
-
- // Supprime les timeSpans de la période
- List<TimeSpanDTO> listTimeSpanDTO = timeSpanServiceImpl
- .searchListTimeSpanDTO(periodDelete);
- // tri la liste des timeSpans dans l'ordre décroissant des dates
- Collections.sort(listTimeSpanDTO, Collections.reverseOrder());
- // Débloque les timeSpans
- for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
- TimeSpan timeSpan = timeSpanServiceImpl
- .searchTimeSpanByDate(timeSpanDTO);
- // Si le timeSpan est bloqué
- if (timeSpanDTO.isLocked()) {
- // débloque le timeSpan
- timeSpanServiceImpl.unblockTimeSpan(timeSpan);
- }
- }
- // Efface les timeSpans
- for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
- TimeSpan timeSpan = timeSpanServiceImpl
- .searchTimeSpanByDate(timeSpanDTO);
- // efface le timeSpan
- timeSpanServiceImpl.removeTimeSpan(timeSpan);
- }
-
-
- //Supprime la période
- periodDAO.delete(periodDelete);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- result = ServiceHelper.RESPOND_SUCCESS;
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
- /*
- * Permet d'effacer une période au format DTO.
- * @param periodDTO la période à supprimer
- * @return
- *
- public String removePeriod(PeriodDTO periodDTO) {
- String result = removePeriod(periodDTO.getId());
- return result;
- }*/
-}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceImpl.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -1,61 +0,0 @@
-package org.chorem.lima.business;
-
-import org.nuiton.topia.TopiaContext;
-
-public class ReportServiceImpl { //implements ReportService {
-
- //@Override
- public String generateAccount(String number, String amount, String label) {
- // TODO Auto-generated method stub
- return null;
- }
-
- //@Override
- public String generateBalanceSheet(String period) {
- // TODO Auto-generated method stub
- return null;
- }
-
- //@Override
- public String generateCashFlowStatement(String period) {
- // TODO Auto-generated method stub
- return null;
- }
-
- //@Override
- public String generateGeneralLedger(String period) {
- // TODO Auto-generated method stub
- return null;
- }
-
- //@Override
- public String generateIncomeStatement(String period) {
- // TODO Auto-generated method stub
- return null;
- }
-
- //@Override
- public String generateJournal(String type, String period) {
- // TODO Auto-generated method stub
- return null;
- }
-
- //@Override
- public String[] getMethods() {
- // TODO Auto-generated method stub
- return null;
- }
-
- //@Override
- public void destroy() {
- // TODO Auto-generated method stub
-
- }
-
- //@Override
- public void init(TopiaContext arg0) {
- // TODO Auto-generated method stub
-
- }
-
-}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/TimeSpanServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/TimeSpanServiceImpl.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/TimeSpanServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -1,533 +0,0 @@
-/*
- * *##% Callao TimeSpanServiceImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.business;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.TimeSpan;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaNotFoundException;
-
-/**
- * Gestion des périodes intermédiaires durant l'exercice.
- * Chaque timeSpan sera fixe, et devra correspondre à un mois complet.
- *
- * @author Rémi Chapelet
- */
-public class TimeSpanServiceImpl { //implements TimeSpanService {
-
- /** log */
- private static final Log log = LogFactory.getLog(TimeSpanServiceImpl.class);
-
- private TopiaContext rootContext;
-
- private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
-
- public TimeSpanServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- /**
- * Création d'une période timeSpan mensuelle avec une date de début et de fin. Une période
- * peut être bloquée ou non.
- * @param beginTimeSpan date de début de période
- * @param endTimeSpan date de fin de période
- * @param locked est à vrai si la période doit être bloquée.
- * @return
- */
- public void createTimeSpan(TimeSpan timeSpan /*Date beginTimeSpan, Date endTimeSpan,
- Period period, boolean locked*/) {
-/*
- // timeSpan correspond à une période mensuelle.
- // La fonction va donc prendre seulement pour date de référence la
- // date beginTimeSpan. Elle calcule automatiquement la date de fin
- // suivant le mois.
- DateUtil dateutil = new DateUtil();
- // Initialise la date de début au premier du mois
- beginTimeSpan = dateutil.InitDateFirstDayMonth(beginTimeSpan);
- // Initialise la date de fin au dernier du mois
- endTimeSpan = dateutil.InitDateEndDayMonth(beginTimeSpan);
- if (log.isInfoEnabled()) {
- log.info("Nouveau timeSpan du " + beginTimeSpan.toString() + " au "
- + endTimeSpan.toString());
- }
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Creation du timespan
- TimeSpan newtimeSpan = timeSpanDAO.create();
- newtimeSpan.setBeginTimeSpan(beginTimeSpan);
- newtimeSpan.setEndTimeSpan(endTimeSpan);
- newtimeSpan.setLocked(locked);
- newtimeSpan.setPeriod(period);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Ajout avec succes du timeSpan");
- }
- return ServiceHelper.RESPOND_SUCCESS;
- } catch (TopiaException e) {
- log.error(e);
- return ServiceHelper.RESPOND_ERROR;
- }*/
- }
-
- /*
- * Permet de trouver un timespan directement avec une date. La date peut
- * être quelconque. Exemple : d = 17 sept 2000, renvoie la période du
- * 1 sept au 30 sept 2000.
- * @param d
- * @return
- *
- public TimeSpan searchTimeSpanByDate(Date d) {
- TimeSpan timeSpan = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Par précaution, on initialise la date au debut du mois
- DateUtil dateutil = new DateUtil();
- // Recherche du timeSpan
- Date searchDate = dateutil.InitDateFirstDayMonth(d);
- timeSpan = timeSpanDAO.findByBeginTimeSpan(searchDate);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return timeSpan;
- }*/
-
- /*
- * Recherche un timeSpan précis, avec sa date de création.
- * @param timeSpanDTO timeSpan au format DTO qu'on recherche
- * @return
- *
- public TimeSpan searchTimeSpanByDate(TimeSpanDTO timeSpanDTO) {
- TimeSpan timeSpan = searchTimeSpanByDate(timeSpanDTO.getBeginTimeSpan());
- return timeSpan;
- }*/
-
- /*
- * Recherche un timeSpan UNIQUE. Celui est identifié par son topiaId.
- * @param topiaId Identifiant du timeSpan recherché
- * @return
- *
- public TimeSpan searchTimeSpanWithTopiaId(String topiaId) {
- TimeSpan timeSpan = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Recherche du timeSpan
- timeSpan = timeSpanDAO.findByTopiaId(topiaId);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return timeSpan;
- }*/
-
- /*
- * Permet de rechercher un timeSpan à l'aide d'une date. Il fait appel
- * à la méthode searchTimeSpanByDate.
- * La méthode renvoie un objet DTO.
- * @param d
- * @return
- *
- public TimeSpanDTO searchTimeSpanDTOByDate(Date d) {
- TimeSpan timeSpan = searchTimeSpanByDate(d);
- TimeSpanDTO timeSpanDTO = convertTimeSpan.timeSpanEntityToDto(timeSpan);
- return timeSpanDTO;
- }*/
-
- /*
- * Permet de faire une recherche de tous les timeSpans d'une période.
- * @param period
- * @return
- *
- public List<TimeSpan> searchListTimeSpan(Period period) {
- List<TimeSpan> listTimeSpan = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Recherche les timeSpans avec cette période
- listTimeSpan = timeSpanDAO.findAllByPeriod(period);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listTimeSpan;
- }*/
-
- /*
- * Permet de rechercher tous les timeSpans suivant une période donnée.
- * Chaque timeSpan est converti ensuite en DTO.
- * @param period
- * @return
- *
- public List<TimeSpanDTO> searchListTimeSpanDTO(Period period) {
- List<TimeSpanDTO> listTimeSpanDTO = new ArrayList<TimeSpanDTO>();
- List<TimeSpan> listTimeSpan = searchListTimeSpan(period);
- for (TimeSpan timeSpan : listTimeSpan) {
- TimeSpanDTO timeSpanDTO = convertTimeSpan
- .timeSpanEntityToDto(timeSpan);
- listTimeSpanDTO.add(timeSpanDTO);
- }
- return listTimeSpanDTO;
- }*/
-
- /*
- * Permet de bloquer un timespan, celle-ci ne doit pas être bloquée.
- * La fonction doit s'assurer que les timeSpans précédents doivent être
- * bloqués.
- * Les transactions doivent être équilibrées
- * @param timespan période qui doit être fermée
- * @param period période (12 smois)
- *
- public String blockTimeSpan(TimeSpan timespan) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Si la période n'est pas déjà fermée.
- if (timespan.getLocked()) {
- if (log.isInfoEnabled()) {
- log.info("Timespan deja bloqué !");
- }
- } else {
- Period period = getPeriodWithTimeSpan(timespan);
- if (period.getLocked()) {
- if (log.isErrorEnabled()) {
- log.error("La période du timespan est bloquée !");
- }
- } else {
- // Vérifie si tous les timeSpans précédents sont bloqués
- boolean AllTimeSpanBlock = alltimeSpanBlocked(timespan, period);
- if (AllTimeSpanBlock) {
- // Enregistrement dans la base de données
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext
- .beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
-
- // Vérifie si les transactons sont équilibrées
- List<Transaction> listTransaction = transactionServiceImpl
- .searchListTransactionWithTimeSpan(timespan);
- boolean isTransactionBalanced = true;
- boolean existTransactionNotBalanced = false;
- for (Transaction transaction : listTransaction) {
- isTransactionBalanced = transactionServiceImpl
- .isTransactionBalanced(transaction);
- if (!isTransactionBalanced) {
- if (log.isInfoEnabled()) {
- log.info("La transaction n'est pas bloquée.");
- }
- existTransactionNotBalanced = true;
- }
- }
- if (!existTransactionNotBalanced) {
- // Bloque la période
- timespan.setLocked(true);
- // Mise à jour de timespan dans la BDD
- timeSpanDAO.update(timespan);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Timespan bloqué avec succès");
- }
- result = ServiceHelper.RESPOND_SUCCESS;
- } else {
- result = ServiceHelper.TRANSACTION_NOT_BALANCED;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- } else {
- if (log.isErrorEnabled()) {
- log.error("Il existe un ou plusieurs timespans précédents"
- + " non bloqués.");
- }
- result = ServiceHelper.TIMESPAN_PREC_NOT_BLOCK;
- }
- }
- }
- return result;
- }*/
-
- /*
- * Permet de bloquer une période au format DTO.
- *
- * @param timespanDTO
- * @return
- *
- public String blockTimeSpan(TimeSpanDTO timespanDTO) {
- return blockTimeSpan(searchTimeSpanByDate(timespanDTO));
- }*/
-
- /*
- * Permet de débloquer un timespan, à condition que les timespans suivants
- * celui-ci soient bien débloqués.
- * @param timespan
- * @param period
- * @return
- *
- public String unblockTimeSpan(TimeSpan timespan) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Si le timspan n'est pas bloqué
- if (!timespan.getLocked()) {
- if (log.isWarnEnabled()) {
- log.warn("Timespan non bloqué !");
- }
- } else {
- Period period = getPeriodWithTimeSpan(timespan);
- if (period.getLocked()) {
- if (log.isErrorEnabled()) {
- log.error("La période du timespan est bloquée !");
- }
- } else {
- boolean NextTimeSpanUnblock = nextTimeSpanUnblock(timespan,
- period);
- // Si aucun timespan suivant bloqué
- if (NextTimeSpanUnblock) {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext
- .beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // débloque la période
- timespan.setLocked(false);
- // Mise à jour de timespan dans la BDD
- timeSpanDAO.update(timespan);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Timespan débloqué avec succès");
- }
- result = ServiceHelper.RESPOND_SUCCESS;
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- } else {
- result = ServiceHelper.TIMESPAN_NEXT_NOT_BLOCK;
- }
- }
- }
- return result;
- }*/
-
- /*
- * Permet de bloquer une période au format DTO.
- *
- * @param timespanDTO
- * @return
- *
- public String unblockTimeSpan(TimeSpanDTO timespanDTO) {
- return unblockTimeSpan(searchTimeSpanByDate(timespanDTO));
- }*/
-
- /*
- * Cette méthode va rechercher tous les timeSpans non bloqués après
- * le timeSpan renseigné en paramètre.
- * Si elle trouve au moins un timeSpan NON bloqué, elle renvoie alors faux.
- * Cette méthode permet essentiellement de définir si il est possible
- * ou non de bloquer un timeSpan. A savoir, un timeSpan ne peut être bloqué,
- * si il existe des timeSpans suivant (dans le calendrier) qui sont non
- * bloqués.
- * @param timespan
- * @param period
- * @return
- *
- private boolean nextTimeSpanUnblock(TimeSpan timespan, Period period) {
- boolean NextTimeSpanUnblock = false;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Recherche des TimeSpans avec la même période.
- // (on doit récupérer normalement 12 timeSpans)
- List<TimeSpan> listeTimeSpanOfPeriod = timeSpanDAO
- .findAllByPeriod(period);
- NextTimeSpanUnblock = true;
- for (TimeSpan timeSpanNext : listeTimeSpanOfPeriod) {
- // Si le timespan est après celui qu'on souhaite bloquer ET est non bloqué
- if (timeSpanNext.getBeginTimeSpan().compareTo(
- timespan.getBeginTimeSpan()) == 1
- && timeSpanNext.getLocked()) {
- NextTimeSpanUnblock = false;
- if (log.isInfoEnabled()) {
- log.info("Timespan " + timeSpanNext.toString()
- + " est bloqué");
- }
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return NextTimeSpanUnblock;
- }*/
-
- /*
- * Permet de renvoyer une période dont appartient le timeSpan.
- * @param timeSpan timeSpan dont on souhaite retourner la période
- * @return
- *
- private Period getPeriodWithTimeSpan(TimeSpan timeSpan) {
- PeriodServiceImpl periodServiceImpl = new PeriodServiceImpl();
- Date beginTimeSpan = timeSpan.getBeginTimeSpan();
- Period period = periodServiceImpl.searchPeriodWithDate(beginTimeSpan);
- return period;
- }*/
-
- /*
- * Cette méthode renvoie vrai lorsque tous les timespans de la période
- * précédent au timespan en paramètre sont bloqués.
- * @param timespan
- * @param period le paramètre period est important, en effet un timespan ne
- * peut être indépendant.
- * @return
- *
- private boolean alltimeSpanBlocked(TimeSpan timespan, Period period) {
- boolean AllTimeSpanBlock = false;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Recherche des TimeSpans avec la même période.
- // (on doit récupérer normalement 12 timeSpans)
- List<TimeSpan> listeTimeSpanOfPeriod = timeSpanDAO
- .findAllByPeriod(period);
- // Fermeture BDD
- topiaContext.closeContext();
- // On contrôle que les timeSpans précédents sont bloqués.
- AllTimeSpanBlock = true;
- for (TimeSpan timeSpanPrev : listeTimeSpanOfPeriod) {
- // Si la période est avant celle qu'on souhaite bloquer ET est non bloquée
- if (timeSpanPrev.getBeginTimeSpan().compareTo(
- timespan.getBeginTimeSpan()) == -1
- && !timeSpanPrev.getLocked()) {
- AllTimeSpanBlock = false;
- if (log.isInfoEnabled()) {
- log.info("Timespan " + timeSpanPrev.toString()
- + " non bloqué");
- }
- }
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- return AllTimeSpanBlock;
- }*/
-
- /*
- * Permet d'effacer un timeSpan. Ce dernier ne doit pas être bloqué.
- * @param timeSpan
- * @return
- *
- public String removeTimeSpan(TimeSpan timeSpan) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Si le timspan est bloqué
- if (timeSpan.getLocked()) {
- if (log.isWarnEnabled()) {
- log.warn("Timespan bloqué !");
- }
- } else {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Mise à jour de timespan dans la BDD
- timeSpanDAO.delete(timeSpan);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Timespan supprimé avec succès");
- }
- result = ServiceHelper.RESPOND_SUCCESS;
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
- /*
- * Vérifie si le timeSpan donné en paramètre est bloqué ou non.
- * @param timeSpan
- * @return
- *
- public boolean isTimeSpanBlocked(TimeSpan timeSpan) {
- boolean isTimeSpanBlocked = true;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Mise à jour de timespan dans la BDD
- TimeSpan timeSpanSearch = timeSpanDAO.findByTopiaId(timeSpan
- .getTopiaId());
- isTimeSpanBlocked = timeSpanSearch.getLocked();
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return isTimeSpanBlocked;
- }*/
-}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionServiceImpl.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -1,745 +0,0 @@
-/*
- * *##% Callao TransactionServiceImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.business;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.dto.EntryDTO;
-import org.chorem.lima.business.dto.LogDTO;
-import org.chorem.lima.business.dto.TransactionDTO;
-import org.chorem.lima.business.utils.ServiceHelper;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryDAO;
-import org.chorem.lima.entity.Journal;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.TimeSpan;
-import org.chorem.lima.entity.Transaction;
-import org.chorem.lima.entity.TransactionDAO;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-
-/**
- * Cette classe permet la création d'une transaction comptable dans l'application.
- * Toute action sur une transaction entraîne automatiquement une création de log.
- * Une transaction est composée d'entrées comptables.
- * Les actions sur les transactions sont soumises au statut de celle-ci, si elle
- * est dans une période bloquée ou non.
- *
- * @author Rémi Chapelet
- */
-public class TransactionServiceImpl {
-
- private static final Log log = LogFactory
- .getLog(TransactionServiceImpl.class);
-
- private TopiaContext rootContext;
-
- private LogServiceImpl logServiceImpl = new LogServiceImpl();
-
- private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
-
- private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
-
- public TransactionServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- /**
- * Permet de créer une transaction comptable. Pour ajouter une transaction,
- * le timeSpan doit être non bloqué.
- * @param entryDate
- * @param voucherRef
- * @param description
- * @param timespan
- * @param journal
- * @return
- */
- public void createTransaction(Transaction transaction /*Date entryDate, String voucherRef,
- String description, TimeSpan timeSpan, Journal journal*/) {
- /*String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- String isCorrectTransaction = isCorrectTransaction(timeSpan,
- journal);
- if (isCorrectTransaction.equals(ServiceHelper.RESPOND_SUCCESS)) {
- // Creation de la transaction
- Transaction newtransaction = transactionDAO.create();
- newtransaction.setTransDate(entryDate);
- newtransaction.setVoucherRef(voucherRef);
- newtransaction.setDescription(description);
- newtransaction.setTimeSpan(timeSpan);
- newtransaction.setJournal(journal);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Ajout avec succes de la transaction");
- }
-
- // Il renvoie soit l'identifiant topiaId ou SUCCESS.
- result = newtransaction.getTopiaId();
- //result = ServiceHelper.RESPOND_SUCCESS;
- } else {
- result = isCorrectTransaction;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;*/
- }
-
- /*
- * Permet de créer une transaction à partir d'une transaction DTO.
- * ATTENTION : si le journal ou timespan n'existe pas, l'ajout ne peut se
- * faire. Si on souhaite, on peut créer le journal automatiquement lors de
- * l'ajout de la transaction si il n'existe pas. Pour le timeSpan, il n'est
- * pas cohérent qu'il n'existe pas. On ne peut travailler que sur une période
- * comptable existante, et par conséquent il ne faut pas le créer.
- * @param transactionDTO
- * @return
- *
- public String createTransaction(TransactionDTO transactionDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Vérifie que transactionDTO possède un journalDTO et un timeSpanDTO
- if (transactionDTO.getJournalDTO() == null
- || transactionDTO.getTimeSpanDTO() == null) {
- if (log.isErrorEnabled()) {
- log.error("L'objet transactionDTO ne possède pas de timeSpan ET/OU de journal.");
- }
- result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
- } else {
- // Recherche du journal
- JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
- Journal journal = journalServiceImpl
- .searchJournalWithLabel(transactionDTO.getJournalDTO()
- .getLabel());
- // Recherche du timeSpan
- TimeSpan timeSpan = timeSpanServiceImpl
- .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
- .getBeginTimeSpan());
-
- // Vérification si timeSpan et Journal existe bien
- if (journal == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le journal "
- + transactionDTO.getJournalDTO().getLabel()
- + " n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
- } else {
- if (timeSpan == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le timeSpan "
- + transactionDTO.getTimeSpanDTO().toString()
- + " n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
- } else {
- result = createTransaction(transactionDTO.getEntryDate(),
- transactionDTO.getVoucherRef(), transactionDTO
- .getDescription(), timeSpan, journal);
- }
- }
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une transaction. Cette dernière est identifiée par la
- * clé topiaId.
- * @param topiaId
- * @param entryDate
- * @param voucherRef
- * @param description
- * @param timespan
- * @param journal
- * @return
- *
- public String modifyTransaction(String topiaId, Date entryDate,
- String voucherRef, String description, TimeSpan timeSpan,
- Journal journal) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Vérification que la transaction existe bien
- Transaction transaction = transactionDAO.findByTopiaId(topiaId);
- if (transaction == null) {
- if (log.isInfoEnabled()) {
- log.info("La transaction " + voucherRef
- + " n'existe pas. (identifiant " + topiaId + ")");
- }
- result = ServiceHelper.TRANSACTION_NOT_EXIST;
- } else {
- // Vérification si la transaction possède de bons paramètres
- String correct = isCorrectTransaction(timeSpan, journal);
- // Si la transaction est correcte
- if (correct.equals(ServiceHelper.RESPOND_SUCCESS)) {
- // Modification
- transaction.setTransDate(entryDate);
- transaction.setVoucherRef(voucherRef);
- transaction.setDescription(description);
- transaction.setTimeSpan(timeSpan);
- transaction.setJournal(journal);
- transaction.update();
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une transaction à partir d'une transaction DTO.
- * Elle va rechercher le journal et le timespan correspondants.
- * @param transactionDTO
- * @return
- *
- public String modifyTransaction(TransactionDTO transactionDTO) {
- // Recherche du journal
- JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
- Journal journal = journalServiceImpl
- .searchJournalWithLabel(transactionDTO.getJournalDTO()
- .getLabel());
- // Recherche du timeSpan
- TimeSpan timeSpan = timeSpanServiceImpl
- .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
- .getBeginTimeSpan());
- // Appel pour la modification
- String result = modifyTransaction(transactionDTO.getId(),
- transactionDTO.getEntryDate(), transactionDTO.getVoucherRef(),
- transactionDTO.getDescription(), timeSpan, journal);
- return result;
- }*/
-
- /*
- * Recherche une transaction unique avec son identifiant TopiaId.
- * @param topiaId
- * @return
- *
- public Transaction searchTransactionWithTopiaId(String topiaId) {
- Transaction transaction = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- transaction = transactionDAO.findByTopiaId(topiaId);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return transaction;
- }*/
-
- /*
- * Recherche une transaction unique à partir d'une transaction DTO.
- * @param transactionDTO
- * @return
- *
- public Transaction searchTransactionWithTopiaId(
- TransactionDTO transactionDTO) {
- Transaction transaction = searchTransactionWithTopiaId(transactionDTO
- .getId());
- return transaction;
- }*/
-
- /*
- * Recherche une transaction dans la base de données, et renvoie celle-ci
- * sous format DTO. Nous ne pouvons pas appeler la méthode searchTransactionWithTopiaId
- * du fait que lors de la convertion, nous avons besoin du journal et du
- * timeSpan. Or il ne faut donc pas de fermeture de connexion à la base de
- * données pour celà.
- * @param topiaId
- * @return
- *
- public TransactionDTO searchTransactionDTO(String topiaId) {
- TransactionDTO transactionDTO = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- Transaction transaction = transactionDAO.findByTopiaId(topiaId);
- // Converti la transaction en DTO
- convertTransaction.setTransaction(rootContext);
- transactionDTO = convertTransaction
- .transactionEntityToDto(transaction);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return transactionDTO;
- }*/
-
- /*
- * Recherche toutes les transactions qui correspondent à un timespan.
- * @param timeSpan
- * @return
- *
- public List<Transaction> searchListTransactionWithTimeSpan(TimeSpan timeSpan) {
- List<Transaction> listTransaction = null;
- if (timeSpan != null) {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- listTransaction = transactionDAO.findAllByTimeSpan(timeSpan);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return listTransaction;
- }*/
-
- /*
- * Recherche les transactions DTO d'un timeSpan
- * @param timeSpan
- * @return
- *
- public List<TransactionDTO> searchListTransactionDTOWithTimeSpan(
- TimeSpan timeSpan) {
- List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
- if (timeSpan != null) {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- List<Transaction> listTransaction = transactionDAO
- .findAllByTimeSpan(timeSpan);
- // Converti la transaction en DTO
- convertTransaction.setTransaction(rootContext);
- for (Transaction transaction : listTransaction) {
- TransactionDTO transactionDTO = convertTransaction
- .transactionEntityToDto(transaction);
- listTransactionDTO.add(transactionDTO);
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return listTransactionDTO;
- }*/
-
- /*
- * Recherche toutes les transactions appartenant à un même journal donné
- * en paramètre.
- * @param journal
- * @return
- *
- public List<Transaction> searchListTransactionWithJournal(Journal journal) {
- List<Transaction> listTransaction = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- listTransaction = transactionDAO.findAllByJournal(journal);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listTransaction;
- }*/
-
- /*
- * Permet de rechercher toutes les transactions dans la base de données,
- * avec en retour une liste de transactions au format DTO.
- * @return
- *
- public List<TransactionDTO> getAllTransactionDTO() {
- List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- List<Transaction> listTransaction = transactionDAO.findAll();
- // Converti la transaction en DTO
- convertTransaction.setTransaction(rootContext);
- for (Transaction transaction : listTransaction) {
- TransactionDTO transactionDTO = convertTransaction
- .transactionEntityToDto(transaction);
- listTransactionDTO.add(transactionDTO);
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listTransactionDTO;
- }*/
-
- /*
- * Cette méthode permet de vérifier si une transaction possède des paramètres
- * corrects.
- * Un journal doit exister.
- * Un timeSpan doit exister et être non bloqué.
- * @param timeSpan
- * @param journal
- * @return
- *
- public String isCorrectTransaction(TimeSpan timeSpan, Journal journal) {
- String result = ServiceHelper.RESPOND_SUCCESS;
- // Vérification si timeSpan et Journal existe bien
- if (journal == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le journal n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
- }
- if (timeSpan == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le timeSpan n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
- } else {
- // Vérifie si le timeSpan est bloqué
- if (timeSpan.getLocked()) {
- if (log.isErrorEnabled()) {
- log.error("Le timeSpan est bloqué ! Il est donc impossible"
- + " d'ajouter une transaction sur cette période. ("
- + "Période du " + timeSpan + ")");
- }
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- }
- return result;
- }*/
-
- /*
- * Permet d'effacer une transaction dans la base de données.
- * ATTENTION : Elle supprime également toutes les entées comptables
- * associées. Une transaction appartenant à un timeSpan bloqué ne peut être
- * supprimée.
- * @return
- *
- public String removeTransaction(String topiaId) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche de l'entry
- Transaction transaction = transactionDAO.findByTopiaId(topiaId);
- // Transaction doit exister
- if (transaction != null) {
- // Vérifie si la transaction est non bloquée.
- if (!isTransactionBlocked(transaction)) {
- // Supprime tous les entrys de la transactions
- List<Entry> listEntry = entryServiceImpl
- .searchEntryWithTransaction(transaction);
- for (Entry entry : listEntry) {
- result = removeEntry(entry.getTopiaId());
- }
- // Supprime la transaction
- transactionDAO.delete(transaction);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("La transaction a été supprimée avec succès.");
- }
- result = ServiceHelper.RESPOND_SUCCESS;
- } else {
- // Transaction bloquée
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- } else {
- result = ServiceHelper.TRANSACTION_NOT_EXIST;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Supprime une transaction au format DTO.
- * @param transactionDTO
- * @return
- *
- public String removeTransaction(TransactionDTO transactionDTO) {
- String result = removeTransaction(transactionDTO.getId());
- return result;
- }*/
-
- /*
- * Permet d'ajouter une entrée comptable pour une transaction donnée.
- * ATTENTION : la transaction doit être NON bloquée.
- *
- * @param description
- * @param amount
- * @param debit
- * @param lettering
- * @param detail
- * @param transaction
- * @return
- *
- public String addEntry(String description, String amount, boolean debit,
- String lettering, String detail, Transaction transaction,
- Account account) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Si la transaction est non bloquée
- if (!isTransactionBlocked(transaction)) {
- // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
- result = entryServiceImpl.createEntry(description, amount, debit,
- lettering, detail, transaction, account);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet d'ajouter une entrée comptable pour une transaction donnée.
- * L'entrée est sous format DTO.
- *
- * @param entryDTO
- * @return
- *
- public String addEntry(EntryDTO entryDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Recherche TransactionDTO
- TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
- Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
- // Si la transaction est non bloquée
- if (!isTransactionBlocked(transaction)) {
-
- // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
- result = entryServiceImpl.createEntry(entryDTO);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une entrée comptable.
- * ATTENTION : la transaction doit être NON bloquée.
- *
- * @param topiaId
- * @param description
- * @param amount
- * @param debit
- * @param lettering
- * @param detail
- * @param transaction
- * @param account
- * @return
- *
- public String modifyEntry(String topiaId, String description,
- String amount, boolean debit, String lettering, String detail,
- Transaction transaction, Account account) {
- String result = ServiceHelper.RESPOND_ERROR;
- if (!isTransactionBlocked(transaction)) {
- result = entryServiceImpl.modifyEntry(topiaId, description, amount,
- debit, lettering, detail, account);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une entrée.
- * @param entryDTO
- * @return
- *
- public String modifyEntry(EntryDTO entryDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Recherche TransactionDTO
- TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
- Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
- if (!isTransactionBlocked(transaction)) {
- result = entryServiceImpl.modifyEntry(entryDTO);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet d'effacer une entrée comptable. Elle est identifiée par son identifiant
- * topiaID. Une entrée peut être supprimée seulement si elle est non bloquée.
- * @param topiaId
- * @return
- *
- public String removeEntry(String topiaId) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- // Recherche de l'entry
- Entry entryDelete = entryDAO.findByTopiaId(topiaId);
- // Entry doit exister
- if (entryDelete != null) {
- // Prend la transaction dont appartient entry
- Transaction transaction = entryDelete.getTransaction();
- // Vérifie si la transaction est non bloquée.
- if (!isTransactionBlocked(transaction)) {
- // Création d'un log DTO
- LogDTO logDTO = new LogDTO("", new Date(),
- ServiceHelper.LOG_REMOVE, transaction
- .getTransDate(), transaction
- .getVoucherRef(), transaction
- .getDescription(), entryDelete
- .getDescription(), entryDelete.getAmount(),
- entryDelete.getDebit(), entryDelete.getLettering());
- // Appel pour supprimer l'entrée
- result = entryServiceImpl.removeEntry(topiaId);
- // Si la suppression s'est bien déroulée, création log
- if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- // Ajout du log
- logServiceImpl.addLog(logDTO);
- }
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- } else {
- result = ServiceHelper.ENTRY_NOT_EXIST;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Permet de supprimer une entrée à partir d'un DTO.
- * @param entryDTO
- * @return
- *
- public String removeEntry(EntryDTO entryDTO) {
- String result = removeEntry(entryDTO.getId());
- return result;
- }*/
-
- /*
- * Permet de vérifier si une transaction est dans une période bloquée ou non
- * @param transaction
- * @return
- *
- public boolean isTransactionBlocked(Transaction transaction) {
- boolean isTransactionBlocked = true;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- Transaction transactionSearch = transactionDAO
- .findByTopiaId(transaction.getTopiaId());
- isTransactionBlocked = timeSpanServiceImpl
- .isTimeSpanBlocked(transactionSearch.getTimeSpan());
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return isTransactionBlocked;
- }*/
-
- /*
- * Permet de vérifier si une transaction est équilibrée.
- * @param transaction
- * @return
- *
- public boolean isTransactionBalanced(Transaction transaction) {
- List<EntryDTO> ListEntryDTO = entryServiceImpl
- .searchEntryDTOWithTransaction(transaction);
- float debit = 0;
- float credit = 0;
- // Pour toutes les entrées comptables trouvées
- for (EntryDTO entryDTO : ListEntryDTO) {
- // Si entrée au debit
- if (entryDTO.isDebit()) {
- debit = debit
- + Float.parseFloat(entryDTO.getAmount().replaceFirst(
- ",", "."));
- } else {
- credit = credit
- + Float.parseFloat(entryDTO.getAmount().replaceFirst(
- ",", "."));
- }
- }
- // Vérifie si le debit == credit
- boolean isTransactionBalanced = debit == credit;
- return isTransactionBalanced;
- }*/
-
-}
\ No newline at end of file
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/UserServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/UserServiceImpl.java 2010-03-23 13:45:06 UTC (rev 2810)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/UserServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -1,116 +0,0 @@
-/*
- * *##% Callao
- * Copyright (C) 2010 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.business;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.User;
-import org.chorem.lima.entity.UserDAO;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-
-/**
- * User service.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class UserServiceImpl {
-
- /** log */
- private static final Log log = LogFactory.getLog(UserServiceImpl.class);
-
- private TopiaContext rootContext;
-
- public UserServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- /**
- * Add new user.
- *
- * @param name new user name
- * @throws LimaException
- */
- public void addUser(User user/*String name*/) throws LimaException {
- /*// Attention doublon utilisateur
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- UsersDAO userdao = LimaCallaoDAOHelper.getUsersDAO(topiaContext);
- // Création de l'user
- Users newuser = userdao.create();
- newuser.setMatcher(name);
- // Création BDD
- topiaContext.commitTransaction();
- topiaContext.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Add user : " + name);
- }
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't create user", ex);
- throw new LimaException("Can't create user", ex);
- }
-
- }*/
- }
-
- /**
- * Find user with name.
- *
- * @param name
- * @throws LimaException
- */
- public void findUser(String name) throws LimaException {
- /*try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- UsersDAO userdao = LimaCallaoDAOHelper.getUsersDAO(topiaContext);
- // Recherche du user
- Users newuser = userdao.findByMatcher(name);
- // Fermeture BDD
- topiaContext.closeContext();
- if (newuser == null) {
- throw new LimaBusinessException("can't find user " + name);
- }
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't find user", ex);
- throw new LimaException("Can't find user", ex);
- }
- }*/
- }
-}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java (from rev 2807, trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -0,0 +1,803 @@
+/*
+ * *##% Callao AccountServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Stateless;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Permet d'implémenter le Plan Comptable Général.
+ * Un compte ne peut être supprimé si il contient des écritures comptables.
+ * Un compte peut devenir père et avoir des comptes fils. Chaque compte créé doit
+ * renseigné si il appartient à un compte père avec le numéro de compte père.
+ *
+ * @author Rémi Chapelet
+ */
+@Stateless
+public class AccountServiceImpl implements AccountService {
+
+ private static final Log log = LogFactory.getLog(AccountServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ //private ConvertAccount convertAccount = new ConvertAccount();
+
+ public AccountServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Permet de créer un nouveau compte dans le PCG de l'application.
+ * Il ne peut exister deux numéros identiques. Pour chaque nouveau compte,
+ * il est vérifié si il n'existe pas un compte avec le numéro donné. Dans ce
+ * cas présent, le compte n'est pas créé.
+ * ATTENTION : le compte masterAccount, c'est à dire le compte père, doit
+ * exister, sinon le compte n'est pas créé. Si le compte n'a pas de père, alors
+ * mettre masterAccount à null.
+ *
+ * @param account account to create
+ * @throws LimaException
+ */
+ @Override
+ public void createAccount(Account masterAccount, Account account) throws LimaException {
+
+ // test la validite du numero de compte
+ if (StringUtils.isBlank(account.getAccountNumber())) {
+ throw new LimaBusinessException("Invalid AccountNumber : " + account.getAccountNumber());
+ }
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // test si le numero de compte existe deja
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ List<Account> existingAccounts = accountDAO.findAllByAccountNumber(account.getAccountNumber());
+ if (CollectionUtils.isNotEmpty(existingAccounts)) {
+ throw new LimaBusinessException(_("An account already exists with this number : %s", account.getAccountNumber()));
+ }
+
+ accountDAO.create(account);
+
+ // test si le compte parent existe;
+ if (masterAccount != null) {
+ masterAccount.addSubAccounts(account);
+ accountDAO.update(masterAccount);
+ }
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create account", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create account", ex);
+ }
+ }
+ }
+ }
+ /*public String createAccount (String accountNumber, String label,Account masterAccount,String type)
+ {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Détermine si le compte existe déjà ou non
+ boolean existAccount = existAccount(accountNumber);
+ // Si le numéro de compte existe
+ if (existAccount)
+ {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro "+accountNumber+" existe deja !");
+ }
+ result = ServiceHelper.ACCOUNT_DOUBLE;
+ } else {
+ // Création du compte
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+
+ //Le compte a un père
+
+ if ( masterAccount != null )
+ {
+ // Vérification que le compte père existe dans la base de données
+ boolean existMasterAccount = existAccount(masterAccount.getAccountNumber());
+ // Si le compte père n'existe pas
+ if (!existMasterAccount)
+ {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte père numéro "+accountNumber+" n'existe pas !");
+ }
+ result = ServiceHelper.ACCOUNT_NOT_MASTER;
+ } else {
+ // Creation du compte
+ Account newAccount = accountDAO.create();
+ newAccount.setAccountNumber(accountNumber);
+ newAccount.setLabel(label);
+ newAccount.setMasterAccount(masterAccount);
+ newAccount.setType(type);
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ } else {
+ // Le compte n'a pas de père
+ // Creation du compte
+ Account newAccount = accountDAO.create();
+ newAccount.setAccountNumber(accountNumber);
+ newAccount.setLabel(label);
+ newAccount.setType(type);
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ }catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+
+ /*
+ * Permet de créer un compte à partir du numéro de compte père. Il appelle
+ * ensuite createAccount avec le compte père.
+ * @param accountNumber numéro du compte à créer
+ * @param label label pour le compte
+ * @param maserAccountNumber numéro du compte père, si il en a pas, mettre 0.
+ * @return
+ *
+ public String createAccount(String accountNumber, String label,
+ String masterAccountNumber, String type) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Recherche le compte Master
+ Account masterAccount = searchAccount(masterAccountNumber);
+ // Si le compte père n'existe pas
+ if (masterAccount == null && !masterAccountNumber.equals("0")) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte père numéro " + masterAccountNumber
+ + " n'existe pas !");
+ }
+ result = ServiceHelper.ACCOUNT_NOT_MASTER;
+ } else {
+ // Création du compte
+ result = createAccount(accountNumber, label, masterAccount, type);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de creer un compte à partir d'un objet DTO
+ * @param accountDTO compte au format DTO
+ * @return
+ *
+ public String createAccount(AccountDTO accountDTO) {
+ String result;
+ String result_final;
+ boolean error = false; // Si il y a eu une erreur pour créer les enfants
+
+ // Création du compte père
+ result = createAccount(accountDTO.getAccountNumber(), accountDTO
+ .getLabel(), accountDTO.getMasterAccount(), accountDTO
+ .getType());
+ // Création des comptes enfants
+
+ // Pour chaque enfant
+ for (AccountDTO accountChildDTO : accountDTO.getAccountChildDTO()) {
+ // Création de l'enfant
+ result = createAccount(accountChildDTO);
+ // Si il y a eu une erreur
+ if (!result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro " + accountChildDTO.getLabel()
+ + " n'a pu être créé !");
+ }
+ error = true;
+ result_final = result;
+ }
+ }
+ // Si il y a eu une erreur lors de la création d'un enfant, il est envoyé une erreur.
+ if (error) {
+ result = ServiceHelper.RESPOND_ERROR;
+ }
+ return result;
+ }*/
+
+ /*
+ * Recherche un compte DTO. Il est recherché dans la base de données et est
+ * converti avec ConvertAccount. ConvertAccount recherche dans la liste de
+ * ses enfants pour les convertir également, et ainsi de suite.
+ * @param accountNumber numéro du compte qu'on souhait rechercher
+ * @return
+ *
+ public AccountDTO searchAccountDTO(String accountNumber) {
+ AccountDTO accountDTO = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche du compte
+ Account account = accountDAO.findByAccountNumber(accountNumber);
+ // Converti entity en DTO
+ convertAccount.setTransaction(topiaContext);
+ accountDTO = convertAccount.accountEntityToDto(account, null);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return accountDTO;
+ }*/
+
+ /*
+ * Permet de rechercher un compte à partir d'un numéro de compte.
+ * @param accountNumber numéro du compte à rechercher
+ * @return
+ *
+ public Account searchAccount(String accountNumber) {
+ Account accountResult = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche du compte
+ accountResult = accountDAO.findByAccountNumber(accountNumber);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return accountResult;
+ }*/
+
+ /*
+ * Permet de renvoyer tous les enfants du compte.
+ * Cette fonction permet de renvoyer les enfants, mais PAS les enfants des
+ * enfants (et ainsi de suite). Cette méthode descend donc uniquement d'un
+ * niveau sur la hiérarchie.
+ * @param account compte dont on souhaite obtenir ses enfants.
+ * @return
+ *
+ public List<Account> searchListChildAccount(Account account) {
+ List<Account> ListAccount = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche des comptes enfants
+ ListAccount = accountDAO.findAllByMasterAccount(account);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return ListAccount;
+ }*/
+
+ /*
+ * Permet de renvoyer tous les enfants du compte. Elle se base sur la fonction
+ * searchListChildAccount(Account account).
+ * Cette fonction permet de renvoyer les enfants, mais PAS les enfants des
+ * enfants (et ainsi de suite). Cette méthode descend donc uniquement d'un
+ * niveau sur la hiérarchie.
+ * @param account numéro de compte dont on souhaite obtenir ses enfants.
+ * @return
+ *
+ public List<Account> searchListChildAccount(String accountNumber) {
+ List<Account> ListAccount = null;
+ // Recherche le compte
+ Account account = searchAccount(accountNumber);
+ // Si le compte n'existe pas
+ if (account == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro " + accountNumber
+ + " n'existe pas !");
+ }
+ } else {
+ // Recherche des comptes enfants
+ ListAccount = searchListChildAccount(account);
+ }
+ return ListAccount;
+ }*/
+
+ /**
+ * Permet de convertir tous les comptes en DTO. Il recherche dans un premier
+ * temps tous les comptes "master".
+ *
+ * @return
+ * @throws LimaException
+ */
+ @Override
+ public List<Account> getAllAccounts() throws LimaException {
+ /*ArrayList<AccountDTO> listAccountDTO = new ArrayList<AccountDTO>();
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche des comptes enfants
+ List<Account> listAccount = accountDAO.findAll();
+ // Pour chaque compte
+ // Converti entity en DTO
+ convertAccount.setTransaction(topiaContext);
+ for (Account account : listAccount) {
+ // Pour les comptes sans père
+ if (account.getMasterAccount() == null) {
+ AccountDTO accountDTO = convertAccount.accountEntityToDto(
+ account, null);
+ listAccountDTO.add(accountDTO);
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listAccountDTO;*/
+
+ List<Account> accountsList = new ArrayList<Account>();
+
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ List<Account> accounts = accountDAO.findAll();
+ accountsList.addAll(accounts);
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create account", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create account", ex);
+ }
+ }
+ }
+
+ return accountsList;
+ }
+
+ /*
+ * Renvoie vrai si le compte avec son numéro existe déjà dans la base de
+ * données.
+ * @param accountNumber numéro du compte recherché
+ * @return
+ *
+ public boolean existAccount(String accountNumber) {
+ // Recherche du compte
+ Account accountSearch = searchAccount(accountNumber);
+ boolean result = false;
+ // Si le compte est trouvé
+ if (accountSearch != null) {
+ result = true;
+ }
+ return result;
+ }*/
+
+ /**
+ * Permet d'effacer un compte dans la base de données.
+ *
+ * Il est vérifié dans un premier temps si le compte existe bien.
+ * ATTENTION : si il existe une entrée comptable associée au numéro de
+ * compte, il est alors impossible de supprimer le compte.
+ *
+ * @param account
+ * @throws LimaException
+ */
+ @Override
+ public void removeAccount(Account account) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ Account deleteAccount = searchAccount(accountNumber);
+ // Si le compte n'existe pas
+ if (deleteAccount == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro " + accountNumber
+ + " n'existe pas !");
+ }
+ result = ServiceHelper.ACCOUNT_NOT_EXIST;
+ } else // Sinon on efface le compte
+ {
+ // Vérifie si une entrée ne possède pas ce numéro de compte.
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper
+ .getEntryDAO(topiaContext);
+ // Recherche au moins une entry avec ce compte.
+ Entry entry = entryDAO.findByAccount(deleteAccount);
+ // Il existe au moins une entrée
+ if (entry != null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro " + accountNumber
+ + " possède des entrées comptable !");
+ }
+ result = ServiceHelper.ACCOUNT_WITH_ENTRIES;
+ } else {
+ // On efface tous les comptes enfants
+ List<Account> listAccountChild = searchListChildAccount(deleteAccount);
+ boolean ErrorRemoveChild = false;
+ for (Account accountChild : listAccountChild) {
+ // Si on souhaite supprimer les comptes enfants
+ result = removeAccount(accountChild.getAccountNumber());
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ ErrorRemoveChild = true;
+ if (log.isErrorEnabled()) {
+ log.error("Le compte fils numéro "
+ + accountChild.getAccountNumber()
+ + " n'a pas été supprimé !");
+ }
+ }
+ //
+ // Si on ne souhaite pas supprimer les comptes enfants, tous les
+ // comptes enfants se retrouvent sans père. Commenter removeAccountChildTest
+ // dans le fichier AccountServiceImplTest dans ce cas.
+
+ //modifyAccount(accountChild.getAccountNumber(),accountChild.getLabel(),null);
+ }
+ // Si il n'a jamais eu d'erreur pour supprimer ses fils
+ if (!ErrorRemoveChild) {
+
+ //// Efface le compte père
+
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Supprime le compte
+ accountDAO.delete(deleteAccount);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ if (log.isInfoEnabled()) {
+ log.info("Le compte numéro " + accountNumber
+ + " a ete supprimé avec succès.");
+ }
+ }
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;*/
+
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ // Vérifie si une entrée ne possède pas ce numéro de compte.
+ // FIXME !IMPORTANT! check that subaccounts have no entries too
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
+ Entry firstEntry = entryDAO.findByAccount(account);
+
+ if (firstEntry != null) {
+ throw new LimaBusinessException("Can't delete account with entries");
+ }
+
+ // remove account
+ // FIXME !IMPORTANT! check that subaccounts are also deleted
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ accountDAO.delete(account);
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't delete account", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't delete account", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Permet d'effacer un compte à partir d'un compte DTO. Il appelle la
+ * méthode removeAccount, qui effacera également les enfants (et ainsi de
+ * suite dans la hiérarchie du compte).
+ * @param accountDTO Compte au format DTO qu'on souhaite supprimer.
+ * @return
+ *
+ public String removeAccount(AccountDTO accountDTO) {
+ String result;
+ result = removeAccount(accountDTO.getAccountNumber());
+ return result;
+ }*/
+
+ /**
+ * Permet de modifier un compte sur son label et son compte père.
+ *
+ * Il n'est pas possible de modifier un numéro de compte.
+ * Si le compte n'existe pas, il envoie alors un message d'avertissement.
+ *
+ * @param accountNumber numéro de compte à modifier
+ * @param label label à modifier
+ * @param masterAccountNumber compte père à modifier
+
+ * @throws LimaException
+ */
+ @Override
+ public void updateAccount(Account account) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche du compte
+ Account modifyAccount = accountDAO
+ .findByAccountNumber(accountNumber);
+ // Si le compte n'existe pas
+ if (modifyAccount == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro " + accountNumber
+ + " n'existe pas !");
+ }
+ result = ServiceHelper.ACCOUNT_NOT_EXIST;
+ } else {
+
+ // Modifie le compte
+ modifyAccount.setLabel(label);
+ modifyAccount.setType(type);
+ // Recherche du compte père
+ // Si il possède un compte père
+ if (masterAccount != null) {
+ modifyAccount.setMasterAccount(masterAccount);
+ }
+ modifyAccount.update();
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;*/
+
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ // update account
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ accountDAO.update(account);
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't update account", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't update account", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Permet de modifier un compte sur son label et son compte père.
+ * Il recherche le compte père avec le numéro de compte fourni. Appel ensuite
+ * la méthode modifyAccount avec pour paramètre le compte père trouvé.
+ * @param accountNumber numéro de compte à modifier
+ * @param label label à modifier
+ * @param masterAccountNumber le numéro du compte père
+ * @return
+ *
+ public String modifyAccount(String accountNumber, String label,
+ String type, String masterAccountNumber) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+
+ // Modifie le compte
+ // Recherche du compte père
+ Account masterAccount = accountDAO
+ .findByAccountNumber(masterAccountNumber);
+ result = modifyAccount(accountNumber, label, type, masterAccount);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier un compte à partir d'un compte DTO.
+ * @param accountDTO compte au format DTO qu'on souhaire modifier.
+ * @return
+ *
+ public String modifyAccount(AccountDTO accountDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche du compte père
+ Account masterAccount = accountDAO.findByAccountNumber(accountDTO
+ .getMasterAccount());
+ result = modifyAccount(accountDTO.getAccountNumber(), accountDTO
+ .getLabel(), accountDTO.getType(), masterAccount);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de mettre à jour le compte DTO ainsi que tous ses fils.
+ * Cette méthode permet d'ajouter, modifier, et supprimer un compte et
+ * ses enfants (et ainsi de suite).
+ * @param accountDTO
+ * @return
+ *
+ public String updateDTO(AccountDTO accountDTO) {
+ String result;
+ // Si le compte DTO père existe
+ if (existAccount(accountDTO.getAccountNumber())) {
+ // Modification du compte père
+ result = modifyAccount(accountDTO);
+ } else {
+ // Création du compte père
+ result = createAccount(accountDTO);
+ }
+ // Pour chaque enfant on lance l'update
+ for (AccountDTO accountChildDTO : accountDTO.getAccountChildDTO()) {
+ updateDTO(accountChildDTO);
+ }
+
+ // On recherche les comptes DTO effacés
+ List<Account> listAccountChild = searchListChildAccount(accountDTO
+ .getAccountNumber());
+ for (Account account : listAccountChild) {
+ // Si le compte n'est pas dans la liste, alors on efface
+ if (!accountDTO.existAccountChild(account.getAccountNumber())) {
+ result = removeAccount(account.getAccountNumber());
+ }
+ }
+ return result;
+ }*/
+
+}
\ No newline at end of file
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java (from rev 2802, trunk/lima-business/src/main/java/org/chorem/lima/business/EntryServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -0,0 +1,382 @@
+/*
+ * *##% Callao EntryServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.entity.Entry;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Cette classe permet de contrôler les différentes saisies possibles dans
+ * Callao. Ces saisies sont transmises à la base de données par la classe
+ * Entry. Chaque action sur une entrée déclenche une création d'un log.
+ * Chaque opération comptable doit faire appel également au contrôl de la
+ * période comptable sur laquelle l'entry repose. Ainsi il n'est possible
+ * d'ajouter/modifier/supprimer une entrée si la période est bloquée.
+ *
+ * @author Rémi Chapelet
+ */
+public class EntryServiceImpl { // implements EntryService {
+
+ private static final Log log = LogFactory.getLog(EntryServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ private LogServiceImpl logServiceImpl = new LogServiceImpl();
+
+ // TODO A revoir car transaction a besoin de entry et vice versa
+ private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+
+ private AccountServiceImpl accountServiceImpl = new AccountServiceImpl();
+
+ public EntryServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Création d'une entrée comptable.
+ * La période ne doit PAS être bloquée.
+ *
+ * @return
+ */
+ public void createEntry(Entry entry /*String description, String amount, boolean debit,
+ String lettering, String detail, Transaction transaction,
+ Account account*/) {
+ /*String result = isCorrectEntry(transaction, account);
+ if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper
+ .getEntryDAO(topiaContext);
+ // Creation de l'entrée comptable
+ Entry newEntry = entryDAO.create();
+ newEntry.setDescription(description);
+ // On formate le nombre
+ newEntry.setAmount(numberUtil.format(amount));
+ newEntry.setDebit(debit);
+ newEntry.setLettering(lettering);
+ newEntry.setDetail(detail);
+ newEntry.setTransaction(transaction);
+ newEntry.setAccount(account);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ if (log.isInfoEnabled()) {
+ log.info("Ajout avec succes de l'entrée comptable.");
+ }
+ // Création du log
+ Date logDate = new Date();
+ logServiceImpl.addLog(logDate, transaction.getTransDate(),
+ ServiceHelper.LOG_ADD, transaction.getVoucherRef(),
+ transaction.getDescription(), detail, amount, debit,
+ lettering);
+
+ // Il renvoie soit l'identifiant topiaId ou SUCCESS.
+ result = newEntry.getTopiaId();
+ //result = ServiceHelper.RESPOND_SUCCESS;
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;*/
+ }
+
+ /*
+ * Permet de créer une entrée comptable à partir de son DTO.
+ * @param entryDTO
+ * @return
+ *
+ public String createEntry(EntryDTO entryDTO) {
+ // Recherche TransactionDTO
+ TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
+ Transaction transaction = transactionServiceImpl
+ .searchTransactionWithTopiaId(transactonDTO);
+ // Recherche AccountDTO
+ AccountDTO accountDTO = entryDTO.getAccountDTO();
+ Account account = accountServiceImpl.searchAccount(accountDTO
+ .getAccountNumber());
+ // Création entry
+ String result = createEntry(entryDTO.getDescription(), entryDTO
+ .getAmount(), entryDTO.isDebit(), entryDTO.getLettering(),
+ entryDTO.getDetail(), transaction, account);
+ return result;
+ }*/
+
+ /*
+ * Vérifie que les objets transaction et account ne sont pas nulls.
+ * @param transaction
+ * @param account
+ * @return
+ *
+ public String isCorrectEntry(Transaction transaction, Account account) {
+ String result = ServiceHelper.RESPOND_SUCCESS;
+ // Vérification si timeSpan et Journal existe bien
+ if (account == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création entry : Le account n'existe pas.");
+ }
+ result = ServiceHelper.ACCOUNT_NOT_EXIST;
+ }
+ if (transaction == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création entry : La transaction n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_EXIST;
+ }
+ return result;
+ }*/
+
+ /*
+ * Recherche toutes les entrées comptables d'une transaction.
+ * @param transaction
+ * @return
+ *
+ public List<Entry> searchEntryWithTransaction(Transaction transaction) {
+ List<Entry> listEntry = null;
+ if (transaction != null) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper
+ .getEntryDAO(topiaContext);
+ // Recherche
+ listEntry = entryDAO.findAllByTransaction(transaction);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return listEntry;
+ }*/
+
+ /*
+ * Recherche toutes les entrées comptables d'une transaction, et renvoie
+ * au format DTO.
+ * @param transaction
+ * @return
+ *
+ public List<EntryDTO> searchEntryDTOWithTransaction(Transaction transaction) {
+ List<EntryDTO> listEntryDTO = new ArrayList<EntryDTO>();
+ // Si la transaction est trouvée
+ if (transaction != null) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper
+ .getEntryDAO(topiaContext);
+ // Recherche toutes les entrées comptables de la transaction
+ List<Entry> listEntry = entryDAO
+ .findAllByTransaction(transaction);
+ // Pour chaque entry, on fait appel au convertisseur pour avoir en DTO
+ convertEntry.setTransaction(topiaContext);
+ for (Entry entry : listEntry) {
+ EntryDTO entryDTO = convertEntry.entryEntityToDto(entry);
+ // On ajoute le nouvel DTO
+ listEntryDTO.add(entryDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return listEntryDTO;
+ }*/
+
+ /*
+ * Recherche les entrées comptables pour une transaction donnée au format DTO.
+ * @param transactionTopiaId identifiant de la transaction
+ * @return
+ *
+ public List<EntryDTO> searchEntryDTOWithTransaction(
+ String transactionTopiaId) {
+ List<EntryDTO> listEntryDTO = new ArrayList<EntryDTO>();
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ // Recherche de la transaction
+ Transaction transaction = transactionServiceImpl
+ .searchTransactionWithTopiaId(transactionTopiaId);
+ // Si la transaction est trouvée
+ if (transaction != null) {
+ // Recherche toutes les entrées comptables de la transaction
+ List<Entry> listEntry = entryDAO
+ .findAllByTransaction(transaction);
+ // Pour chaque entry, on fait appel au convertisseur pour avoir en DTO
+ convertEntry.setTransaction(topiaContext);
+ for (Entry entry : listEntry) {
+ EntryDTO entryDTO = convertEntry.entryEntityToDto(entry);
+ // On ajoute l'entrée DTO
+ listEntryDTO.add(entryDTO);
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listEntryDTO;
+ }*/
+
+ /*
+ * Recherche les entrées comptables pour une transaction donnée au format DTO.
+ * @param transactionDTO
+ * @return
+ *
+ public List<EntryDTO> searchEntryDTOWithTransaction(
+ TransactionDTO transactionDTO) {
+ List<EntryDTO> listEntryOfTransaction = searchEntryDTOWithTransaction(transactionDTO
+ .getId());
+ return listEntryOfTransaction;
+ }*/
+
+ /*
+ * Permet d'effacer une entrée comptable à partir de son identifiant topia.
+ * @param topiaId
+ * @return
+ *
+ public String removeEntry(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ // Recherche de l'entry
+ Entry entryDelete = entryDAO.findByTopiaId(topiaId);
+ // Si l'entry existe alors on supprime
+ if (entryDelete != null) {
+ // Supprime
+ entryDAO.delete(entryDelete);
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ result = ServiceHelper.ENTRY_NOT_EXIST;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'effacer une entrée comptable au format DTO.
+ * @param entryDTO
+ * @return
+ *
+ public String removeEntry(EntryDTO entryDTO) {
+ String result = removeEntry(entryDTO.getId());
+ return result;
+ }*/
+
+ /*
+ * Modification d'une entrée comptable.
+ * @param topiaId
+ * @param description
+ * @param amount
+ * @param debit
+ * @param lettering
+ * @param detail
+ * @param transaction
+ * @param account
+ * @return
+ *
+ public String modifyEntry(String topiaId, String description,
+ String amount, boolean debit, String lettering, String detail,
+ Account account) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ // Recherche Entry
+ Entry entry = entryDAO.findByTopiaId(topiaId);
+ entry.setDescription(description);
+ // On formate le nombre
+ entry.setAmount(numberUtil.format(amount));
+ entry.setDebit(debit);
+ entry.setLettering(lettering);
+ entry.setDetail(detail);
+ entry.setAccount(account);
+ entry.update();
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Chargement DAO transaction
+ Transaction transaction = entry.getTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Edit avec succes de l'entrée comptable.");
+ }
+ // Création du log
+ Date logDate = new Date();
+ logServiceImpl.addLog(logDate, transaction.getTransDate(),
+ ServiceHelper.LOG_MODIFY, transaction.getVoucherRef(),
+ transaction.getDescription(), detail, amount, debit,
+ lettering);
+ result = ServiceHelper.RESPOND_SUCCESS;
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une entrée comptable.
+ * @param entryDTO
+ * @return
+ *
+ public String modifyEntry(EntryDTO entryDTO) {
+ // Recherche AccountDTO
+ AccountDTO accountDTO = entryDTO.getAccountDTO();
+ Account account = accountServiceImpl.searchAccount(accountDTO
+ .getAccountNumber());
+ // Modification entry
+ String result = modifyEntry(entryDTO.getId(),
+ entryDTO.getDescription(), entryDTO.getAmount(), entryDTO
+ .isDebit(), entryDTO.getLettering(), entryDTO
+ .getDetail(), account);
+ return result;
+ }*/
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java (from rev 2802, trunk/lima-business/src/main/java/org/chorem/lima/business/FilesServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -0,0 +1,667 @@
+/*
+ * *##% Callao FilesServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.dto.AccountDTO;
+import org.chorem.lima.business.dto.EntryDTO;
+import org.chorem.lima.business.dto.JournalDTO;
+import org.chorem.lima.business.dto.PeriodDTO;
+import org.chorem.lima.business.dto.TimeSpanDTO;
+import org.chorem.lima.business.dto.TransactionDTO;
+import org.chorem.lima.business.utils.DateUtil;
+import org.chorem.lima.business.utils.ServiceHelper;
+import org.jdom.Attribute;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+import org.jdom.xpath.XPath;
+import org.nuiton.topia.TopiaContext;
+
+/**
+ * Cette classe permet d'importer et exporter des données comptables. Ces données
+ * sont au format xml.
+ *
+ * @author Rémi Chapelet
+ */
+public class FilesServiceImpl { // implements FilesService {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(FilesServiceImpl.class);
+
+ static Element racine = new Element("Callao");
+
+ static org.jdom.Document document = new Document(racine);
+
+ private static DateUtil dateUtil = new DateUtil();
+
+ private AccountServiceImpl accountServiceImpl = new AccountServiceImpl();
+
+ private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
+
+ private JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
+
+ private PeriodServiceImpl periodServiceImpl = new PeriodServiceImpl();
+
+ private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
+
+ private TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+
+ /**
+ * Cete méthode permet d'exporter des données de Callao vers un fichier au
+ * format xml.
+ *
+ * @param nameFile
+ */
+ public void exportDatas(String nameFile) {
+ /*if (log.isDebugEnabled()) {
+ log.debug("Save file XML : ");
+ }
+
+ // Partie Informations
+ Element info = new Element("informations");
+ racine.addContent(info);
+ Attribute date = new Attribute("date", new Date().toString());
+ info.setAttribute(date);
+ Attribute user = new Attribute("user", "Name user");
+ info.setAttribute(user);
+ Attribute company = new Attribute("company", "Name company");
+ info.setAttribute(company);
+
+ // Partie Save
+
+ // Création Element save
+ Element save = new Element("save");
+ racine.addContent(save);
+
+ // Period
+
+ // Création élément liste de périods
+ Element periods = new Element("periods");
+ // Création élément liste de timespans
+ Element timeSpans = new Element("timespans");
+ save.addContent(periods);
+ save.addContent(timeSpans);
+ // Recherche de la liste de toutes les périodes et leurs timeSpans en DTO
+ List<PeriodDTO> listPeriodDTO = periodServiceImpl.getAllPeriod();
+ // Pour chaque période
+ for (PeriodDTO periodDTO : listPeriodDTO) {
+ // Création élément périod
+ Element period = new Element("period");
+ periods.addContent(period);
+ // Identifiant période
+ Attribute id = new Attribute("id", periodDTO.getId());
+ period.setAttribute(id);
+ // BeginPeriod
+ // Découpage date
+ String dateTab[] = dateUtil.arrayDate(periodDTO.getBeginPeriod());
+ Attribute beginYear = new Attribute("beginYear", dateTab[0]);
+ period.setAttribute(beginYear);
+ Attribute beginMonth = new Attribute("beginMonth", dateTab[1]);
+ period.setAttribute(beginMonth);
+ Attribute beginDay = new Attribute("beginDay", dateTab[2]);
+ period.setAttribute(beginDay);
+ // EndPeriod
+ dateTab = dateUtil.arrayDate(periodDTO.getEndPeriod());
+ Attribute endYear = new Attribute("endYear", dateTab[0]);
+ period.setAttribute(endYear);
+ Attribute endMonth = new Attribute("endMonth", dateTab[1]);
+ period.setAttribute(endMonth);
+ Attribute endDay = new Attribute("endDay", dateTab[2]);
+ period.setAttribute(endDay);
+ // Locked Period
+ if (periodDTO.isLocked()) {
+ Attribute locked = new Attribute("locked", "true");
+ period.setAttribute(locked);
+ } else {
+ Attribute locked = new Attribute("locked", "false");
+ period.setAttribute(locked);
+ }
+
+ // TimeSpan
+
+ // Recherche des timeSpans de la période
+ List<TimeSpanDTO> listTimeSpanDTO = periodDTO.getListTimeSpan();
+ // Pour chaque timeSpan
+ for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
+ Element timeSpan = new Element("timespan");
+ timeSpans.addContent(timeSpan);
+ // Identifiant timeSpan
+ Attribute idTimeSpan = new Attribute("id", timeSpanDTO.getId());
+ timeSpan.setAttribute(idTimeSpan);
+ Attribute idPeriod = new Attribute("idPeriod", periodDTO
+ .getId());
+ timeSpan.setAttribute(idPeriod);
+ // Begin TimeSpan
+ // Découpage date
+ dateTab = dateUtil.arrayDate(timeSpanDTO.getBeginTimeSpan());
+ Attribute beginYearTimeSpan = new Attribute("beginYear",
+ dateTab[0]);
+ timeSpan.setAttribute(beginYearTimeSpan);
+ Attribute beginMonthTimeSpan = new Attribute("beginMonth",
+ dateTab[1]);
+ timeSpan.setAttribute(beginMonthTimeSpan);
+ Attribute beginDayTimeSpan = new Attribute("beginDay",
+ dateTab[2]);
+ timeSpan.setAttribute(beginDayTimeSpan);
+ // End TimeSpan
+ dateTab = dateUtil.arrayDate(timeSpanDTO.getEndTimeSpan());
+ Attribute endYearTimeSpan = new Attribute("endYear", dateTab[0]);
+ timeSpan.setAttribute(endYearTimeSpan);
+ Attribute endMonthTimeSpan = new Attribute("endMonth",
+ dateTab[1]);
+ timeSpan.setAttribute(endMonthTimeSpan);
+ Attribute endDayTimeSpan = new Attribute("endDay", dateTab[2]);
+ timeSpan.setAttribute(endDayTimeSpan);
+ // Lock timeSpan
+ if (timeSpanDTO.isLocked()) {
+ Attribute locked = new Attribute("locked", "true");
+ timeSpan.setAttribute(locked);
+ } else {
+ Attribute locked = new Attribute("locked", "false");
+ timeSpan.setAttribute(locked);
+ }
+ }
+ }
+
+ // Journal
+
+ Element journals = new Element("journals");
+ save.addContent(journals);
+ List<JournalDTO> listJournalDTO = journalServiceImpl.getAllJournal();
+ for (JournalDTO journalDTO : listJournalDTO) {
+ Element journal = new Element("journal");
+ journals.addContent(journal);
+ // Identification du journal
+ Attribute idJournal = new Attribute("id", journalDTO.getId());
+ journal.setAttribute(idJournal);
+ // Label
+ Attribute label = new Attribute("label", journalDTO.getLabel());
+ journal.setAttribute(label);
+ // Prefix
+ Attribute prefix = new Attribute("prefix", journalDTO.getPrefix());
+ journal.setAttribute(prefix);
+ // Description
+ Attribute description = new Attribute("description", journalDTO
+ .getDescription());
+ journal.setAttribute(description);
+ }
+
+ // Account
+
+ Element accounts = new Element("accounts");
+ save.addContent(accounts);
+ List<AccountDTO> listAccountDTO = accountServiceImpl.getAllAccount();
+ // Appel une fonction récursive pour parcourir l'arborescence des comptes
+ accountXML(listAccountDTO, accounts);
+
+ // Transaction
+ Element transactions = new Element("transactions");
+ save.addContent(transactions);
+ Element entries = new Element("entries");
+ save.addContent(entries);
+ // Recherche de toutes les transactions
+ List<TransactionDTO> listTransactionDTO = transactionServiceImpl
+ .getAllTransactionDTO();
+ // Pour chaque transaction
+ for (TransactionDTO transactionDTO : listTransactionDTO) {
+ Element transaction = new Element("transaction");
+ transactions.addContent(transaction);
+ // Identification de la transaction
+ Attribute idTransaction = new Attribute("id", transactionDTO
+ .getId());
+ transaction.setAttribute(idTransaction);
+ // EntryDate
+ String dateTab[] = dateUtil
+ .arrayDate(transactionDTO.getEntryDate());
+ Attribute entryDateYear = new Attribute("entryDateYear", dateTab[0]);
+ transaction.setAttribute(entryDateYear);
+ Attribute entryDateMonth = new Attribute("entryDateMonth",
+ dateTab[1]);
+ transaction.setAttribute(entryDateMonth);
+ Attribute entryDateDay = new Attribute("entryDateDay", dateTab[2]);
+ transaction.setAttribute(entryDateDay);
+ // VoucherRef
+ Attribute voucherRef = new Attribute("voucherRef", transactionDTO
+ .getVoucherRef());
+ transaction.setAttribute(voucherRef);
+ // Description
+ Attribute description = new Attribute("description", transactionDTO
+ .getDescription());
+ transaction.setAttribute(description);
+ // Id journal
+ Attribute IdJournal = new Attribute("idJournal", transactionDTO
+ .getJournalDTO().getId());
+ transaction.setAttribute(IdJournal);
+ // Id timeSpan
+ Attribute IdTimeSpan = new Attribute("idTimeSpan", transactionDTO
+ .getTimeSpanDTO().getId());
+ transaction.setAttribute(IdTimeSpan);
+
+ // Entry
+ List<EntryDTO> listEntryDTO = entryServiceImpl
+ .searchEntryDTOWithTransaction(transactionDTO);
+ for (EntryDTO entryDTO : listEntryDTO) {
+ Element entry = new Element("entry");
+ entries.addContent(entry);
+ // Identification du entry
+ Attribute idEntry = new Attribute("id", entryDTO.getId());
+ entry.setAttribute(idEntry);
+ // Description
+ Attribute descriptionEntry = new Attribute("description",
+ entryDTO.getDescription());
+ entry.setAttribute(descriptionEntry);
+ // Amount
+ Attribute amount = new Attribute("amount", entryDTO.getAmount());
+ entry.setAttribute(amount);
+ // Lettering
+ Attribute lettering = new Attribute("lettering", entryDTO
+ .getLettering());
+ entry.setAttribute(lettering);
+ // Detail
+ Attribute detail = new Attribute("detail", entryDTO.getDetail());
+ entry.setAttribute(detail);
+ // Debit / crédit
+ if (entryDTO.isDebit()) {
+ Attribute debit = new Attribute("debit", "true");
+ entry.setAttribute(debit);
+ } else {
+ Attribute debit = new Attribute("debit", "false");
+ entry.setAttribute(debit);
+ }
+ // Transaction
+ Attribute idrefTransaction = new Attribute("idTransaction",
+ transactionDTO.getId());
+ entry.setAttribute(idrefTransaction);
+ // Account
+ Attribute idAccount = new Attribute("idAccount", entryDTO
+ .getAccountDTO().getId());
+ entry.setAttribute(idAccount);
+ }
+ }
+ //affiche();
+ enregistre(nameFile);
+ return ServiceHelper.RESPOND_SUCCESS;*/
+ }
+
+ /**
+ * Converti la liste des comptes pour être ajouté au document xml.
+ * @param listAccountDTO
+ * @param accounts
+ */
+ protected void accountXML(List<AccountDTO> listAccountDTO, Element accounts) {
+ /*for (AccountDTO accountDTO : listAccountDTO) {
+ Element account = new Element("account");
+ accounts.addContent(account);
+ // Identification du account
+ Attribute idAccount = new Attribute("id", accountDTO.getId());
+ account.setAttribute(idAccount);
+ // Label
+ Attribute label = new Attribute("label", accountDTO.getLabel());
+ account.setAttribute(label);
+ // Type
+ Attribute type = new Attribute("type", accountDTO.getType());
+ account.setAttribute(type);
+ // AccountNumber
+ Attribute accountNumber = new Attribute("accountNumber", accountDTO
+ .getAccountNumber());
+ account.setAttribute(accountNumber);
+ // MasterAccountNumber
+ Attribute masterAccountNumber = new Attribute("masterAccount",
+ accountDTO.getMasterAccount());
+ account.setAttribute(masterAccountNumber);
+ // Ajoute les comptes enfants à la liste
+ accountXML(accountDTO.getAccountChildDTO(), accounts);
+ }*/
+ }
+
+ // Affiche le fichier xml
+ /*static void affiche() {
+ try {
+ XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
+ sortie.output(document, System.out);
+ } catch (java.io.IOException e) {
+ }
+ }*/
+
+ /**
+ * Permet d'enregistrer le fichier xml.
+ * @param fichier
+ */
+ /*static void enregistre(String fichier) {
+ try {
+ XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
+ sortie.output(document, new FileOutputStream(fichier));
+ } catch (java.io.IOException e) {
+ }
+ }*/
+
+ /**
+ * Permet d'importer un fichier de données au format xml dans Callao. Si le
+ * fichier n'est pas disponible, il est alors renvoyé un message d'erreur.
+ * @param file
+ * @return
+ */
+ public void importDatas(String file) {
+ /*if (log.isDebugEnabled()) {
+ log.debug("Load file XML : ");
+ }
+ String result = ServiceHelper.RESPOND_ERROR;
+ boolean existError = false;
+
+
+ // Chargement du fichier et construction du Dom
+ try {
+ // On crée une instance de SAXBuilder
+ SAXBuilder sxb = new SAXBuilder();
+ document = sxb.build(file);
+ } catch (IOException e) {
+ log.error("Erreur lors de la lecture du fichier " + e.getMessage());
+ e.printStackTrace();
+ } catch (JDOMException e) {
+ log.error("Erreur lors de la construction du fichier JDOM "
+ + e.getMessage());
+ e.printStackTrace();
+ }
+
+
+ // Ecriture dans la base de données
+ try {
+ // Recherche de la racine
+ Element racine = document.getRootElement();
+
+ // Journal
+ XPath requeteXpath = XPath.newInstance("//journal");
+ List results = requeteXpath.selectNodes(racine);
+
+ Iterator iter = results.iterator();
+ // Pour tous les journaux
+ while (iter.hasNext()) {
+ Element noeudCourant = (Element) iter.next();
+ // Recherche attributs
+ String label = noeudCourant.getAttribute("label").getValue();
+ String prefix = noeudCourant.getAttribute("prefix").getValue();
+ String description = noeudCourant.getAttribute("description")
+ .getValue();
+ // Création bdd
+ result = journalServiceImpl.createJournal(label, prefix,
+ description);
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+ }
+
+ // Account
+ requeteXpath = XPath.newInstance("//account");
+ results = requeteXpath.selectNodes(racine);
+
+ iter = results.iterator();
+ // Pour tous les accounts
+ while (iter.hasNext()) {
+ Element noeudCourant = (Element) iter.next();
+ // Recherche attributs
+ String label = noeudCourant.getAttribute("label").getValue();
+ String accountNumber = noeudCourant.getAttribute(
+ "accountNumber").getValue();
+ String masterAccount = noeudCourant.getAttribute(
+ "masterAccount").getValue();
+ String typeAccount = noeudCourant.getAttribute("type")
+ .getValue();
+ // Création bdd
+ result = accountServiceImpl.createAccount(accountNumber, label,
+ masterAccount, typeAccount);
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+ }
+
+ // Period
+ requeteXpath = XPath.newInstance("//period");
+ results = requeteXpath.selectNodes(racine);
+
+ iter = results.iterator();
+ // Pour tous les periods
+ while (iter.hasNext()) {
+ Element noeudCourant = (Element) iter.next();
+ // Recherche attributs
+ String idPeriod = noeudCourant.getAttribute("id").getValue();
+ int year = Integer.parseInt(noeudCourant.getAttribute(
+ "beginYear").getValue());
+ int month = Integer.parseInt(noeudCourant.getAttribute(
+ "beginMonth").getValue());
+ int day = Integer.parseInt(noeudCourant
+ .getAttribute("beginDay").getValue());
+ Date beginPeriod = new Date(year - 1900, month, day);
+ year = Integer.parseInt(noeudCourant.getAttribute("endYear")
+ .getValue());
+ month = Integer.parseInt(noeudCourant.getAttribute("endMonth")
+ .getValue());
+ day = Integer.parseInt(noeudCourant.getAttribute("endDay")
+ .getValue());
+ Date endPeriod = new Date(year - 1900, month, day);
+ // Création bdd
+ result = periodServiceImpl.createPeriod(beginPeriod, endPeriod,
+ false);
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+
+ // Transaction
+ requeteXpath = XPath
+ .newInstance("//transaction[@idTimeSpan=//timespan[@idPeriod='"
+ + idPeriod + "']/@id]");
+ List resultsTransaction = requeteXpath.selectNodes(racine);
+ Iterator iterTrans = resultsTransaction.iterator();
+ // Pour tous les transactions
+ while (iterTrans.hasNext()) {
+ Element noeudCourantTrans = (Element) iterTrans.next();
+
+ // Recherche attributs
+
+ // Id transaction XMl
+ String idTransactionXML = noeudCourantTrans.getAttribute(
+ "id").getValue();
+ // Recherche du journal en DTO
+ String idJournal = noeudCourantTrans.getAttribute(
+ "idJournal").getValue();
+ requeteXpath = XPath.newInstance("//journal[@id='"
+ + idJournal + "']/@label");
+ String label = requeteXpath.valueOf(racine);
+ JournalDTO journalDTO = journalServiceImpl
+ .searchJournalDTOWithLabel(label);
+ // Recherche du timeSpan en DTO
+ String idtimeSpan = noeudCourantTrans.getAttribute(
+ "idTimeSpan").getValue();
+ requeteXpath = XPath.newInstance("//timespan[@id='"
+ + idtimeSpan + "']/@beginYear");
+ year = Integer.parseInt(requeteXpath.valueOf(racine));
+ requeteXpath = XPath.newInstance("//timespan[@id='"
+ + idtimeSpan + "']/@beginMonth");
+ month = Integer.parseInt(requeteXpath.valueOf(racine));
+ requeteXpath = XPath.newInstance("//timespan[@id='"
+ + idtimeSpan + "']/@beginDay");
+ day = Integer.parseInt(requeteXpath.valueOf(racine));
+ Date beginTimeSpan = new Date(year - 1900, month, day);
+ TimeSpanDTO timeSpanDTO = timeSpanServiceImpl
+ .searchTimeSpanDTOByDate(beginTimeSpan);
+
+ // Création de transaction DTO
+ TransactionDTO transactionDTO = new TransactionDTO();
+ transactionDTO.setJournalDTO(journalDTO);
+ transactionDTO.setTimeSpanDTO(timeSpanDTO);
+ // entryDate
+ year = Integer.parseInt(noeudCourantTrans.getAttribute(
+ "entryDateYear").getValue());
+ month = Integer.parseInt(noeudCourantTrans.getAttribute(
+ "entryDateMonth").getValue());
+ day = Integer.parseInt(noeudCourantTrans.getAttribute(
+ "entryDateDay").getValue());
+ Date entryDate = new Date(year - 1900, month, day);
+ transactionDTO.setEntryDate(entryDate);
+ // voucherRef
+ String voucherRef = noeudCourantTrans.getAttribute(
+ "voucherRef").getValue();
+ transactionDTO.setVoucherRef(voucherRef);
+ // description
+ String description = noeudCourantTrans.getAttribute(
+ "description").getValue();
+ transactionDTO.setDescription(description);
+
+ // Création bdd
+ String idTransactionCallao = transactionServiceImpl
+ .createTransaction(transactionDTO);
+
+ // Entry
+ requeteXpath = XPath.newInstance("//entry[@idTransaction='"
+ + idTransactionXML + "']");
+ List resultsEntry = requeteXpath.selectNodes(racine);
+
+ Iterator iterEntry = resultsEntry.iterator();
+ // Pour tous les entries
+ while (iterEntry.hasNext()) {
+ Element noeudEntry = (Element) iterEntry.next();
+
+ // Recherche attributs
+
+ // Transaction DTO
+ transactionDTO = transactionServiceImpl
+ .searchTransactionDTO(idTransactionCallao);
+ // Account DTO
+ String idAccount = noeudEntry.getAttribute("idAccount")
+ .getValue();
+ requeteXpath = XPath.newInstance("//account[@id='"
+ + idAccount + "']/@accountNumber");
+ String accountNumber = requeteXpath.valueOf(racine);
+ AccountDTO accountDTO = accountServiceImpl
+ .searchAccountDTO(accountNumber);
+ // Entry DTO
+ EntryDTO entryDTO = new EntryDTO();
+ entryDTO.setAccountDTO(accountDTO);
+ entryDTO.setTransactionDTO(transactionDTO);
+ // Description
+ description = noeudEntry.getAttribute("description")
+ .getValue();
+ entryDTO.setDescription(description);
+ // Amount
+ String amount = noeudEntry.getAttribute("amount")
+ .getValue();
+ entryDTO.setAmount(amount);
+ // Debit
+ boolean debit = noeudEntry.getAttribute("debit")
+ .getValue().equals("true");
+ entryDTO.setDebit(debit);
+ // Lettering
+ String lettering = noeudEntry.getAttribute("lettering")
+ .getValue();
+ entryDTO.setLettering(lettering);
+ // Detail
+ String detail = noeudEntry.getAttribute("detail")
+ .getValue();
+ entryDTO.setDetail(detail);
+ // Création bdd
+ result = transactionServiceImpl.addEntry(entryDTO);
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+ }
+ }
+
+
+ // Bloquer Period
+ boolean lock = noeudCourant.getAttribute("locked").getValue()
+ .equals("true");
+ // Si la période est bloquée
+ if (lock) {
+ // Bloque tous ses timeSpans
+ result = periodServiceImpl
+ .blockAllTimeSpanOfPeriod(periodServiceImpl
+ .searchPeriodWithDate(beginPeriod));
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+ // bloque la période
+ result = periodServiceImpl.blockPeriod(periodServiceImpl
+ .searchPeriodWithDate(beginPeriod));
+
+ } else {
+ // On regarde si il y a besoin de bloquer les timeSpans
+ requeteXpath = XPath.newInstance("//timespan[@idPeriod = '"
+ + idPeriod + "']");
+ List resultsTimeSpan = requeteXpath.selectNodes(racine);
+ Iterator iterTimeSpan = resultsTimeSpan.iterator();
+ // Pour tous les timeSpans
+ while (iterTimeSpan.hasNext()) {
+ Element noeudCourantTimeSpan = (Element) iterTimeSpan
+ .next();
+ // Recherche attributs
+ year = Integer.parseInt(noeudCourantTimeSpan
+ .getAttribute("beginYear").getValue());
+ month = Integer.parseInt(noeudCourantTimeSpan
+ .getAttribute("beginMonth").getValue());
+ day = Integer.parseInt(noeudCourantTimeSpan
+ .getAttribute("beginDay").getValue());
+ Date beginTimeSpan = new Date(year - 1900, month, day);
+ lock = noeudCourantTimeSpan.getAttribute("locked")
+ .getValue().equals("true");
+ // Bloque le timeSpan
+ if (lock) {
+ timeSpanServiceImpl
+ .blockTimeSpan(timeSpanServiceImpl
+ .searchTimeSpanByDate(beginTimeSpan));
+ }
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+ }
+ }
+
+ }
+
+ } catch (JDOMException e) {
+ log.error("Erreur JDOM " + e.getMessage());
+ e.printStackTrace();
+ }
+
+ // Détection des erreurs
+ if (!existError) {
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ return result;*/
+ }
+
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/JournalServiceImpl.java (from rev 2802, trunk/lima-business/src/main/java/org/chorem/lima/business/JournalServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/JournalServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/JournalServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -0,0 +1,473 @@
+/*
+ * *##% Callao JournalServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Journal;
+import org.chorem.lima.entity.JournalDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.entity.Transaction;
+import org.chorem.lima.entity.TransactionDAO;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Implémente la fonction multi-journal. Il est possible de créer ici le
+ * journal des ventes, le journal des achats, etc.
+ *
+ * @author Rémi Chapelet
+ */
+public class JournalServiceImpl {
+
+ private static final Log log = LogFactory.getLog(JournalServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ //private ConvertJournal convertJournal = new ConvertJournal();
+
+ public JournalServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Création d'un journal. Il peut être unique sur son label (au choix).
+ *
+ * @param journal journal
+ * @throws LimaException
+ */
+ public void createJournal(Journal journal) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+
+ // Si on souhaite avoir un journal unique avec son label
+
+ Journal journal = searchJournalWithLabel(label);
+ // Si un journal existe déjà avec ce label
+ if (journal != null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Un journal avec le label " + label
+ + " existe déjà !");
+ }
+ result = ServiceHelper.JOURNAL_DOUBLE;
+ } else {
+ // Creation du journal
+ Journal newJournal = journalDAO.create();
+ newJournal.setLabel(label);
+ newJournal.setPrefix(prefix);
+ newJournal.setDescription(description);
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;*/
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // test si un journal de ce nom existe deja
+ JournalDAO journalDAO = LimaCallaoDAOHelper.getJournalDAO(transaction);
+ Journal existingJournal = journalDAO.findByLabel(journal.getLabel());
+ if (existingJournal != null) {
+ throw new LimaBusinessException(_("An journal already exists with this label : %s", journal.getLabel()));
+ }
+
+ // creation du journal
+ journalDAO.create(journal);
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Création d'un journal à partir de son DTO.
+ * @param journalDTO Journal au format DTO.
+ * @return
+ *
+ public String createJournal(JournalDTO journalDTO) {
+ String result;
+ result = createJournal(journalDTO.getLabel(), journalDTO.getPrefix(),
+ journalDTO.getDescription());
+ return result;
+ }*/
+
+ public List<Journal> getAllJournal() throws LimaException {
+ /*List<JournalDTO> listJournalDTO = new ArrayList<JournalDTO>();
+
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+ // Creation du journal
+ List<Journal> listJournal = journalDAO.findAll();
+ // Pour chaque journal, on le transforme en DTO
+ for (Journal journal : listJournal) {
+ // Converti en DTO
+ JournalDTO journalDTO = convertJournal
+ .journalEntityToDto(journal);
+ // Ajoute à la liste
+ listJournalDTO.add(journalDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listJournalDTO;*/
+
+ List<Journal> journalsList = new ArrayList<Journal>();
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // test si un journal de ce nom existe deja
+ JournalDAO journalDAO = LimaCallaoDAOHelper.getJournalDAO(transaction);
+ List<Journal> journals = journalDAO.findAll();
+ journalsList.addAll(journals);
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ }
+ }
+
+ return journalsList;
+ }
+
+ /*
+ * Permet de rechercher un journal existant à partir de son label.
+ * ATTENTION : il est possible que plusieurs journaux existent avec ce
+ * même label. La méthode renvoie le premier trouvé.
+ * @param prefix préfixe du journal recherché
+ * @return
+ *
+ public Journal searchJournalWithLabel(String label) {
+ Journal journalResult = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+ // Creation du journal
+ journalResult = journalDAO.findByLabel(label);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return journalResult;
+ }*/
+
+ /*
+ * Permet de rechercher un journal existant à partir du label.
+ * Le journal recherché est converti automatiquement en format DTO.
+ * @param prefix préfixe du journal recherché
+ * @return
+ *
+ public JournalDTO searchJournalDTOWithLabel(String label) {
+ Journal journal = searchJournalWithLabel(label);
+ JournalDTO journalDTO = convertJournal.journalEntityToDto(journal);
+ return journalDTO;
+ }*/
+
+ /*
+ * Permet de rechercher un journal unique identifé par son topiaId.
+ * @param topiaId identifiant du journal recherché
+ * @return
+ *
+ public Journal searchJournalWithTopiaId(String topiaId) {
+ Journal journalResult = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+ // Creation du journal
+ journalResult = journalDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return journalResult;
+ }*/
+
+ /*
+ * Permet de rechercher un journal existant à partir du topiaId.
+ * Le journal recherché est converti automatiquement en format DTO.
+ * @param prefix préfixe du journal recherché
+ * @return
+ *
+ public JournalDTO searchJournalDTOWithTopiaId(String topiaId) {
+ Journal journal = searchJournalWithTopiaId(topiaId);
+ JournalDTO journalDTO = convertJournal.journalEntityToDto(journal);
+ return journalDTO;
+ }*/
+
+ /*
+ * Permet de modifier un journal.
+ * @param label
+ * @param prefix
+ * @return
+ *
+ public String modifyJournal(String topiaId, String label, String prefix,
+ String description) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ Journal journalModify = searchJournalWithTopiaId(topiaId);
+ // Si le journal n'existe pas
+ if (journalModify == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le journal " + label + " n'existe pas !");
+ }
+ result = ServiceHelper.JOURNAL_NOT_EXIST;
+ } else // Sinon on modifie le journal
+ {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+ // Modifie le journal
+ journalModify.setPrefix(prefix);
+ journalModify.setDescription(description);
+ journalDAO.update(journalModify);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /**
+ * Permet d'effacer un journal dans la base de données.
+ *
+ * ATTENTION : si un journal est associé avec des transactions, il est alors
+ * impossible de supprimer celui-ci.
+ *
+ * @param prefix préfixe du journal à supprimer
+ * @return
+ * @throws LimaException
+ */
+ public void removeJournal(Journal journal) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ Journal journalDelete = searchJournalWithTopiaId(topiaId);
+ // Si le journal n'existe pas
+ if (journalDelete == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le journal " + topiaId + " n'existe pas !");
+ }
+ result = ServiceHelper.JOURNAL_NOT_EXIST;
+ } else // Sinon on efface le journal
+ {
+
+ // Vérifie si une transaction n'appartient pas à ce journal.
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche au moins une transaction avec ce journal.
+ Transaction transaction = transactionDAO
+ .findByJournal(journalDelete);
+ // Il existe au moins une transaction
+ if (transaction != null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le journal " + topiaId
+ + " possède des transactions comptables !");
+ }
+ result = ServiceHelper.JOURNAL_WITH_TRANSACTIONS;
+ } else {
+
+ // Efface le journal
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+ // Supprime le journal
+ journalDAO.delete(journalDelete);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;*/
+
+ TopiaContext topiaTransaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ topiaTransaction = rootContext.beginTransaction();
+
+ // Vérifie si une transaction n'appartient pas à ce journal.
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
+ Transaction transaction = transactionDAO.findByJournal(journal);
+ if (transaction != null) {
+ throw new LimaBusinessException("Can't delete journal with transactions");
+ }
+
+ // test si un journal de ce nom existe deja
+ JournalDAO journalDAO = LimaCallaoDAOHelper.getJournalDAO(topiaTransaction);
+ journalDAO.delete(journal);
+
+ // commit
+ topiaTransaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ if (topiaTransaction != null) {
+ try {
+ topiaTransaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ finally {
+ if (topiaTransaction != null) {
+ try {
+ topiaTransaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Permet d'effacer un journal dans la base de données.
+ * ATTENTION : si un journal est associé avec des transactions, il est alors
+ * impossible de supprimer celui-ci.
+ * @param journalDTO journal au format DTO à supprimer
+ * @return
+ *
+ public String removeJournal(JournalDTO journalDTO) {
+ String result = removeJournal(journalDTO.getId());
+ return result;
+ }*/
+
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/LogServiceImpl.java (from rev 2802, trunk/lima-business/src/main/java/org/chorem/lima/business/LogServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/LogServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/LogServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -0,0 +1,366 @@
+/*
+ * *##% Callao LogServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.EntryLog;
+import org.chorem.lima.entity.EntryLogDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Permet d'ajouter des logs au systeme.
+ *
+ * ATTENTION on ne peut supprimer un log.
+ *
+ * @author Rémi Chapelet
+ */
+public class LogServiceImpl { //implements LogService {
+
+ /** log */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(LogServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+
+ public LogServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Création d'un log dans le systeme.
+ *
+ * @param entryLog date de creation du log
+ * @throws LimaException
+ */
+ public void addLog(EntryLog entryLog) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryLogDAO logDAO = LimaCallaoDAOHelper.getEntryLogDAO(topiaContext);
+ // Creation du log
+ EntryLog newlog = logDAO.create();
+ newlog.setLogDate(logDate);
+ newlog.setTransDate(transDate);
+ newlog.setVoucherRef(voucherRef);
+ newlog.setType(type);
+ newlog.setTransDesc(transDesc);
+ newlog.setEntryDesc(entryDesc);
+ newlog.setAmount(amount);
+ newlog.setDebit(debit);
+ newlog.setLettering(lettering);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ // Affichage pour les logs
+ String topiaId = newlog.getTopiaId();
+ if (log.isInfoEnabled()) {
+ log.info("Log created: "+ topiaId);
+ }
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;*/
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // creation
+ EntryLogDAO entryLogDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(transaction);
+ entryLogDAO.create(entryLog);
+
+ // commit
+ transaction.commitTransaction();
+ } catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create entry log", ex);
+ } finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create entry log", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Création d'un log à partir d'un log DTO.
+ * @param logDTO log en format DTO qu'on souhaite créer
+ * @return
+ *
+ public String addLog (LogDTO logDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Vérifie si logDTO existe
+ if (logDTO != null)
+ {
+ result = addLog(logDTO.getLogDate(),logDTO.getTransDate(),logDTO.getType(),
+ logDTO.getVoucherRef(),logDTO.getTransDesc(),logDTO.getEntryDesc(),
+ logDTO.getAmount(),logDTO.isDebit(),logDTO.getLettering());
+ }
+ return result;
+ }*/
+
+ /**
+ * Recherche tous les logs dans la base de donnees.
+ *
+ * @return la liste des logs
+ * @throws LimaException
+ */
+ public List<EntryLog> listeAllLog() throws LimaException {
+ /*List<EntryLog> listelog = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryLogDAO logDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(topiaContext);
+ // recherche des log
+ listelog = logDAO.findAll();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ if (log.isInfoEnabled()) {
+ log.info("Search all logs");
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listelog;*/
+
+ List<EntryLog> entryLogsList = new ArrayList<EntryLog>();
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // creation
+ EntryLogDAO entryLogDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(transaction);
+ List<EntryLog> entryLogs = entryLogDAO.findAll();
+ entryLogsList.addAll(entryLogs);
+
+ // commit
+ transaction.commitTransaction();
+ } catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create entry log", ex);
+ } finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create entry log", ex);
+ }
+ }
+ }
+
+ return entryLogsList;
+ }
+
+ /*
+ * Permet de renvoyer tous les logs au format DTO.
+ * @return
+ *
+ public List<LogDTO> listeAllLogDTO() {
+ List<LogDTO> listLogDTO = new ArrayList<LogDTO>();
+ // On recherche tous les logs.
+ List<EntryLog> listLog = listeAllLog();
+ // Pour chaque log, on le converti en logDTO et on l'ajoute à la nouvelle liste de DTO
+ for (EntryLog log : listLog) {
+ // conerti de l'entity en DTO
+ LogDTO logDTO = convertLog.logEntityToDto(log);
+ // Ajoute à la liste des logs DTO
+ listLogDTO.add(logDTO);
+ }
+ return listLogDTO;
+ }*/
+
+ /*
+ * Renvoie une liste de tous les logs suivant la date de creation
+ * @param datecreate date de creation des logs recherchés
+ * @return une liste des logs trouves
+ *
+ public List<EntryLog> searchLogWithDateCreate(Date dateCreate) {
+ List<EntryLog> listelog = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryLogDAO logDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(topiaContext);
+ // recherche des log
+ listelog = logDAO.findAllByLogDate(dateCreate);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ if (log.isInfoEnabled()) {
+ log.info("Log(s) find : " + listelog.size() + "log(s)");
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listelog;
+ }*/
+
+ /*
+ * Permet de rechercher tous les logs suivant la date de création, c'est à
+ * dire de l'opération effectuée sur une entry à un jour précis, et qui a
+ * déclenchée automatiquement une création de log.
+ * La méthode renvoie sous forme de liste, en convertissant les objets
+ * entitys en DTO.
+ * @param dateCreate date de création des logs recherchés
+ * @return
+ *
+ public List<LogDTO> searchLogDTOWithDateCreate(Date dateCreate) {
+ List<LogDTO> listLogDTO = new ArrayList<LogDTO>();
+ // On recherche tous les logs suivant la date de création.
+ List<EntryLog> listLog = searchLogWithDateCreate(dateCreate);
+ // Pour chaque log, on le converti en logDTO et on l'ajoute à la nouvelle liste de DTO
+ for (EntryLog log : listLog) {
+ // conerti de l'entity en DTO
+ LogDTO logDTO = convertLog.logEntityToDto(log);
+ // Ajoute à la liste des logs DTO
+ listLogDTO.add(logDTO);
+ }
+ return listLogDTO;
+ }*/
+
+ /*
+ * Recherche un log avec son identifiant topiaId.
+ * @param topiaId identifiant d'un log
+ * @return
+ *
+ public EntryLog searchLogWithTopiaId(String topiaId) {
+ EntryLog logSearch = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryLogDAO logDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(topiaContext);
+ // Creation du journal
+ logSearch = logDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return logSearch;
+ }*/
+
+ /*
+ * Efface un log : uniquement utilisé pour supprimer les logs dans les tests
+ * unitaires.
+ * @param topiaId identifiant du log à supprimer
+ * @return
+ *
+ public String removeLog(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ EntryLog logDelete = searchLogWithTopiaId(topiaId);
+ // Si le log n'existe pas
+ if (logDelete == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le log " + topiaId + " n'existe pas !");
+ }
+ } else // Sinon on efface le log
+ {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryLogDAO logDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(topiaContext);
+ // Supprime le log
+ logDAO.delete(logDelete);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de supprimer un log à partir de son DTO.
+ * @param logDTO log à supprimer
+ * @return
+ *
+ public String removeLog(LogDTO logDTO) {
+ String result = removeLog(logDTO.getId());
+ return result;
+ }*/
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/PeriodServiceImpl.java (from rev 2802, trunk/lima-business/src/main/java/org/chorem/lima/business/PeriodServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/PeriodServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/PeriodServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -0,0 +1,505 @@
+/*
+ * *##% Callao PeriodServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.entity.Period;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Gestion des périodes.
+ * Chaque période doit posséder 12 timespans mensuels.
+ * Une période ne peut être supprimée et débloquée.
+ *
+ * @author Rémi Chapelet
+ */
+public class PeriodServiceImpl { //implements PeriodService {
+
+ private static final Log log = LogFactory.getLog(PeriodServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
+
+ public PeriodServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Permet de créer une période principale. Elle a une durée de un an,
+ * composées de 12 périodes mensuelles. Elle correspond à l'exercice
+ * comptable. Pour créer une nouvelle période, la précédente doit être
+ * obligatoirement clôturée.
+ * @param beginTimeSpan date début de période
+ * @param endTimeSpan date fin de période
+ * @param lock Vrai si la période est bloquée
+ * @return
+ */
+ public void createPeriod(Period period /*Date beginTimeSpan, Date endTimeSpan, boolean lock*/) {
+ /*// Par défaut lock est à false
+ lock = false;
+ String result = ServiceHelper.RESPOND_ERROR;
+
+ try {
+ boolean correctPeriod = false;
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Creation de la periodDate
+ PeriodDates newPeriod = new PeriodDates(beginTimeSpan, endTimeSpan);
+
+ // Creation de la période
+ Period period = periodDAO.create();
+ period.setBeginPeriod(newPeriod.getFromDate());
+ period.setEndPeriod(newPeriod.getThruDate());
+ period.setLocked(lock);
+ // Vérification si la période est correcte
+ correctPeriod = isCorrectPeriod(period);
+ if (correctPeriod) {
+ // Si elle est correcte : Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Ajout exercice du " + beginTimeSpan.toString()
+ + " au " + endTimeSpan.toString());
+ }
+
+ //Ajout des timeSpans mensuels
+ //Par défaut, il prend seulement la date beginTimeSpan, et calcule
+ //la date de fin, c'est pourquoi il est laissé deux fois "beginTimeSpan"
+ TimeSpanServiceImpl timeSpanImpl = new TimeSpanServiceImpl();
+ boolean stop = false; // En cas d'erreur lors de la création d'un timeSpan.
+
+ List<Date> monthList = newPeriod.getMonths();
+
+ int max = monthList.size();
+ log.debug("la periode fait:" + max);
+ for (int i = 0; i < max; i++) {
+ // Création timeSpan
+ result = timeSpanImpl.createTimeSpan(monthList.get(i),
+ monthList.get(i), period, false);
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ stop = true;
+ if (log.isErrorEnabled()) {
+ log.error("Erreur lors de la création des " + max
+ + " timeSpans");
+ }
+ result = ServiceHelper.PERIOD_CREATE_TIMESPANS;
+ }
+ // Supprimer la periode si stop = true
+ }
+ if (stop == false) {
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result; */
+ }
+
+ /*
+ * Permet de créer une période à partir d'une période DTO.
+ * @param periodDTO période à créer au format DTO.
+ * @return
+ *
+ public String createPeriod(PeriodDTO periodDTO) {
+ String result = createPeriod(periodDTO.getBeginPeriod(), periodDTO
+ .getEndPeriod(), false);
+ // Tous les timeSpans sont automatiquement créés avec la méthode createPeriod
+ return result;
+ }*/
+
+ /*
+ * Permet de vérifier si la période est correcte (aucun chevauchement avec
+ * les autres périodes, période(s) précédente(s) bloquée(s), formée de 1 à 24
+ * mois).
+ * @param period période à tester si elle est correcte
+ * @return
+ *
+ private boolean isCorrectPeriod(Period period) {
+ // Calcul du nombre de mois pour que la période soit valide (12 mois)
+ int number_months = dateUtil.numberOfMonths(period.getBeginPeriod(),
+ period.getEndPeriod());
+ boolean result = true;
+
+ if (number_months == 0 && number_months >= 24) // Periode de 1mois a 24 mois
+ {
+ if (log.isErrorEnabled()) {
+ log.error("Période du "
+ + period.getBeginPeriod()
+ + " au "
+ + period.getEndPeriod()
+ + " : L'exercice doit faire au minimum 1 mois et au maximum 24 mois");
+ }
+ result = false;
+ } else {
+ // Période(s) précédente(s) bloquée(s).
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Recherche les périodes qui ne sont pas bloquées.
+ List<Period> listePeriod = periodDAO.findAllByLocked(false);
+ // Recherche la dernière période, les dates doivent se suivre
+ Date date_search = period.getBeginPeriod();
+ Period previousPeriod = periodDAO.findByEndPeriod(dateUtil
+ .previousDay(date_search));
+ // Nombre de périodes dans la base
+ int number_period = periodDAO.findAll().size();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ // Si il y a au moins une période trouvée
+ if (!(listePeriod.isEmpty())) {
+ if (log.isErrorEnabled()) {
+ log.error("Il existe au moins une période précédente non bloquée !");
+ }
+ result = false;
+ }
+ // Si la période précédente correspond au jour précédent
+ // et vérifie si ce n'est pas la première période
+ if (previousPeriod == null && number_period != 0) {
+ if (log.isErrorEnabled()) {
+ log.error("Votre période doit être collée "
+ + "aux autres périodes !"
+ + date_search.toString() + " PPP "
+ + dateUtil.previousDay(date_search).toString());
+ }
+ result = false;
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Cette méthode permet de bloquer une période. Elle doit vérifier que
+ * tous les timeSpans mensuels sont bloqués.
+ * @param
+ * @return
+ *
+ public String blockPeriod(Period period) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // La période ne doit pas être nulle
+ if (period != null) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Recherche tous les timeSpans de la période non bloquées
+ List<TimeSpan> listeTimeSpan = timeSpanDAO
+ .findAllByPeriod(period);
+ boolean existTimeSpanNotBlock = false;
+ for (TimeSpan timeSpan : listeTimeSpan) {
+ // Si timeSpan non bloqué
+ if (!timeSpan.getLocked()) {
+ existTimeSpanNotBlock = true;
+ if (log.isErrorEnabled()) {
+ log.error("Le timeSpan du "
+ + timeSpan.getBeginTimeSpan().toString()
+ + " au "
+ + timeSpan.getEndTimeSpan().toString()
+ + " non bloqué !");
+ }
+ result = ServiceHelper.PERIOD_TIMESPAN_NOT_BLOCK;
+ }
+ }
+ // Si il n'existe pas de timeSpan non bloqué
+ if (!(existTimeSpanNotBlock)) {
+ // Bloque la période
+ period.setLocked(true);
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ periodDAO.update(period);
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ if (log.isInfoEnabled()) {
+ log.info("Période "
+ + period.getBeginPeriod().toString() + " au "
+ + period.getEndPeriod().toString()
+ + " bloquée avec succès.");
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de bloquer une période. Avec la périodeDTO passée en paramètre, on
+ * effectue une recherche avec la date de début pour récupérer la période
+ * dans la base de données. Il est possible de l'identifier avec son topiaId,
+ * mais il y a plus de risque que cette mentien ne soit pas renseignée dans
+ * l'objet periodDTO.
+ * @param periodDTO
+ * @return
+ *
+ public String blockPeriod(PeriodDTO periodDTO) {
+ // Recherche de la période
+ Period period = searchPeriodWithDate(periodDTO.getBeginPeriod());
+ String result = blockPeriod(period);
+ return result;
+ }*/
+
+ /*
+ * Permet de bloquer TOUS les timeSpans de la période
+ * @param period
+ * @return
+ *
+ public String blockAllTimeSpanOfPeriod(Period period) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ if (period == null) {
+ if (log.isErrorEnabled()) {
+ log.error("La période ne peut bloquer ses périodes mensuelles, "
+ + "il faut une période en entrée.");
+ }
+ } else {
+ // On bloque chaque timeSpan
+ boolean ErrorBlockTimeSpan = false;
+ List<TimeSpanDTO> listTimeSpanDTO = timeSpanServiceImpl
+ .searchListTimeSpanDTO(period);
+ // tri la liste des timeSpans dans l'ordre croissant des dates
+ Collections.sort(listTimeSpanDTO);
+ for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
+ result = timeSpanServiceImpl.blockTimeSpan(timeSpanDTO);
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ ErrorBlockTimeSpan = true;
+ }
+ }
+ // Si il n'y a pas eu d'erreurs pour bloquer les timespans
+ if (!ErrorBlockTimeSpan) {
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ if (log.isErrorEnabled()) {
+ log.error("Impossible de bloquer tous les timeSpans.");
+ }
+ result = ServiceHelper.PERIOD_ALL_TIMESPAN;
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Cette méthode est semblable à searchPeriodWithDateFirst. Elle permet
+ * de rechercher une période sans forcément connaître la date de départ. On
+ * donne une date quelconque, et elle retourne la période correspondante.
+ * @param d
+ * @return
+ *
+ public Period searchPeriodWithDate(Date d) {
+ Period period = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Recherche de toutes les périodes
+ List<Period> listePeriod = periodDAO.findAll();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ // Recherche de la période
+ for (Period periodSearch : listePeriod) {
+ // Recherche si la date d est entre la date de début et fin de la période
+ boolean periodBetweenDate = dateUtil.betweenDate(d,
+ periodSearch.getBeginPeriod(), periodSearch
+ .getEndPeriod());
+ // Si la date est comprise dans les limites de la période
+ if (periodBetweenDate) {
+ period = periodSearch;
+ }
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return period;
+ }*/
+
+ /*
+ * Permet de rechercher une période au format DTO avec une date. Cette date
+ * peut être quelconque (pas obligatoire d'être le premier jour de la période
+ * par exemple).
+ * @param d date comprise dans la période qu'on souhaite rechercher
+ * @return
+ *
+ public PeriodDTO searchPeriodDTOWithDate(Date d) {
+ Period period = searchPeriodWithDate(d);
+ // Converti la période en PeriodDTO
+ PeriodDTO periodDTO = convertPeriod.periodEntityToDto(period);
+ return periodDTO;
+ }*/
+
+ /*
+ * Permet de renvoyer tous les périodes en format DTO, avec tous les timeSpans
+ * en format DTO également.
+ * @return
+ *
+ public List<PeriodDTO> getAllPeriod() {
+ ArrayList<PeriodDTO> listAllPeriodDTO = new ArrayList<PeriodDTO>();
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Recherche de toutes les périodes
+ List<Period> listePeriod = periodDAO.findAll();
+ // Transforme les périodes en DTO
+ for (Period period : listePeriod) {
+ PeriodDTO periodDTO = convertPeriod.periodEntityToDto(period);
+ listAllPeriodDTO.add(periodDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listAllPeriodDTO;
+ }*/
+
+ /*
+ * Recherche une période précise, avec son identifiant topiaId.
+ * @param topiaId identifiant de la période
+ * @return
+ *
+ public Period searchPeriodWithTopiaId(String topiaId) {
+ Period periodSearch = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Creation du journal
+ periodSearch = periodDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return periodSearch;
+ }*/
+
+
+ /*
+ * Efface une période dans la base de données. Tous les timeSpans sont
+ * également effacés. Cette méthode est uniquement utilisée pour les tests
+ * unitaires.
+ * @param period
+ * @return
+ *
+ public String removePeriod(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ Period periodDelete = searchPeriodWithTopiaId(topiaId);
+ // Si la période n'existe pas
+ if (periodDelete == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("La période " + topiaId + " n'existe pas !");
+ }
+ result = ServiceHelper.PERIOD_NOT_EXIST;
+ } else // Sinon on efface la période
+ {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Débloque la période
+ periodDelete.setLocked(false);
+ // Mise à jour dans la bdd
+ periodDAO.update(periodDelete);
+ // Création BDD
+ topiaContext.commitTransaction();
+
+ // Supprime les timeSpans de la période
+ List<TimeSpanDTO> listTimeSpanDTO = timeSpanServiceImpl
+ .searchListTimeSpanDTO(periodDelete);
+ // tri la liste des timeSpans dans l'ordre décroissant des dates
+ Collections.sort(listTimeSpanDTO, Collections.reverseOrder());
+ // Débloque les timeSpans
+ for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
+ TimeSpan timeSpan = timeSpanServiceImpl
+ .searchTimeSpanByDate(timeSpanDTO);
+ // Si le timeSpan est bloqué
+ if (timeSpanDTO.isLocked()) {
+ // débloque le timeSpan
+ timeSpanServiceImpl.unblockTimeSpan(timeSpan);
+ }
+ }
+ // Efface les timeSpans
+ for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
+ TimeSpan timeSpan = timeSpanServiceImpl
+ .searchTimeSpanByDate(timeSpanDTO);
+ // efface le timeSpan
+ timeSpanServiceImpl.removeTimeSpan(timeSpan);
+ }
+
+
+ //Supprime la période
+ periodDAO.delete(periodDelete);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'effacer une période au format DTO.
+ * @param periodDTO la période à supprimer
+ * @return
+ *
+ public String removePeriod(PeriodDTO periodDTO) {
+ String result = removePeriod(periodDTO.getId());
+ return result;
+ }*/
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java (from rev 2802, trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -0,0 +1,61 @@
+package org.chorem.lima.business.ejb;
+
+import org.nuiton.topia.TopiaContext;
+
+public class ReportServiceImpl { //implements ReportService {
+
+ //@Override
+ public String generateAccount(String number, String amount, String label) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String generateBalanceSheet(String period) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String generateCashFlowStatement(String period) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String generateGeneralLedger(String period) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String generateIncomeStatement(String period) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String generateJournal(String type, String period) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String[] getMethods() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public void destroy() {
+ // TODO Auto-generated method stub
+
+ }
+
+ //@Override
+ public void init(TopiaContext arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TimeSpanServiceImpl.java (from rev 2802, trunk/lima-business/src/main/java/org/chorem/lima/business/TimeSpanServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TimeSpanServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TimeSpanServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -0,0 +1,534 @@
+/*
+ * *##% Callao TimeSpanServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.entity.TimeSpan;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Gestion des périodes intermédiaires durant l'exercice.
+ * Chaque timeSpan sera fixe, et devra correspondre à un mois complet.
+ *
+ * @author Rémi Chapelet
+ */
+public class TimeSpanServiceImpl { //implements TimeSpanService {
+
+ /** log */
+ private static final Log log = LogFactory.getLog(TimeSpanServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+
+ public TimeSpanServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Création d'une période timeSpan mensuelle avec une date de début et de fin. Une période
+ * peut être bloquée ou non.
+ * @param beginTimeSpan date de début de période
+ * @param endTimeSpan date de fin de période
+ * @param locked est à vrai si la période doit être bloquée.
+ * @return
+ */
+ public void createTimeSpan(TimeSpan timeSpan /*Date beginTimeSpan, Date endTimeSpan,
+ Period period, boolean locked*/) {
+/*
+ // timeSpan correspond à une période mensuelle.
+ // La fonction va donc prendre seulement pour date de référence la
+ // date beginTimeSpan. Elle calcule automatiquement la date de fin
+ // suivant le mois.
+ DateUtil dateutil = new DateUtil();
+ // Initialise la date de début au premier du mois
+ beginTimeSpan = dateutil.InitDateFirstDayMonth(beginTimeSpan);
+ // Initialise la date de fin au dernier du mois
+ endTimeSpan = dateutil.InitDateEndDayMonth(beginTimeSpan);
+ if (log.isInfoEnabled()) {
+ log.info("Nouveau timeSpan du " + beginTimeSpan.toString() + " au "
+ + endTimeSpan.toString());
+ }
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Creation du timespan
+ TimeSpan newtimeSpan = timeSpanDAO.create();
+ newtimeSpan.setBeginTimeSpan(beginTimeSpan);
+ newtimeSpan.setEndTimeSpan(endTimeSpan);
+ newtimeSpan.setLocked(locked);
+ newtimeSpan.setPeriod(period);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ if (log.isInfoEnabled()) {
+ log.info("Ajout avec succes du timeSpan");
+ }
+ return ServiceHelper.RESPOND_SUCCESS;
+ } catch (TopiaException e) {
+ log.error(e);
+ return ServiceHelper.RESPOND_ERROR;
+ }*/
+ }
+
+ /*
+ * Permet de trouver un timespan directement avec une date. La date peut
+ * être quelconque. Exemple : d = 17 sept 2000, renvoie la période du
+ * 1 sept au 30 sept 2000.
+ * @param d
+ * @return
+ *
+ public TimeSpan searchTimeSpanByDate(Date d) {
+ TimeSpan timeSpan = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Par précaution, on initialise la date au debut du mois
+ DateUtil dateutil = new DateUtil();
+ // Recherche du timeSpan
+ Date searchDate = dateutil.InitDateFirstDayMonth(d);
+ timeSpan = timeSpanDAO.findByBeginTimeSpan(searchDate);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return timeSpan;
+ }*/
+
+ /*
+ * Recherche un timeSpan précis, avec sa date de création.
+ * @param timeSpanDTO timeSpan au format DTO qu'on recherche
+ * @return
+ *
+ public TimeSpan searchTimeSpanByDate(TimeSpanDTO timeSpanDTO) {
+ TimeSpan timeSpan = searchTimeSpanByDate(timeSpanDTO.getBeginTimeSpan());
+ return timeSpan;
+ }*/
+
+ /*
+ * Recherche un timeSpan UNIQUE. Celui est identifié par son topiaId.
+ * @param topiaId Identifiant du timeSpan recherché
+ * @return
+ *
+ public TimeSpan searchTimeSpanWithTopiaId(String topiaId) {
+ TimeSpan timeSpan = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Recherche du timeSpan
+ timeSpan = timeSpanDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return timeSpan;
+ }*/
+
+ /*
+ * Permet de rechercher un timeSpan à l'aide d'une date. Il fait appel
+ * à la méthode searchTimeSpanByDate.
+ * La méthode renvoie un objet DTO.
+ * @param d
+ * @return
+ *
+ public TimeSpanDTO searchTimeSpanDTOByDate(Date d) {
+ TimeSpan timeSpan = searchTimeSpanByDate(d);
+ TimeSpanDTO timeSpanDTO = convertTimeSpan.timeSpanEntityToDto(timeSpan);
+ return timeSpanDTO;
+ }*/
+
+ /*
+ * Permet de faire une recherche de tous les timeSpans d'une période.
+ * @param period
+ * @return
+ *
+ public List<TimeSpan> searchListTimeSpan(Period period) {
+ List<TimeSpan> listTimeSpan = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Recherche les timeSpans avec cette période
+ listTimeSpan = timeSpanDAO.findAllByPeriod(period);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listTimeSpan;
+ }*/
+
+ /*
+ * Permet de rechercher tous les timeSpans suivant une période donnée.
+ * Chaque timeSpan est converti ensuite en DTO.
+ * @param period
+ * @return
+ *
+ public List<TimeSpanDTO> searchListTimeSpanDTO(Period period) {
+ List<TimeSpanDTO> listTimeSpanDTO = new ArrayList<TimeSpanDTO>();
+ List<TimeSpan> listTimeSpan = searchListTimeSpan(period);
+ for (TimeSpan timeSpan : listTimeSpan) {
+ TimeSpanDTO timeSpanDTO = convertTimeSpan
+ .timeSpanEntityToDto(timeSpan);
+ listTimeSpanDTO.add(timeSpanDTO);
+ }
+ return listTimeSpanDTO;
+ }*/
+
+ /*
+ * Permet de bloquer un timespan, celle-ci ne doit pas être bloquée.
+ * La fonction doit s'assurer que les timeSpans précédents doivent être
+ * bloqués.
+ * Les transactions doivent être équilibrées
+ * @param timespan période qui doit être fermée
+ * @param period période (12 smois)
+ *
+ public String blockTimeSpan(TimeSpan timespan) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Si la période n'est pas déjà fermée.
+ if (timespan.getLocked()) {
+ if (log.isInfoEnabled()) {
+ log.info("Timespan deja bloqué !");
+ }
+ } else {
+ Period period = getPeriodWithTimeSpan(timespan);
+ if (period.getLocked()) {
+ if (log.isErrorEnabled()) {
+ log.error("La période du timespan est bloquée !");
+ }
+ } else {
+ // Vérifie si tous les timeSpans précédents sont bloqués
+ boolean AllTimeSpanBlock = alltimeSpanBlocked(timespan, period);
+ if (AllTimeSpanBlock) {
+ // Enregistrement dans la base de données
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext
+ .beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+
+ // Vérifie si les transactons sont équilibrées
+ List<Transaction> listTransaction = transactionServiceImpl
+ .searchListTransactionWithTimeSpan(timespan);
+ boolean isTransactionBalanced = true;
+ boolean existTransactionNotBalanced = false;
+ for (Transaction transaction : listTransaction) {
+ isTransactionBalanced = transactionServiceImpl
+ .isTransactionBalanced(transaction);
+ if (!isTransactionBalanced) {
+ if (log.isInfoEnabled()) {
+ log.info("La transaction n'est pas bloquée.");
+ }
+ existTransactionNotBalanced = true;
+ }
+ }
+ if (!existTransactionNotBalanced) {
+ // Bloque la période
+ timespan.setLocked(true);
+ // Mise à jour de timespan dans la BDD
+ timeSpanDAO.update(timespan);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Timespan bloqué avec succès");
+ }
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ result = ServiceHelper.TRANSACTION_NOT_BALANCED;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ } else {
+ if (log.isErrorEnabled()) {
+ log.error("Il existe un ou plusieurs timespans précédents"
+ + " non bloqués.");
+ }
+ result = ServiceHelper.TIMESPAN_PREC_NOT_BLOCK;
+ }
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de bloquer une période au format DTO.
+ *
+ * @param timespanDTO
+ * @return
+ *
+ public String blockTimeSpan(TimeSpanDTO timespanDTO) {
+ return blockTimeSpan(searchTimeSpanByDate(timespanDTO));
+ }*/
+
+ /*
+ * Permet de débloquer un timespan, à condition que les timespans suivants
+ * celui-ci soient bien débloqués.
+ * @param timespan
+ * @param period
+ * @return
+ *
+ public String unblockTimeSpan(TimeSpan timespan) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Si le timspan n'est pas bloqué
+ if (!timespan.getLocked()) {
+ if (log.isWarnEnabled()) {
+ log.warn("Timespan non bloqué !");
+ }
+ } else {
+ Period period = getPeriodWithTimeSpan(timespan);
+ if (period.getLocked()) {
+ if (log.isErrorEnabled()) {
+ log.error("La période du timespan est bloquée !");
+ }
+ } else {
+ boolean NextTimeSpanUnblock = nextTimeSpanUnblock(timespan,
+ period);
+ // Si aucun timespan suivant bloqué
+ if (NextTimeSpanUnblock) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext
+ .beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // débloque la période
+ timespan.setLocked(false);
+ // Mise à jour de timespan dans la BDD
+ timeSpanDAO.update(timespan);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Timespan débloqué avec succès");
+ }
+ result = ServiceHelper.RESPOND_SUCCESS;
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ } else {
+ result = ServiceHelper.TIMESPAN_NEXT_NOT_BLOCK;
+ }
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de bloquer une période au format DTO.
+ *
+ * @param timespanDTO
+ * @return
+ *
+ public String unblockTimeSpan(TimeSpanDTO timespanDTO) {
+ return unblockTimeSpan(searchTimeSpanByDate(timespanDTO));
+ }*/
+
+ /*
+ * Cette méthode va rechercher tous les timeSpans non bloqués après
+ * le timeSpan renseigné en paramètre.
+ * Si elle trouve au moins un timeSpan NON bloqué, elle renvoie alors faux.
+ * Cette méthode permet essentiellement de définir si il est possible
+ * ou non de bloquer un timeSpan. A savoir, un timeSpan ne peut être bloqué,
+ * si il existe des timeSpans suivant (dans le calendrier) qui sont non
+ * bloqués.
+ * @param timespan
+ * @param period
+ * @return
+ *
+ private boolean nextTimeSpanUnblock(TimeSpan timespan, Period period) {
+ boolean NextTimeSpanUnblock = false;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Recherche des TimeSpans avec la même période.
+ // (on doit récupérer normalement 12 timeSpans)
+ List<TimeSpan> listeTimeSpanOfPeriod = timeSpanDAO
+ .findAllByPeriod(period);
+ NextTimeSpanUnblock = true;
+ for (TimeSpan timeSpanNext : listeTimeSpanOfPeriod) {
+ // Si le timespan est après celui qu'on souhaite bloquer ET est non bloqué
+ if (timeSpanNext.getBeginTimeSpan().compareTo(
+ timespan.getBeginTimeSpan()) == 1
+ && timeSpanNext.getLocked()) {
+ NextTimeSpanUnblock = false;
+ if (log.isInfoEnabled()) {
+ log.info("Timespan " + timeSpanNext.toString()
+ + " est bloqué");
+ }
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return NextTimeSpanUnblock;
+ }*/
+
+ /*
+ * Permet de renvoyer une période dont appartient le timeSpan.
+ * @param timeSpan timeSpan dont on souhaite retourner la période
+ * @return
+ *
+ private Period getPeriodWithTimeSpan(TimeSpan timeSpan) {
+ PeriodServiceImpl periodServiceImpl = new PeriodServiceImpl();
+ Date beginTimeSpan = timeSpan.getBeginTimeSpan();
+ Period period = periodServiceImpl.searchPeriodWithDate(beginTimeSpan);
+ return period;
+ }*/
+
+ /*
+ * Cette méthode renvoie vrai lorsque tous les timespans de la période
+ * précédent au timespan en paramètre sont bloqués.
+ * @param timespan
+ * @param period le paramètre period est important, en effet un timespan ne
+ * peut être indépendant.
+ * @return
+ *
+ private boolean alltimeSpanBlocked(TimeSpan timespan, Period period) {
+ boolean AllTimeSpanBlock = false;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Recherche des TimeSpans avec la même période.
+ // (on doit récupérer normalement 12 timeSpans)
+ List<TimeSpan> listeTimeSpanOfPeriod = timeSpanDAO
+ .findAllByPeriod(period);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ // On contrôle que les timeSpans précédents sont bloqués.
+ AllTimeSpanBlock = true;
+ for (TimeSpan timeSpanPrev : listeTimeSpanOfPeriod) {
+ // Si la période est avant celle qu'on souhaite bloquer ET est non bloquée
+ if (timeSpanPrev.getBeginTimeSpan().compareTo(
+ timespan.getBeginTimeSpan()) == -1
+ && !timeSpanPrev.getLocked()) {
+ AllTimeSpanBlock = false;
+ if (log.isInfoEnabled()) {
+ log.info("Timespan " + timeSpanPrev.toString()
+ + " non bloqué");
+ }
+ }
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return AllTimeSpanBlock;
+ }*/
+
+ /*
+ * Permet d'effacer un timeSpan. Ce dernier ne doit pas être bloqué.
+ * @param timeSpan
+ * @return
+ *
+ public String removeTimeSpan(TimeSpan timeSpan) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Si le timspan est bloqué
+ if (timeSpan.getLocked()) {
+ if (log.isWarnEnabled()) {
+ log.warn("Timespan bloqué !");
+ }
+ } else {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Mise à jour de timespan dans la BDD
+ timeSpanDAO.delete(timeSpan);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Timespan supprimé avec succès");
+ }
+ result = ServiceHelper.RESPOND_SUCCESS;
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Vérifie si le timeSpan donné en paramètre est bloqué ou non.
+ * @param timeSpan
+ * @return
+ *
+ public boolean isTimeSpanBlocked(TimeSpan timeSpan) {
+ boolean isTimeSpanBlocked = true;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Mise à jour de timespan dans la BDD
+ TimeSpan timeSpanSearch = timeSpanDAO.findByTopiaId(timeSpan
+ .getTopiaId());
+ isTimeSpanBlocked = timeSpanSearch.getLocked();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return isTimeSpanBlocked;
+ }*/
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java (from rev 2802, trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -0,0 +1,746 @@
+/*
+ * *##% Callao TransactionServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.dto.EntryDTO;
+import org.chorem.lima.business.dto.LogDTO;
+import org.chorem.lima.business.dto.TransactionDTO;
+import org.chorem.lima.business.utils.ServiceHelper;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.Journal;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.entity.TimeSpan;
+import org.chorem.lima.entity.Transaction;
+import org.chorem.lima.entity.TransactionDAO;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Cette classe permet la création d'une transaction comptable dans l'application.
+ * Toute action sur une transaction entraîne automatiquement une création de log.
+ * Une transaction est composée d'entrées comptables.
+ * Les actions sur les transactions sont soumises au statut de celle-ci, si elle
+ * est dans une période bloquée ou non.
+ *
+ * @author Rémi Chapelet
+ */
+public class TransactionServiceImpl {
+
+ private static final Log log = LogFactory
+ .getLog(TransactionServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ private LogServiceImpl logServiceImpl = new LogServiceImpl();
+
+ private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
+
+ private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
+
+ public TransactionServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Permet de créer une transaction comptable. Pour ajouter une transaction,
+ * le timeSpan doit être non bloqué.
+ * @param entryDate
+ * @param voucherRef
+ * @param description
+ * @param timespan
+ * @param journal
+ * @return
+ */
+ public void createTransaction(Transaction transaction /*Date entryDate, String voucherRef,
+ String description, TimeSpan timeSpan, Journal journal*/) {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ String isCorrectTransaction = isCorrectTransaction(timeSpan,
+ journal);
+ if (isCorrectTransaction.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Creation de la transaction
+ Transaction newtransaction = transactionDAO.create();
+ newtransaction.setTransDate(entryDate);
+ newtransaction.setVoucherRef(voucherRef);
+ newtransaction.setDescription(description);
+ newtransaction.setTimeSpan(timeSpan);
+ newtransaction.setJournal(journal);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Ajout avec succes de la transaction");
+ }
+
+ // Il renvoie soit l'identifiant topiaId ou SUCCESS.
+ result = newtransaction.getTopiaId();
+ //result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ result = isCorrectTransaction;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;*/
+ }
+
+ /*
+ * Permet de créer une transaction à partir d'une transaction DTO.
+ * ATTENTION : si le journal ou timespan n'existe pas, l'ajout ne peut se
+ * faire. Si on souhaite, on peut créer le journal automatiquement lors de
+ * l'ajout de la transaction si il n'existe pas. Pour le timeSpan, il n'est
+ * pas cohérent qu'il n'existe pas. On ne peut travailler que sur une période
+ * comptable existante, et par conséquent il ne faut pas le créer.
+ * @param transactionDTO
+ * @return
+ *
+ public String createTransaction(TransactionDTO transactionDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Vérifie que transactionDTO possède un journalDTO et un timeSpanDTO
+ if (transactionDTO.getJournalDTO() == null
+ || transactionDTO.getTimeSpanDTO() == null) {
+ if (log.isErrorEnabled()) {
+ log.error("L'objet transactionDTO ne possède pas de timeSpan ET/OU de journal.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ } else {
+ // Recherche du journal
+ JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
+ Journal journal = journalServiceImpl
+ .searchJournalWithLabel(transactionDTO.getJournalDTO()
+ .getLabel());
+ // Recherche du timeSpan
+ TimeSpan timeSpan = timeSpanServiceImpl
+ .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
+ .getBeginTimeSpan());
+
+ // Vérification si timeSpan et Journal existe bien
+ if (journal == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le journal "
+ + transactionDTO.getJournalDTO().getLabel()
+ + " n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ } else {
+ if (timeSpan == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le timeSpan "
+ + transactionDTO.getTimeSpanDTO().toString()
+ + " n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
+ } else {
+ result = createTransaction(transactionDTO.getEntryDate(),
+ transactionDTO.getVoucherRef(), transactionDTO
+ .getDescription(), timeSpan, journal);
+ }
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une transaction. Cette dernière est identifiée par la
+ * clé topiaId.
+ * @param topiaId
+ * @param entryDate
+ * @param voucherRef
+ * @param description
+ * @param timespan
+ * @param journal
+ * @return
+ *
+ public String modifyTransaction(String topiaId, Date entryDate,
+ String voucherRef, String description, TimeSpan timeSpan,
+ Journal journal) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Vérification que la transaction existe bien
+ Transaction transaction = transactionDAO.findByTopiaId(topiaId);
+ if (transaction == null) {
+ if (log.isInfoEnabled()) {
+ log.info("La transaction " + voucherRef
+ + " n'existe pas. (identifiant " + topiaId + ")");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_EXIST;
+ } else {
+ // Vérification si la transaction possède de bons paramètres
+ String correct = isCorrectTransaction(timeSpan, journal);
+ // Si la transaction est correcte
+ if (correct.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Modification
+ transaction.setTransDate(entryDate);
+ transaction.setVoucherRef(voucherRef);
+ transaction.setDescription(description);
+ transaction.setTimeSpan(timeSpan);
+ transaction.setJournal(journal);
+ transaction.update();
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une transaction à partir d'une transaction DTO.
+ * Elle va rechercher le journal et le timespan correspondants.
+ * @param transactionDTO
+ * @return
+ *
+ public String modifyTransaction(TransactionDTO transactionDTO) {
+ // Recherche du journal
+ JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
+ Journal journal = journalServiceImpl
+ .searchJournalWithLabel(transactionDTO.getJournalDTO()
+ .getLabel());
+ // Recherche du timeSpan
+ TimeSpan timeSpan = timeSpanServiceImpl
+ .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
+ .getBeginTimeSpan());
+ // Appel pour la modification
+ String result = modifyTransaction(transactionDTO.getId(),
+ transactionDTO.getEntryDate(), transactionDTO.getVoucherRef(),
+ transactionDTO.getDescription(), timeSpan, journal);
+ return result;
+ }*/
+
+ /*
+ * Recherche une transaction unique avec son identifiant TopiaId.
+ * @param topiaId
+ * @return
+ *
+ public Transaction searchTransactionWithTopiaId(String topiaId) {
+ Transaction transaction = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ transaction = transactionDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return transaction;
+ }*/
+
+ /*
+ * Recherche une transaction unique à partir d'une transaction DTO.
+ * @param transactionDTO
+ * @return
+ *
+ public Transaction searchTransactionWithTopiaId(
+ TransactionDTO transactionDTO) {
+ Transaction transaction = searchTransactionWithTopiaId(transactionDTO
+ .getId());
+ return transaction;
+ }*/
+
+ /*
+ * Recherche une transaction dans la base de données, et renvoie celle-ci
+ * sous format DTO. Nous ne pouvons pas appeler la méthode searchTransactionWithTopiaId
+ * du fait que lors de la convertion, nous avons besoin du journal et du
+ * timeSpan. Or il ne faut donc pas de fermeture de connexion à la base de
+ * données pour celà.
+ * @param topiaId
+ * @return
+ *
+ public TransactionDTO searchTransactionDTO(String topiaId) {
+ TransactionDTO transactionDTO = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ Transaction transaction = transactionDAO.findByTopiaId(topiaId);
+ // Converti la transaction en DTO
+ convertTransaction.setTransaction(rootContext);
+ transactionDTO = convertTransaction
+ .transactionEntityToDto(transaction);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return transactionDTO;
+ }*/
+
+ /*
+ * Recherche toutes les transactions qui correspondent à un timespan.
+ * @param timeSpan
+ * @return
+ *
+ public List<Transaction> searchListTransactionWithTimeSpan(TimeSpan timeSpan) {
+ List<Transaction> listTransaction = null;
+ if (timeSpan != null) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ listTransaction = transactionDAO.findAllByTimeSpan(timeSpan);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return listTransaction;
+ }*/
+
+ /*
+ * Recherche les transactions DTO d'un timeSpan
+ * @param timeSpan
+ * @return
+ *
+ public List<TransactionDTO> searchListTransactionDTOWithTimeSpan(
+ TimeSpan timeSpan) {
+ List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
+ if (timeSpan != null) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ List<Transaction> listTransaction = transactionDAO
+ .findAllByTimeSpan(timeSpan);
+ // Converti la transaction en DTO
+ convertTransaction.setTransaction(rootContext);
+ for (Transaction transaction : listTransaction) {
+ TransactionDTO transactionDTO = convertTransaction
+ .transactionEntityToDto(transaction);
+ listTransactionDTO.add(transactionDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return listTransactionDTO;
+ }*/
+
+ /*
+ * Recherche toutes les transactions appartenant à un même journal donné
+ * en paramètre.
+ * @param journal
+ * @return
+ *
+ public List<Transaction> searchListTransactionWithJournal(Journal journal) {
+ List<Transaction> listTransaction = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ listTransaction = transactionDAO.findAllByJournal(journal);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listTransaction;
+ }*/
+
+ /*
+ * Permet de rechercher toutes les transactions dans la base de données,
+ * avec en retour une liste de transactions au format DTO.
+ * @return
+ *
+ public List<TransactionDTO> getAllTransactionDTO() {
+ List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ List<Transaction> listTransaction = transactionDAO.findAll();
+ // Converti la transaction en DTO
+ convertTransaction.setTransaction(rootContext);
+ for (Transaction transaction : listTransaction) {
+ TransactionDTO transactionDTO = convertTransaction
+ .transactionEntityToDto(transaction);
+ listTransactionDTO.add(transactionDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listTransactionDTO;
+ }*/
+
+ /*
+ * Cette méthode permet de vérifier si une transaction possède des paramètres
+ * corrects.
+ * Un journal doit exister.
+ * Un timeSpan doit exister et être non bloqué.
+ * @param timeSpan
+ * @param journal
+ * @return
+ *
+ public String isCorrectTransaction(TimeSpan timeSpan, Journal journal) {
+ String result = ServiceHelper.RESPOND_SUCCESS;
+ // Vérification si timeSpan et Journal existe bien
+ if (journal == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le journal n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ }
+ if (timeSpan == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le timeSpan n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
+ } else {
+ // Vérifie si le timeSpan est bloqué
+ if (timeSpan.getLocked()) {
+ if (log.isErrorEnabled()) {
+ log.error("Le timeSpan est bloqué ! Il est donc impossible"
+ + " d'ajouter une transaction sur cette période. ("
+ + "Période du " + timeSpan + ")");
+ }
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'effacer une transaction dans la base de données.
+ * ATTENTION : Elle supprime également toutes les entées comptables
+ * associées. Une transaction appartenant à un timeSpan bloqué ne peut être
+ * supprimée.
+ * @return
+ *
+ public String removeTransaction(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche de l'entry
+ Transaction transaction = transactionDAO.findByTopiaId(topiaId);
+ // Transaction doit exister
+ if (transaction != null) {
+ // Vérifie si la transaction est non bloquée.
+ if (!isTransactionBlocked(transaction)) {
+ // Supprime tous les entrys de la transactions
+ List<Entry> listEntry = entryServiceImpl
+ .searchEntryWithTransaction(transaction);
+ for (Entry entry : listEntry) {
+ result = removeEntry(entry.getTopiaId());
+ }
+ // Supprime la transaction
+ transactionDAO.delete(transaction);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("La transaction a été supprimée avec succès.");
+ }
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ // Transaction bloquée
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ } else {
+ result = ServiceHelper.TRANSACTION_NOT_EXIST;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Supprime une transaction au format DTO.
+ * @param transactionDTO
+ * @return
+ *
+ public String removeTransaction(TransactionDTO transactionDTO) {
+ String result = removeTransaction(transactionDTO.getId());
+ return result;
+ }*/
+
+ /*
+ * Permet d'ajouter une entrée comptable pour une transaction donnée.
+ * ATTENTION : la transaction doit être NON bloquée.
+ *
+ * @param description
+ * @param amount
+ * @param debit
+ * @param lettering
+ * @param detail
+ * @param transaction
+ * @return
+ *
+ public String addEntry(String description, String amount, boolean debit,
+ String lettering, String detail, Transaction transaction,
+ Account account) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Si la transaction est non bloquée
+ if (!isTransactionBlocked(transaction)) {
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+ result = entryServiceImpl.createEntry(description, amount, debit,
+ lettering, detail, transaction, account);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'ajouter une entrée comptable pour une transaction donnée.
+ * L'entrée est sous format DTO.
+ *
+ * @param entryDTO
+ * @return
+ *
+ public String addEntry(EntryDTO entryDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Recherche TransactionDTO
+ TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
+ Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
+ // Si la transaction est non bloquée
+ if (!isTransactionBlocked(transaction)) {
+
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+ result = entryServiceImpl.createEntry(entryDTO);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une entrée comptable.
+ * ATTENTION : la transaction doit être NON bloquée.
+ *
+ * @param topiaId
+ * @param description
+ * @param amount
+ * @param debit
+ * @param lettering
+ * @param detail
+ * @param transaction
+ * @param account
+ * @return
+ *
+ public String modifyEntry(String topiaId, String description,
+ String amount, boolean debit, String lettering, String detail,
+ Transaction transaction, Account account) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ if (!isTransactionBlocked(transaction)) {
+ result = entryServiceImpl.modifyEntry(topiaId, description, amount,
+ debit, lettering, detail, account);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une entrée.
+ * @param entryDTO
+ * @return
+ *
+ public String modifyEntry(EntryDTO entryDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Recherche TransactionDTO
+ TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
+ Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
+ if (!isTransactionBlocked(transaction)) {
+ result = entryServiceImpl.modifyEntry(entryDTO);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'effacer une entrée comptable. Elle est identifiée par son identifiant
+ * topiaID. Une entrée peut être supprimée seulement si elle est non bloquée.
+ * @param topiaId
+ * @return
+ *
+ public String removeEntry(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ // Recherche de l'entry
+ Entry entryDelete = entryDAO.findByTopiaId(topiaId);
+ // Entry doit exister
+ if (entryDelete != null) {
+ // Prend la transaction dont appartient entry
+ Transaction transaction = entryDelete.getTransaction();
+ // Vérifie si la transaction est non bloquée.
+ if (!isTransactionBlocked(transaction)) {
+ // Création d'un log DTO
+ LogDTO logDTO = new LogDTO("", new Date(),
+ ServiceHelper.LOG_REMOVE, transaction
+ .getTransDate(), transaction
+ .getVoucherRef(), transaction
+ .getDescription(), entryDelete
+ .getDescription(), entryDelete.getAmount(),
+ entryDelete.getDebit(), entryDelete.getLettering());
+ // Appel pour supprimer l'entrée
+ result = entryServiceImpl.removeEntry(topiaId);
+ // Si la suppression s'est bien déroulée, création log
+ if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Ajout du log
+ logServiceImpl.addLog(logDTO);
+ }
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ } else {
+ result = ServiceHelper.ENTRY_NOT_EXIST;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de supprimer une entrée à partir d'un DTO.
+ * @param entryDTO
+ * @return
+ *
+ public String removeEntry(EntryDTO entryDTO) {
+ String result = removeEntry(entryDTO.getId());
+ return result;
+ }*/
+
+ /*
+ * Permet de vérifier si une transaction est dans une période bloquée ou non
+ * @param transaction
+ * @return
+ *
+ public boolean isTransactionBlocked(Transaction transaction) {
+ boolean isTransactionBlocked = true;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ Transaction transactionSearch = transactionDAO
+ .findByTopiaId(transaction.getTopiaId());
+ isTransactionBlocked = timeSpanServiceImpl
+ .isTimeSpanBlocked(transactionSearch.getTimeSpan());
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return isTransactionBlocked;
+ }*/
+
+ /*
+ * Permet de vérifier si une transaction est équilibrée.
+ * @param transaction
+ * @return
+ *
+ public boolean isTransactionBalanced(Transaction transaction) {
+ List<EntryDTO> ListEntryDTO = entryServiceImpl
+ .searchEntryDTOWithTransaction(transaction);
+ float debit = 0;
+ float credit = 0;
+ // Pour toutes les entrées comptables trouvées
+ for (EntryDTO entryDTO : ListEntryDTO) {
+ // Si entrée au debit
+ if (entryDTO.isDebit()) {
+ debit = debit
+ + Float.parseFloat(entryDTO.getAmount().replaceFirst(
+ ",", "."));
+ } else {
+ credit = credit
+ + Float.parseFloat(entryDTO.getAmount().replaceFirst(
+ ",", "."));
+ }
+ }
+ // Vérifie si le debit == credit
+ boolean isTransactionBalanced = debit == credit;
+ return isTransactionBalanced;
+ }*/
+
+}
\ No newline at end of file
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java (from rev 2802, trunk/lima-business/src/main/java/org/chorem/lima/business/UserServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java 2010-03-23 15:26:54 UTC (rev 2811)
@@ -0,0 +1,118 @@
+/*
+ * *##% Callao
+ * Copyright (C) 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.entity.User;
+import org.chorem.lima.entity.UserDAO;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * User service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class UserServiceImpl {
+
+ /** log */
+ private static final Log log = LogFactory.getLog(UserServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ public UserServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Add new user.
+ *
+ * @param name new user name
+ * @throws LimaException
+ */
+ public void addUser(User user/*String name*/) throws LimaException {
+ /*// Attention doublon utilisateur
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ UsersDAO userdao = LimaCallaoDAOHelper.getUsersDAO(topiaContext);
+ // Création de l'user
+ Users newuser = userdao.create();
+ newuser.setMatcher(name);
+ // Création BDD
+ topiaContext.commitTransaction();
+ topiaContext.closeContext();
+ if (log.isInfoEnabled()) {
+ log.info("Add user : " + name);
+ }
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't create user", ex);
+ throw new LimaException("Can't create user", ex);
+ }
+
+ }*/
+ }
+
+ /**
+ * Find user with name.
+ *
+ * @param name
+ * @throws LimaException
+ */
+ public void findUser(String name) throws LimaException {
+ /*try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ UsersDAO userdao = LimaCallaoDAOHelper.getUsersDAO(topiaContext);
+ // Recherche du user
+ Users newuser = userdao.findByMatcher(name);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ if (newuser == null) {
+ throw new LimaBusinessException("can't find user " + name);
+ }
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't find user", ex);
+ throw new LimaException("Can't find user", ex);
+ }
+ }*/
+ }
+}
1
0
23 Mar '10
Author: echatellier
Date: 2010-03-23 14:45:06 +0100 (Tue, 23 Mar 2010)
New Revision: 2810
Log:
Ajout de quelques traductions
Modified:
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-03-23 13:19:56 UTC (rev 2809)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-03-23 13:45:06 UTC (rev 2810)
@@ -1,4 +1,7 @@
+lima.error.errorpane.title=Lima error
+lima.error.errorpane.htmlmessage=<html><body><b>An application error happened</b>:<br/>%s</body></html>
lima.about.message=
+lima.accountplan=Plan de comptes
lima.account=Account
lima.account.type=Account type
lima.actif=Asset
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-03-23 13:19:56 UTC (rev 2809)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-03-23 13:45:06 UTC (rev 2810)
@@ -1,4 +1,9 @@
+lima.error.errorpane.title=Lima erreur
+lima.error.errorpane.htmlmessage=<html><body><b>Une erreur s'est produite</b>:<br/>%s</body></html>
lima.about.message=
+lima.account.number=Num�ro du compte
+lima.accountplan=Plan de comptes
+lima.account.label=Libell�
lima.account=Compte
lima.account.type=Type de compte
lima.actif=Actif
1
0
Author: echatellier
Date: 2010-03-23 14:19:56 +0100 (Tue, 23 Mar 2010)
New Revision: 2809
Log:
Use topia snapshot
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-22 08:48:18 UTC (rev 2808)
+++ trunk/pom.xml 2010-03-23 13:19:56 UTC (rev 2809)
@@ -241,7 +241,7 @@
<!-- customized libs version -->
<nuiton-utils.version>1.2.1-SNAPSHOT</nuiton-utils.version>
<eugene.version>2.0</eugene.version>
- <topia.version>2.3</topia.version>
+ <topia.version>2.3.1-SNAPSHOT</topia.version>
<jaxx.version>2.0</jaxx.version>
<i18n.version>1.1</i18n.version>
1
0
Author: echatellier
Date: 2010-03-22 09:48:18 +0100 (Mon, 22 Mar 2010)
New Revision: 2808
Log:
Update h2
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-19 17:17:04 UTC (rev 2807)
+++ trunk/pom.xml 2010-03-22 08:48:18 UTC (rev 2808)
@@ -104,7 +104,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
- <version>1.2.131</version>
+ <version>1.2.132</version>
<scope>runtime</scope>
</dependency>
1
0
r2807 - in trunk: . lima-business lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/data lima-business/src/main/resources lima-business/src/main/resources/META-INF
by echatellier@users.chorem.org 19 Mar '10
by echatellier@users.chorem.org 19 Mar '10
19 Mar '10
Author: echatellier
Date: 2010-03-19 18:17:04 +0100 (Fri, 19 Mar 2010)
New Revision: 2807
Log:
Instanciation des services avec openejb (embedded mode)
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/data/Status.java
trunk/lima-business/src/main/resources/META-INF/
trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml
Modified:
trunk/lima-business/pom.xml
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java
trunk/lima-business/src/main/resources/log4j.properties
trunk/pom.xml
Modified: trunk/lima-business/pom.xml
===================================================================
--- trunk/lima-business/pom.xml 2010-03-16 16:51:18 UTC (rev 2806)
+++ trunk/lima-business/pom.xml 2010-03-19 17:17:04 UTC (rev 2807)
@@ -36,6 +36,10 @@
<groupId>javax.time</groupId>
<artifactId>jsr-310-ri</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ </dependency>
</dependencies>
<!-- ************************************************************* -->
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-03-19 17:17:04 UTC (rev 2807)
@@ -0,0 +1,35 @@
+/* *##%
+ * Copyright (C) 2010 Code Lutin, 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.Account;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface AccountService {
+
+ public void createAccount(Account account) throws LimaException;
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java 2010-03-16 16:51:18 UTC (rev 2806)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java 2010-03-19 17:17:04 UTC (rev 2807)
@@ -20,9 +20,12 @@
package org.chorem.lima.business;
import static org.nuiton.i18n.I18n._;
+
import java.util.ArrayList;
import java.util.List;
+import javax.ejb.Stateless;
+
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -45,7 +48,8 @@
*
* @author Rémi Chapelet
*/
-public class AccountServiceImpl {
+@Stateless
+public class AccountServiceImpl implements AccountService {
private static final Log log = LogFactory.getLog(AccountServiceImpl.class);
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/data/Status.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/data/Status.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/data/Status.java 2010-03-19 17:17:04 UTC (rev 2807)
@@ -0,0 +1,96 @@
+/* *##%
+ Copyright (C) 2009-2010 Lima Callao
+ *##%*/
+package org.chorem.lima.business.data;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * DTO implantation for Status entity.
+ */
+public class Status implements java.io.Serializable {
+
+ private java.lang.String idName;
+ private java.lang.String idType;
+ private java.lang.String description;
+
+ protected java.beans.PropertyChangeSupport p;
+
+ /**
+ * Default constructor of StatusDTO.
+ */
+ public Status() {
+ p = new java.beans.PropertyChangeSupport(this);
+ }
+
+ /**
+ * Constructor of StatusDTO with all parameters.
+ */
+ public Status(java.lang.String idName, java.lang.String idType, java.lang.String description ) {
+ this();
+ this.idName = idName;
+ this.idType = idType;
+ this.description = description;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ p.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ p.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public void setIdName(java.lang.String value) {
+ java.lang.String oldValue = this.idName;
+ this.idName = value;
+ p.firePropertyChange("idName", oldValue, value);
+ }
+
+ public java.lang.String getIdName() {
+ return idName;
+ }
+
+ public void setIdType(java.lang.String value) {
+ java.lang.String oldValue = this.idType;
+ this.idType = value;
+ p.firePropertyChange("idType", oldValue, value);
+ }
+
+ public java.lang.String getIdType() {
+ return idType;
+ }
+
+ public void setDescription(java.lang.String value) {
+ java.lang.String oldValue = this.description;
+ this.description = value;
+ p.firePropertyChange("description", oldValue, value);
+ }
+
+ public java.lang.String getDescription() {
+ return description;
+ }
+
+
+ @Override
+ public String toString() {
+ String result = new ToStringBuilder(this).
+ append("idName", this.idName).
+ append("idType", this.idType).
+ append("description", this.description).
+ toString();
+ return result;
+ }
+
+} //StatusDTO
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/data/Status.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml
===================================================================
--- trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml (rev 0)
+++ trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml 2010-03-19 17:17:04 UTC (rev 2807)
@@ -0,0 +1,3 @@
+<!-- Empty configuration file based on
+ http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html -->
+<ejb-jar/>
Modified: trunk/lima-business/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-business/src/main/resources/log4j.properties 2010-03-16 16:51:18 UTC (rev 2806)
+++ trunk/lima-business/src/main/resources/log4j.properties 2010-03-19 17:17:04 UTC (rev 2807)
@@ -8,3 +8,4 @@
# package level
log4j.logger.org.chorem.lima=DEBUG
+log4j.logger.org.nuiton.util=DEBUG
\ No newline at end of file
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-16 16:51:18 UTC (rev 2806)
+++ trunk/pom.xml 2010-03-19 17:17:04 UTC (rev 2807)
@@ -61,6 +61,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-email</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
<version>${nuiton-utils.version}</version>
@@ -114,6 +120,15 @@
<version>${axis.version}</version>
</dependency>-->
+ <!-- Services -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <!-- 3.2.1 has a startup warning with 1.6.0_u18 -->
+ <version>3.1.3-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
<!-- autres libraires -->
<dependency>
<groupId>org.swinglabs</groupId>
@@ -224,7 +239,7 @@
<projectId>lima</projectId>
<!-- customized libs version -->
- <nuiton-utils.version>1.2</nuiton-utils.version>
+ <nuiton-utils.version>1.2.1-SNAPSHOT</nuiton-utils.version>
<eugene.version>2.0</eugene.version>
<topia.version>2.3</topia.version>
<jaxx.version>2.0</jaxx.version>
@@ -321,6 +336,10 @@
<id>jboss.repo</id>
<url>http://repository.jboss.org/maven2</url>
</repository>
+ <repository>
+ <id>apache.snapshot</id>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
</repositories>
<pluginRepositories>
1
0
Author: echatellier
Date: 2010-03-16 17:51:18 +0100 (Tue, 16 Mar 2010)
New Revision: 2806
Log:
Update junit
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-16 15:53:11 UTC (rev 2805)
+++ trunk/pom.xml 2010-03-16 16:51:18 UTC (rev 2806)
@@ -153,7 +153,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.7</version>
+ <version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
1
0
r2805 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/test/java/org/chorem/lima/business lima-swing/src/main/java/org/chorem/lima/util
by echatellier@users.chorem.org 16 Mar '10
by echatellier@users.chorem.org 16 Mar '10
16 Mar '10
Author: echatellier
Date: 2010-03-16 16:53:11 +0100 (Tue, 16 Mar 2010)
New Revision: 2805
Log:
Add missing files during last refactoring
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaException.java
trunk/lima-business/src/test/java/org/chorem/lima/business/LimaConfigTest.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/ServiceHelper.java
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-03-16 15:53:11 UTC (rev 2805)
@@ -0,0 +1,60 @@
+/* *##%
+ * Copyright (C) 2010 Code Lutin, 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.util.ArgumentsParserException;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class LimaConfig extends ApplicationConfig {
+
+ private static final Log log = LogFactory.getLog(LimaConfig.class);
+
+ protected static LimaConfig instance;
+
+ protected LimaConfig() {
+
+ }
+
+ public static LimaConfig getInstance() {
+ if (instance == null) {
+ instance = new LimaConfig();
+ instance.setConfigFileName("lima.properties");
+ try {
+ instance.parse(new String[0]);
+ } catch (ArgumentsParserException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't read configuration", ex);
+ }
+ }
+ }
+
+ return instance;
+ }
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaException.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaException.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaException.java 2010-03-16 15:53:11 UTC (rev 2805)
@@ -0,0 +1,53 @@
+/* *##% Lima
+ * Copyright (C) 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+/**
+ * Lima exception.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class LimaException extends Exception {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -6876236663940184462L;
+
+ /**
+ * Constructs a new exception with the specified detail message.
+ *
+ * @param message message
+ */
+ public LimaException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a new exception with the specified detail message and cause.
+ *
+ * @param message message
+ * @param cause cause
+ */
+ public LimaException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/LimaConfigTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/LimaConfigTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/LimaConfigTest.java 2010-03-16 15:53:11 UTC (rev 2805)
@@ -0,0 +1,55 @@
+/* *##%
+ * Copyright (C) 2010 Code Lutin, 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.nuiton.util.ArgumentsParserException;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+@Ignore
+public class LimaConfigTest extends LimaConfig {
+
+ private static final Log log = LogFactory.getLog(LimaConfig.class);
+
+ public static LimaConfig getInstance() {
+ if (instance == null) {
+ instance = new LimaConfig();
+ instance.setConfigFileName("lima_test.properties");
+ try {
+ instance.parse(new String[0]);
+ } catch (ArgumentsParserException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't read configuration", ex);
+ }
+ }
+ }
+
+ return instance;
+ }
+}
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/LimaConfigTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/util/ServiceHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/ServiceHelper.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ServiceHelper.java 2010-03-16 15:53:11 UTC (rev 2805)
@@ -0,0 +1,354 @@
+/**
+ * *##% Lima service
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.nuiton.i18n.I18n._;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author chemit
+ * @author Rémi Chapelet
+ */
+public class ServiceHelper {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(ServiceHelper.class);
+ /**
+ * Transaction status type
+ */
+ public static final String TR_FINALIZED = "TR_FINALIZED";
+ public static final String TR_BALANCED = "TR_BALANCED";
+ public static final String TR_WIP = "TR_WIP";
+ /**
+ * Period status type
+ */
+ public static final String PE_OPEN = "PE_OPEN";
+ public static final String PE_CLOSETMP = "PE_CLOSETMP";
+ public static final String PE_CLOSE = "PE_CLOSE";
+ /**
+ * Responses
+ */
+ public static final String RESPOND_SUCCESS = "success";
+ public static final String RESPOND_ERROR = "error";
+
+ /**
+ * Account Error
+ */
+ public static final String ACCOUNT_DOUBLE = "account_double";
+ public static final String ACCOUNT_NOT_MASTER = "account_not_master";
+ public static final String ACCOUNT_NOT_EXIST = "account_not_exist";
+ public static final String ACCOUNT_WITH_ENTRIES = "account_with_entries";
+
+ /**
+ * Entries Error
+ */
+ public static final String ENTRY_NOT_EXIST = "entry_not_exist";
+
+ /**
+ * Journal
+ */
+ public static final String JOURNAL_DOUBLE = "journal_double";
+ public static final String JOURNAL_NOT_EXIST = "journal_not_exist";
+ public static final String JOURNAL_WITH_TRANSACTIONS = "journal_with_transactions";
+
+ /**
+ * Period
+ */
+ public static final String PERIOD_CREATE_TIMESPANS = "period_create_timespan";
+ public static final String PERIOD_TIMESPAN_NOT_BLOCK = "period_timespan_not_block";
+ public static final String PERIOD_TIMESPAN_BLOCK = "period_timespan_block";
+ public static final String PERIOD_ALL_TIMESPAN = "period_all_timespan";
+ public static final String PERIOD_NOT_EXIST = "period_not_exist";
+
+ public static final String PERIOD_PREC_NOT_BLOCK = "period_prec_not_block";
+ public static final String PERIOD_NEXT_NOT_BLOCK = "period_next_not_block";
+
+ /**
+ * Transaction
+ */
+ public static final String TRANSACTION_NOT_JOURNAL = "transaction_not_journal";
+ public static final String TRANSACTION_NOT_TIMESPAN = "transaction_not_timespan";
+ public static final String TRANSACTION_TIMESPAN_BLOCKED = "transaction_timespan_blocked";
+ public static final String TRANSACTION_NOT_EXIST = "transaction_not_exist";
+ public static final String TRANSACTION_NOT_BALANCED = "transaction_not_balanced";
+
+ protected ServiceHelper() {
+ // no instance
+ }
+
+ /**
+ * TODO
+ *
+ * @param accounts TODO
+ * @return TODO
+ */
+ public static List<Account> getAllFlatAccount(Account accounts) {
+ List<Account> flatList = new LinkedList<Account>();
+ concatListAccount(flatList, accounts.getChildren());
+ return flatList;
+ }
+
+ /**
+ * TODO
+ *
+ * @param res TODO
+ * @param add TODO
+ */
+ private static void concatListAccount(List<Account> res, List<Account> add) {
+ res.addAll(add);
+ for (Account acc : add) {
+ if (acc.getChildren() != null) {
+ concatListAccount(res, acc.getChildren());
+ }
+ }
+ }
+
+ /**
+ * TODO
+ *
+ * @param periods TODO
+ * @return TODO
+ */
+ public static List<PeriodDTO> getAllFlatPeriod(List<PeriodDTO> periods) {
+ List<PeriodDTO> flatList = new LinkedList<PeriodDTO>();
+ for (PeriodDTO period : periods) {
+ flatList.add(period);
+ flatList.addAll(period.getChildren());
+ }
+ return flatList;
+ }
+
+ /**
+ * @param date
+ * @return
+ */
+ public static String dateToMonth(Date date) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ switch (cal.get(Calendar.MONTH)) {
+ case Calendar.JANUARY:
+ return _("lima.date.january");
+ case Calendar.FEBRUARY:
+ return _("lima.date.february");
+ case Calendar.MARCH:
+ return _("lima.date.march");
+ case Calendar.APRIL:
+ return _("lima.date.april");
+ case Calendar.MAY:
+ return _("lima.date.may");
+ case Calendar.JUNE:
+ return _("lima.date.june");
+ case Calendar.JULY:
+ return _("lima.date.july");
+ case Calendar.AUGUST:
+ return _("lima.date.august");
+ case Calendar.SEPTEMBER:
+ return _("lima.date.september");
+ case Calendar.OCTOBER:
+ return _("lima.date.october");
+ case Calendar.NOVEMBER:
+ return _("lima.date.november");
+ case Calendar.DECEMBER:
+ return _("lima.date.december");
+ }
+ return null;
+ }
+ /**
+ * @param date the date to inspect
+ * @return the year of the given date
+ */
+ public static String dateToYear(Date date) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ return "" + cal.get(Calendar.YEAR);
+ }
+
+ /**
+ * @param trans
+ * @return
+ */
+ public static boolean isEditable(TransactionDTO trans) {
+ String finalizedKey = ServiceHelper.PE_CLOSE;
+ return !trans.getPeriod().getStatus().getIdType().equals(finalizedKey);
+ }
+
+ /**
+ * @param entry
+ * @return
+ */
+ public static boolean isEditable(EntryDTO entry) {
+ return isEditable(entry.getTransaction());
+ }
+
+ public static StatusDTO findStatusByType(List<StatusDTO> list, String id) {
+ if (id == null || list == null) {
+ return null;
+ }
+ for (StatusDTO status : list) {
+ if (id.equals(status.getIdType())) {
+ return status;
+ }
+ }
+ log.warn("Status " + id + " couldn't be found.");
+ return null;
+ }
+
+ public static JournalDTO findJournalById(List<JournalDTO> list, String id) {
+ if (id == null || list == null) {
+ return null;
+ }
+ for (JournalDTO journal : list) {
+ if (id.equalsIgnoreCase(journal.getIdName()) || id.equalsIgnoreCase(journal.getPrefix()) || id.equals(journal.getIdSeq())) {
+ return journal;
+ }
+ }
+ log.warn("Journal " + id + " couldn't be found.");
+ return null;
+ }
+
+ public static StatusDTO findStatusById(List<StatusDTO> list, String id) {
+ if (id == null || list == null) {
+ return null;
+ }
+ for (StatusDTO Status : list) {
+ if (id.equals(Status.getIdName())) {
+ return Status;
+ }
+ }
+ log.warn("Status " + id + " couldn't be found.");
+ return null;
+ }
+
+ public static AccountDTO findAccountById(List<AccountDTO> list, String id) {
+ if (id == null || list == null) {
+ return null;
+ }
+ for (AccountDTO account : list) {
+ if (id.equals(account.getIdNumber())) {
+ return account;
+ }
+ }
+ log.warn("Account " + id + " couldn't be found.");
+ return null;
+ }
+
+ public static PeriodDTO findPeriodById(List<PeriodDTO> list, String id) {
+ if (id == null || list == null) {
+ return null;
+ }
+ for (PeriodDTO period : list) {
+ if (id.equals(period.getIdSeq())) {
+ return period;
+ }
+ }
+ log.warn("Period " + id + " couldn't be found.");
+ return null;
+ }
+
+ public static PeriodDTO findPeriodByDate(List<PeriodDTO> list, Date d) {
+ if (d == null || list == null) {
+ return null;
+ }
+ PeriodDTO periodSearch = null;
+ for (PeriodDTO period : list) {
+ if ( betweenDate(d,period.getBegin(),period.getEnd()) ) {
+ periodSearch = period;
+ }
+ }
+ if ( periodSearch == null)
+ {
+ log.warn("Period with this date " + d + " couldn't be found.");
+ }
+ return periodSearch;
+ }
+
+ /**
+ * Permet de rechercher toutes les transactions appartenant à une période
+ * donnée.
+ * @param period
+ * @param listTransactions
+ * @return
+ */
+ public static List<TransactionDTO> findTransactionByPeriod(PeriodDTO period,List<TransactionDTO> listTransactions)
+ {
+ if (period == null || listTransactions == null) {
+ return null;
+ }
+ List<TransactionDTO> ListTransactionSearch = new LinkedList<TransactionDTO>();
+ // Si période annuelle
+ if ( period.getParent() == null )
+ {
+ for (TransactionDTO transaction : listTransactions)
+ {
+ if ( transaction.getPeriod().getParent().equals(period) )
+ {
+ ListTransactionSearch.add(transaction);
+ }
+ }
+ } else {
+ // Si période mensuelle
+ for (TransactionDTO transaction : listTransactions)
+ {
+ if ( transaction.getPeriod().equals(period) )
+ {
+ ListTransactionSearch.add(transaction);
+ }
+ }
+ }
+ return ListTransactionSearch;
+ }
+
+ /**
+ * Permet de renvoyer vrai si une date d donnée est entre deux dates.
+ * @param d date se trouvant ou non dans la période
+ * @param dateBegin date de début de période
+ * @param dateEnd date de fin de période
+ * @return
+ */
+ public static boolean betweenDate (Date d, Date dateBegin, Date dateEnd)
+ {
+ boolean result = false;
+ if ( ( (compareDate(d,dateBegin) == 0) || (compareDate(d,dateBegin) == 1) )
+ && ( (compareDate(d,dateEnd) == 0) || (compareDate(d,dateEnd) == -1) ) )
+ {
+ result = true;
+ }
+ return result;
+ }
+
+ /**
+ * Implémentation de compareTO. Si il y a besoin, il est possible de la modifier.
+ * @param d1
+ * @param d2
+ * @return
+ */
+ public static int compareDate(Date d1, Date d2)
+ {
+ return d1.compareTo(d2);
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/util/ServiceHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
Author: echatellier
Date: 2010-03-16 16:52:51 +0100 (Tue, 16 Mar 2010)
New Revision: 2804
Log:
Add new archi svg image
Added:
trunk/src/site/resources/images/limaarchi.svg
Added: trunk/src/site/resources/images/limaarchi.svg
===================================================================
--- trunk/src/site/resources/images/limaarchi.svg (rev 0)
+++ trunk/src/site/resources/images/limaarchi.svg 2010-03-16 15:52:51 UTC (rev 2804)
@@ -0,0 +1,344 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="210mm"
+ height="297mm"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.47 r22583"
+ sodipodi:docname="lima.svg">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="EmptyTriangleOutL"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="EmptyTriangleOutL"
+ style="overflow:visible">
+ <path
+ id="path5414"
+ d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z "
+ style="fill-rule:evenodd;fill:#FFFFFF;stroke:#000000;stroke-width:1.0pt;marker-start:none"
+ transform="scale(0.8) translate(-6,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow2Lend"
+ style="overflow:visible;">
+ <path
+ id="path5274"
+ style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
+ transform="scale(1.1) rotate(180) translate(1,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow1Lend"
+ style="overflow:visible;">
+ <path
+ id="path5256"
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
+ transform="scale(0.8) rotate(180) translate(12.5,0)" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.76095916"
+ inkscape:cx="68.534987"
+ inkscape:cy="598.5638"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1680"
+ inkscape:window-height="975"
+ inkscape:window-x="0"
+ inkscape:window-y="25"
+ inkscape:window-maximized="1" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Calque 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff8080;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2816"
+ sodipodi:cx="125.04024"
+ sodipodi:cy="206.3107"
+ sodipodi:rx="60.08427"
+ sodipodi:ry="61.708168"
+ d="m 185.12451,206.3107 a 60.08427,61.708168 0 1 1 -120.168543,0 60.08427,61.708168 0 1 1 120.168543,0 z"
+ transform="translate(17.862891,-61.708169)" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="128.28804"
+ y="190.07172"
+ id="text2818"><tspan
+ sodipodi:role="line"
+ x="128.28804"
+ y="190.07172"
+ id="tspan2822" /></text>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1.29482162px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 51.964774,291.56542 480.674156,0"
+ id="path5042" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1.49926591px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 48.716976,479.12577 492.041454,0"
+ id="path5044" />
+ <a
+ id="a5898"
+ style="fill:#ff9955">
+ <rect
+ y="350.83774"
+ x="56.836472"
+ height="68.203766"
+ width="175.38112"
+ id="rect5046"
+ style="fill:#ff9955;fill-opacity:1" />
+ </a>
+ <rect
+ style="fill:#a088a4;fill-opacity:1"
+ id="rect5048"
+ width="289.94522"
+ height="71.451561"
+ x="53.588673"
+ y="522.97107" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1.26192796;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.26192795, 7.57156772;stroke-dashoffset:0"
+ d="m 48.847939,647.88033 496.415281,0 0,-1.36198"
+ id="path5050" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff8080;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1, 6;stroke-dashoffset:0"
+ id="path5054"
+ sodipodi:cx="300.42136"
+ sodipodi:cy="216.05411"
+ sodipodi:rx="64.955971"
+ sodipodi:ry="64.955971"
+ d="m 365.37733,216.05411 a 64.955971,64.955971 0 1 1 -129.91194,0 64.955971,64.955971 0 1 1 129.91194,0 z"
+ transform="translate(56.836472,-64.955967)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#805418;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1, 6;stroke-dashoffset:0"
+ id="path5058"
+ sodipodi:cx="96.622002"
+ sodipodi:cy="710.53143"
+ sodipodi:rx="44.657227"
+ sodipodi:ry="33.289932"
+ d="m 141.27923,710.53143 a 44.657227,33.289932 0 1 1 -89.314455,0 44.657227,33.289932 0 1 1 89.314455,0 z"
+ transform="matrix(1.8347419,0,0,0.99472886,-43.201698,3.7453105)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#805814;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1, 6;stroke-dashoffset:0"
+ id="path5060"
+ sodipodi:cx="260.63583"
+ sodipodi:cy="717.83893"
+ sodipodi:rx="51.152824"
+ sodipodi:ry="37.349682"
+ d="m 311.78866,717.83893 a 51.152824,37.349682 0 1 1 -102.30565,0 51.152824,37.349682 0 1 1 102.30565,0 z"
+ transform="matrix(1.7931142,0,0,0.99550121,-64.018183,-4.8900903)" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 219.22639,183.57612 0,0"
+ id="path5062"
+ inkscape:connector-type="polyline" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
+ d="m 143.32007,206.30924 0.97654,144.5285"
+ id="path5248"
+ inkscape:connector-type="polyline"
+ inkscape:connection-start="#path2816"
+ inkscape:connection-end="#rect5046" />
+ <text
+ xml:space="preserve"
+ style="font-size:28.13285065px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="124.3963"
+ y="242.75453"
+ id="text5886"
+ transform="scale(0.89438637,1.118085)"><tspan
+ sodipodi:role="line"
+ id="tspan5888"
+ x="124.3963"
+ y="242.75453"
+ style="font-size:18px;font-style:italic;-inkscape-font-specification:Bitstream Vera Sans Oblique">OpenEJB</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="94.665115"
+ y="151.86778"
+ id="text5890"><tspan
+ sodipodi:role="line"
+ id="tspan5892"
+ x="94.665115"
+ y="151.86778"
+ style="font-size:24px">SwingUI</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="319.22305"
+ y="157.66878"
+ id="text5894"><tspan
+ sodipodi:role="line"
+ id="tspan5896"
+ x="319.22305"
+ y="157.66878"
+ style="font-size:24px">WebUI</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="82.978508"
+ y="395.76242"
+ id="text5901"><tspan
+ sodipodi:role="line"
+ id="tspan5903"
+ x="82.978508"
+ y="395.76242">Metier</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="86.301361"
+ y="570.21423"
+ id="text5905"><tspan
+ sodipodi:role="line"
+ id="tspan5907"
+ x="86.301361"
+ y="570.21423">Persistence</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="83.513458"
+ y="724.94458"
+ id="text5909"><tspan
+ sodipodi:role="line"
+ id="tspan5911"
+ x="83.513458"
+ y="724.94458">Ofbiz</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="360.15771"
+ y="721.07721"
+ id="text5913"><tspan
+ sodipodi:role="line"
+ id="tspan5915"
+ x="360.15771"
+ y="721.07721">SAP</tspan></text>
+ <rect
+ style="fill:#9d00ff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1, 6;stroke-dashoffset:0"
+ id="rect5917"
+ width="94.18615"
+ height="25.982388"
+ x="255.57173"
+ y="289.12958" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="267.7182"
+ y="307.06754"
+ id="text5922"><tspan
+ sodipodi:role="line"
+ x="267.7182"
+ y="307.06754"
+ id="tspan5926"
+ style="font-size:20px">JBoss...</tspan></text>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;display:inline;marker-end:url(#Arrow2Lend)"
+ d="m 335.16946,212.20199 -27.80848,76.92759"
+ id="path5932"
+ inkscape:connector-type="polyline"
+ inkscape:connection-start="#path5054"
+ inkscape:connection-end="#rect5917" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
+ d="m 277.85888,315.11197 -68.21629,35.72577"
+ id="path6120"
+ inkscape:connector-type="polyline"
+ inkscape:connection-start="#rect5917"
+ inkscape:connection-end="#a5898" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.84573668px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#EmptyTriangleOutL)"
+ d="m 135.41895,677.49899 5.20106,-83.84564"
+ id="path6329"
+ inkscape:connector-type="polyline" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#EmptyTriangleOutL)"
+ d="M 359.14283,677.12923 247.00159,594.42263"
+ id="path6331"
+ inkscape:connector-type="polyline"
+ inkscape:connection-start="#path5060"
+ inkscape:connection-end="#rect5048" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.7138375px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
+ d="M 153.61024,418.80798 186.41782,523.3022"
+ id="path6899"
+ inkscape:connector-type="polyline" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="550.62091"
+ y="370.32822"
+ id="text7089"><tspan
+ sodipodi:role="line"
+ id="tspan7091"
+ x="550.62091"
+ y="370.32822"
+ style="font-size:32px;font-style:italic;-inkscape-font-specification:Bitstream Vera Sans Oblique">EJB</tspan><tspan
+ sodipodi:role="line"
+ x="550.62091"
+ y="410.32822"
+ id="tspan7093"
+ style="font-size:32px;font-style:italic;-inkscape-font-specification:Bitstream Vera Sans Oblique">DAO + JTA</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="429.72083"
+ y="574.01855"
+ id="text7095"><tspan
+ sodipodi:role="line"
+ id="tspan7097"
+ x="429.72083"
+ y="574.01855"
+ style="font-size:32px;font-style:italic;-inkscape-font-specification:Bitstream Vera Sans Oblique">Generation TOPIA</tspan></text>
+ </g>
+</svg>
1
0
Author: echatellier
Date: 2010-03-16 16:52:20 +0100 (Tue, 16 Mar 2010)
New Revision: 2803
Log:
Set all svn:ignore
Modified:
trunk/lima-business/
trunk/lima-callao/
Property changes on: trunk/lima-business
___________________________________________________________________
Added: svn:ignore
+ .classpath
.project
.settings
target
Property changes on: trunk/lima-callao
___________________________________________________________________
Added: svn:ignore
+ .settings
target
.classpath
.project
1
0
Author: echatellier
Date: 2010-03-16 16:41:26 +0100 (Tue, 16 Mar 2010)
New Revision: 2802
Log:
Begin refactoring, new modules architecture (not compilable)
Added:
trunk/lima-business/
trunk/lima-business/LICENSE.txt
trunk/lima-business/README.txt
trunk/lima-business/changelog.txt
trunk/lima-business/pom.xml
trunk/lima-business/src/
trunk/lima-business/src/main/
trunk/lima-business/src/main/java/
trunk/lima-business/src/main/java/org/
trunk/lima-business/src/main/java/org/chorem/
trunk/lima-business/src/main/java/org/chorem/lima/
trunk/lima-business/src/main/java/org/chorem/lima/business/
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/EntryServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FilesServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/JournalServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LogServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/PeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/TimeSpanServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/UserServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/
trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertAccount.java
trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertEntry.java
trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertJournal.java
trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertLog.java
trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertPeriod.java
trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTimeSpan.java
trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTopiaContext.java
trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTransaction.java
trunk/lima-business/src/main/java/org/chorem/lima/business/data/
trunk/lima-business/src/main/java/org/chorem/lima/business/data/Balance.java
trunk/lima-business/src/main/java/org/chorem/lima/business/data/Bilan.java
trunk/lima-business/src/main/java/org/chorem/lima/business/dto/
trunk/lima-business/src/main/java/org/chorem/lima/business/dto/AccountDTO.java
trunk/lima-business/src/main/java/org/chorem/lima/business/dto/EntryDTO.java
trunk/lima-business/src/main/java/org/chorem/lima/business/dto/JournalDTO.java
trunk/lima-business/src/main/java/org/chorem/lima/business/dto/LogDTO.java
trunk/lima-business/src/main/java/org/chorem/lima/business/dto/PeriodDTO.java
trunk/lima-business/src/main/java/org/chorem/lima/business/dto/TimeSpanDTO.java
trunk/lima-business/src/main/java/org/chorem/lima/business/dto/TransactionDTO.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DateUtil.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/NumberUtil.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ServiceHelper.java
trunk/lima-business/src/main/resources/
trunk/lima-business/src/main/resources/lima.properties
trunk/lima-business/src/main/resources/log4j.properties
trunk/lima-business/src/main/resources/save_callao.dtd
trunk/lima-business/src/test/
trunk/lima-business/src/test/java/
trunk/lima-business/src/test/java/org/
trunk/lima-business/src/test/java/org/chorem/
trunk/lima-business/src/test/java/org/chorem/lima/
trunk/lima-business/src/test/java/org/chorem/lima/business/
trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/JournalServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/LogServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/PeriodServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/TimeSpanServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/TransactionServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/UserServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/utils/
trunk/lima-business/src/test/java/org/chorem/lima/business/utils/NumberUtilTest.java
trunk/lima-business/src/test/resources/
trunk/lima-business/src/test/resources/lima_test.properties
trunk/lima-callao/
trunk/lima-callao/LICENSE.txt
trunk/lima-callao/README.txt
trunk/lima-callao/changelog.txt
trunk/lima-callao/pom.xml
trunk/lima-callao/src/
trunk/lima-callao/src/main/
trunk/lima-callao/src/main/xmi/
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-callao/src/main/xmi/accountingdto.zargo
trunk/lima-neogia/
trunk/lima-swing/
trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java
trunk/lima-swing/src/main/java/org/chorem/lima/balance/BalanceHelper.java
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ProgressBarImpl.java
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
trunk/lima-swing/src/main/resources/lima.properties
trunk/src/site/resources/images/
trunk/src/site/resources/images/codelutin.png
trunk/src/site/rst/devel/
trunk/src/site/rst/devel/modificationarchitecture.rst
Removed:
trunk/lima-dto/
trunk/lima-main/
trunk/lima-service-callao/
trunk/lima-service-mock/
trunk/lima-service-neogia/
trunk/lima-service/
trunk/lima-swing/dev.sh
trunk/lima-swing/go.bat
trunk/lima-swing/go.sh
trunk/lima-swing/src/main/filters/lima.properties
trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java
trunk/lima-swing/src/main/java/org/chorem/lima/balance/Balance.java
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ProgressBarImpl.java
trunk/lima-swing/src/main/resources/i18n/lima-main-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-main-fr_FR.properties
trunk/src/site/resources/logo/
Modified:
trunk/lima-swing/pom.xml
trunk/lima-swing/src/main/java/org/chorem/lima/DataManager.java
trunk/lima-swing/src/main/java/org/chorem/lima/LimaAction.java
trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
trunk/lima-swing/src/main/java/org/chorem/lima/Main.java
trunk/lima-swing/src/main/java/org/chorem/lima/balance/Category.java
trunk/lima-swing/src/main/java/org/chorem/lima/bilan/Bilan.java
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/AccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/JournalComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/PeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/AccountComboBoxRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/JournalComboBoxRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/PeriodClosureComboBoxRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/PeriodComboBoxRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/comparator/AccountComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/comparator/JournalComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/comparator/PeriodComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/comparator/StatusComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/AccountEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/BalanceEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/BilanActifEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/BilanPassifEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/ClosureEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/FilterEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/JournalEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/ResultChargeEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/ResultProduitEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/TransactionEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/export/CSVExport.java
trunk/lima-swing/src/main/java/org/chorem/lima/export/XMLExport.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/AbstractTransactionFilter.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/AccountFilter.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/AmountFilter.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/CreditFilter.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/DateFilter.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/DebitFilter.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/DescriptionFilter.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/Filter.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/JournalFilter.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/PeriodFilter.java
trunk/lima-swing/src/main/java/org/chorem/lima/filter/VoucherFilter.java
trunk/lima-swing/src/main/java/org/chorem/lima/imports/CSVImport.java
trunk/lima-swing/src/main/java/org/chorem/lima/imports/CSVImportEBP.java
trunk/lima-swing/src/main/java/org/chorem/lima/imports/XMLImport.java
trunk/lima-swing/src/main/java/org/chorem/lima/item/Item.java
trunk/lima-swing/src/main/java/org/chorem/lima/item/PeriodItem.java
trunk/lima-swing/src/main/java/org/chorem/lima/listener/ClicRight.java
trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java
trunk/lima-swing/src/main/java/org/chorem/lima/listener/TransactionHeaderListener.java
trunk/lima-swing/src/main/java/org/chorem/lima/listener/TransactionKeyListener.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/BilanActifJXTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/BilanPassifJXTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/ResultChargesJXTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/ResultProduitsJXTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/TransactionJXTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/NumberTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/PeriodTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/TextTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/BalanceTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/BilanActifTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/BilanPassifTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/ClosureTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/JournalTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/ResultChargesTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/ResultProduitsTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionDataTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFilteredTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFlattenTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableColumnModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/AccountTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/AmountTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/BalanceTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/BilanActifTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/BilanPassifTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/DateTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/JournalTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/PeriodTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/ResultTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/StatusTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/TextTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/TransactionAllCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/TransactionHeaderRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/tree/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ErrorMessage.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/FileChooseView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ProgressBar.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToStringConverter.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/JournalToStringConverter.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/PeriodToStringConverter.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java
trunk/pom.xml
Added: trunk/lima-business/LICENSE.txt
===================================================================
--- trunk/lima-business/LICENSE.txt (rev 0)
+++ trunk/lima-business/LICENSE.txt 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Added: trunk/lima-business/README.txt
===================================================================
--- trunk/lima-business/README.txt (rev 0)
+++ trunk/lima-business/README.txt 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1 @@
+TODO
\ No newline at end of file
Added: trunk/lima-business/changelog.txt
===================================================================
--- trunk/lima-business/changelog.txt (rev 0)
+++ trunk/lima-business/changelog.txt 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,2 @@
+0.1 ??? 200902??
+ * 20090128 [chemit] - initial release
\ No newline at end of file
Added: trunk/lima-business/pom.xml
===================================================================
--- trunk/lima-business/pom.xml (rev 0)
+++ trunk/lima-business/pom.xml 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,77 @@
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+ <parent>
+ <groupId>org.chorem</groupId>
+ <artifactId>lima</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.chorem.lima</groupId>
+ <artifactId>lima-business</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>lima-callao</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jdom</groupId>
+ <artifactId>jdom</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.time</groupId>
+ <artifactId>jsr-310-ri</artifactId>
+ </dependency>
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+ <name>Lima business</name>
+ <description>Business module for lima</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+ <packaging>jar</packaging>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!-- Temp disable -->
+ <showDeprecation>false</showDeprecation>
+ <showWarnings>true</showWarnings>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <!-- <resources>
+ <resource>
+ <directory>${maven.src.dir}/main/resources/</directory>
+ <includes>
+ <include>*.properties</include>
+ </includes>
+ </resource>
+ </resources> -->
+ </build>
+
+</project>
+
+
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,798 @@
+/*
+ * *##% Callao AccountServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+import static org.nuiton.i18n.I18n._;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Permet d'implémenter le Plan Comptable Général.
+ * Un compte ne peut être supprimé si il contient des écritures comptables.
+ * Un compte peut devenir père et avoir des comptes fils. Chaque compte créé doit
+ * renseigné si il appartient à un compte père avec le numéro de compte père.
+ *
+ * @author Rémi Chapelet
+ */
+public class AccountServiceImpl {
+
+ private static final Log log = LogFactory.getLog(AccountServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ //private ConvertAccount convertAccount = new ConvertAccount();
+
+ public AccountServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Permet de créer un nouveau compte dans le PCG de l'application.
+ * Il ne peut exister deux numéros identiques. Pour chaque nouveau compte,
+ * il est vérifié si il n'existe pas un compte avec le numéro donné. Dans ce
+ * cas présent, le compte n'est pas créé.
+ * ATTENTION : le compte masterAccount, c'est à dire le compte père, doit
+ * exister, sinon le compte n'est pas créé. Si le compte n'a pas de père, alors
+ * mettre masterAccount à null.
+ *
+ * @param account account to create
+ * @throws LimaException
+ */
+ public void createAccount(Account account) throws LimaException {
+
+ // test la validite du numero de compte
+ if (StringUtils.isBlank(account.getAccountNumber())) {
+ throw new LimaBusinessException("Invalid AccountNumber : " + account.getAccountNumber());
+ }
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // test si le numero de compte existe deja
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ List<Account> existingAccounts = accountDAO.findAllByAccountNumber(account.getAccountNumber());
+ if (CollectionUtils.isNotEmpty(existingAccounts)) {
+ throw new LimaBusinessException(_("An account already exists with this number : %s", account.getAccountNumber()));
+ }
+
+ // test si le compte parent existe
+ Account masterAcount = account.getMasterAccount();
+ if (masterAcount != null) {
+ accountDAO.update(masterAcount);
+ }
+ else {
+ accountDAO.create(account);
+ }
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create account", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create account", ex);
+ }
+ }
+ }
+ }
+ /*public String createAccount (String accountNumber, String label,Account masterAccount,String type)
+ {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Détermine si le compte existe déjà ou non
+ boolean existAccount = existAccount(accountNumber);
+ // Si le numéro de compte existe
+ if (existAccount)
+ {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro "+accountNumber+" existe deja !");
+ }
+ result = ServiceHelper.ACCOUNT_DOUBLE;
+ } else {
+ // Création du compte
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+
+ //Le compte a un père
+
+ if ( masterAccount != null )
+ {
+ // Vérification que le compte père existe dans la base de données
+ boolean existMasterAccount = existAccount(masterAccount.getAccountNumber());
+ // Si le compte père n'existe pas
+ if (!existMasterAccount)
+ {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte père numéro "+accountNumber+" n'existe pas !");
+ }
+ result = ServiceHelper.ACCOUNT_NOT_MASTER;
+ } else {
+ // Creation du compte
+ Account newAccount = accountDAO.create();
+ newAccount.setAccountNumber(accountNumber);
+ newAccount.setLabel(label);
+ newAccount.setMasterAccount(masterAccount);
+ newAccount.setType(type);
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ } else {
+ // Le compte n'a pas de père
+ // Creation du compte
+ Account newAccount = accountDAO.create();
+ newAccount.setAccountNumber(accountNumber);
+ newAccount.setLabel(label);
+ newAccount.setType(type);
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ }catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+
+ /*
+ * Permet de créer un compte à partir du numéro de compte père. Il appelle
+ * ensuite createAccount avec le compte père.
+ * @param accountNumber numéro du compte à créer
+ * @param label label pour le compte
+ * @param maserAccountNumber numéro du compte père, si il en a pas, mettre 0.
+ * @return
+ *
+ public String createAccount(String accountNumber, String label,
+ String masterAccountNumber, String type) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Recherche le compte Master
+ Account masterAccount = searchAccount(masterAccountNumber);
+ // Si le compte père n'existe pas
+ if (masterAccount == null && !masterAccountNumber.equals("0")) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte père numéro " + masterAccountNumber
+ + " n'existe pas !");
+ }
+ result = ServiceHelper.ACCOUNT_NOT_MASTER;
+ } else {
+ // Création du compte
+ result = createAccount(accountNumber, label, masterAccount, type);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de creer un compte à partir d'un objet DTO
+ * @param accountDTO compte au format DTO
+ * @return
+ *
+ public String createAccount(AccountDTO accountDTO) {
+ String result;
+ String result_final;
+ boolean error = false; // Si il y a eu une erreur pour créer les enfants
+
+ // Création du compte père
+ result = createAccount(accountDTO.getAccountNumber(), accountDTO
+ .getLabel(), accountDTO.getMasterAccount(), accountDTO
+ .getType());
+ // Création des comptes enfants
+
+ // Pour chaque enfant
+ for (AccountDTO accountChildDTO : accountDTO.getAccountChildDTO()) {
+ // Création de l'enfant
+ result = createAccount(accountChildDTO);
+ // Si il y a eu une erreur
+ if (!result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro " + accountChildDTO.getLabel()
+ + " n'a pu être créé !");
+ }
+ error = true;
+ result_final = result;
+ }
+ }
+ // Si il y a eu une erreur lors de la création d'un enfant, il est envoyé une erreur.
+ if (error) {
+ result = ServiceHelper.RESPOND_ERROR;
+ }
+ return result;
+ }*/
+
+ /*
+ * Recherche un compte DTO. Il est recherché dans la base de données et est
+ * converti avec ConvertAccount. ConvertAccount recherche dans la liste de
+ * ses enfants pour les convertir également, et ainsi de suite.
+ * @param accountNumber numéro du compte qu'on souhait rechercher
+ * @return
+ *
+ public AccountDTO searchAccountDTO(String accountNumber) {
+ AccountDTO accountDTO = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche du compte
+ Account account = accountDAO.findByAccountNumber(accountNumber);
+ // Converti entity en DTO
+ convertAccount.setTransaction(topiaContext);
+ accountDTO = convertAccount.accountEntityToDto(account, null);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return accountDTO;
+ }*/
+
+ /*
+ * Permet de rechercher un compte à partir d'un numéro de compte.
+ * @param accountNumber numéro du compte à rechercher
+ * @return
+ *
+ public Account searchAccount(String accountNumber) {
+ Account accountResult = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche du compte
+ accountResult = accountDAO.findByAccountNumber(accountNumber);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return accountResult;
+ }*/
+
+ /*
+ * Permet de renvoyer tous les enfants du compte.
+ * Cette fonction permet de renvoyer les enfants, mais PAS les enfants des
+ * enfants (et ainsi de suite). Cette méthode descend donc uniquement d'un
+ * niveau sur la hiérarchie.
+ * @param account compte dont on souhaite obtenir ses enfants.
+ * @return
+ *
+ public List<Account> searchListChildAccount(Account account) {
+ List<Account> ListAccount = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche des comptes enfants
+ ListAccount = accountDAO.findAllByMasterAccount(account);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return ListAccount;
+ }*/
+
+ /*
+ * Permet de renvoyer tous les enfants du compte. Elle se base sur la fonction
+ * searchListChildAccount(Account account).
+ * Cette fonction permet de renvoyer les enfants, mais PAS les enfants des
+ * enfants (et ainsi de suite). Cette méthode descend donc uniquement d'un
+ * niveau sur la hiérarchie.
+ * @param account numéro de compte dont on souhaite obtenir ses enfants.
+ * @return
+ *
+ public List<Account> searchListChildAccount(String accountNumber) {
+ List<Account> ListAccount = null;
+ // Recherche le compte
+ Account account = searchAccount(accountNumber);
+ // Si le compte n'existe pas
+ if (account == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro " + accountNumber
+ + " n'existe pas !");
+ }
+ } else {
+ // Recherche des comptes enfants
+ ListAccount = searchListChildAccount(account);
+ }
+ return ListAccount;
+ }*/
+
+ /**
+ * Permet de convertir tous les comptes en DTO. Il recherche dans un premier
+ * temps tous les comptes "master".
+ *
+ * @return
+ * @throws LimaException
+ */
+ public List<Account> getAllAccount() throws LimaException {
+ /*ArrayList<AccountDTO> listAccountDTO = new ArrayList<AccountDTO>();
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche des comptes enfants
+ List<Account> listAccount = accountDAO.findAll();
+ // Pour chaque compte
+ // Converti entity en DTO
+ convertAccount.setTransaction(topiaContext);
+ for (Account account : listAccount) {
+ // Pour les comptes sans père
+ if (account.getMasterAccount() == null) {
+ AccountDTO accountDTO = convertAccount.accountEntityToDto(
+ account, null);
+ listAccountDTO.add(accountDTO);
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listAccountDTO;*/
+
+ List<Account> accountsList = new ArrayList<Account>();
+
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ List<Account> accounts = accountDAO.findAll();
+ accountsList.addAll(accounts);
+
+ transaction.closeContext();
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create account", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create account", ex);
+ }
+ }
+ }
+
+ return accountsList;
+ }
+
+ /*
+ * Renvoie vrai si le compte avec son numéro existe déjà dans la base de
+ * données.
+ * @param accountNumber numéro du compte recherché
+ * @return
+ *
+ public boolean existAccount(String accountNumber) {
+ // Recherche du compte
+ Account accountSearch = searchAccount(accountNumber);
+ boolean result = false;
+ // Si le compte est trouvé
+ if (accountSearch != null) {
+ result = true;
+ }
+ return result;
+ }*/
+
+ /**
+ * Permet d'effacer un compte dans la base de données.
+ *
+ * Il est vérifié dans un premier temps si le compte existe bien.
+ * ATTENTION : si il existe une entrée comptable associée au numéro de
+ * compte, il est alors impossible de supprimer le compte.
+ *
+ * @param account
+ * @throws LimaException
+ */
+ public void removeAccount(Account account) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ Account deleteAccount = searchAccount(accountNumber);
+ // Si le compte n'existe pas
+ if (deleteAccount == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro " + accountNumber
+ + " n'existe pas !");
+ }
+ result = ServiceHelper.ACCOUNT_NOT_EXIST;
+ } else // Sinon on efface le compte
+ {
+ // Vérifie si une entrée ne possède pas ce numéro de compte.
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper
+ .getEntryDAO(topiaContext);
+ // Recherche au moins une entry avec ce compte.
+ Entry entry = entryDAO.findByAccount(deleteAccount);
+ // Il existe au moins une entrée
+ if (entry != null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro " + accountNumber
+ + " possède des entrées comptable !");
+ }
+ result = ServiceHelper.ACCOUNT_WITH_ENTRIES;
+ } else {
+ // On efface tous les comptes enfants
+ List<Account> listAccountChild = searchListChildAccount(deleteAccount);
+ boolean ErrorRemoveChild = false;
+ for (Account accountChild : listAccountChild) {
+ // Si on souhaite supprimer les comptes enfants
+ result = removeAccount(accountChild.getAccountNumber());
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ ErrorRemoveChild = true;
+ if (log.isErrorEnabled()) {
+ log.error("Le compte fils numéro "
+ + accountChild.getAccountNumber()
+ + " n'a pas été supprimé !");
+ }
+ }
+ //
+ // Si on ne souhaite pas supprimer les comptes enfants, tous les
+ // comptes enfants se retrouvent sans père. Commenter removeAccountChildTest
+ // dans le fichier AccountServiceImplTest dans ce cas.
+
+ //modifyAccount(accountChild.getAccountNumber(),accountChild.getLabel(),null);
+ }
+ // Si il n'a jamais eu d'erreur pour supprimer ses fils
+ if (!ErrorRemoveChild) {
+
+ //// Efface le compte père
+
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Supprime le compte
+ accountDAO.delete(deleteAccount);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ if (log.isInfoEnabled()) {
+ log.info("Le compte numéro " + accountNumber
+ + " a ete supprimé avec succès.");
+ }
+ }
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;*/
+
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ // Vérifie si une entrée ne possède pas ce numéro de compte.
+ // FIXME !IMPORTANT! check that subaccounts have no entries too
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
+ Entry firstEntry = entryDAO.findByAccount(account);
+
+ if (firstEntry != null) {
+ throw new LimaBusinessException("Can't delete account with entries");
+ }
+
+ // remove account
+ // FIXME !IMPORTANT! check that subaccounts are also deleted
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ accountDAO.delete(account);
+
+ transaction.closeContext();
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't delete account", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't delete account", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Permet d'effacer un compte à partir d'un compte DTO. Il appelle la
+ * méthode removeAccount, qui effacera également les enfants (et ainsi de
+ * suite dans la hiérarchie du compte).
+ * @param accountDTO Compte au format DTO qu'on souhaite supprimer.
+ * @return
+ *
+ public String removeAccount(AccountDTO accountDTO) {
+ String result;
+ result = removeAccount(accountDTO.getAccountNumber());
+ return result;
+ }*/
+
+ /**
+ * Permet de modifier un compte sur son label et son compte père.
+ *
+ * Il n'est pas possible de modifier un numéro de compte.
+ * Si le compte n'existe pas, il envoie alors un message d'avertissement.
+ *
+ * @param accountNumber numéro de compte à modifier
+ * @param label label à modifier
+ * @param masterAccountNumber compte père à modifier
+
+ * @throws LimaException
+ */
+ public void modifyAccount(Account account) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche du compte
+ Account modifyAccount = accountDAO
+ .findByAccountNumber(accountNumber);
+ // Si le compte n'existe pas
+ if (modifyAccount == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le compte numéro " + accountNumber
+ + " n'existe pas !");
+ }
+ result = ServiceHelper.ACCOUNT_NOT_EXIST;
+ } else {
+
+ // Modifie le compte
+ modifyAccount.setLabel(label);
+ modifyAccount.setType(type);
+ // Recherche du compte père
+ // Si il possède un compte père
+ if (masterAccount != null) {
+ modifyAccount.setMasterAccount(masterAccount);
+ }
+ modifyAccount.update();
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;*/
+
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ // update account
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ accountDAO.update(account);
+
+ transaction.closeContext();
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't update account", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't update account", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Permet de modifier un compte sur son label et son compte père.
+ * Il recherche le compte père avec le numéro de compte fourni. Appel ensuite
+ * la méthode modifyAccount avec pour paramètre le compte père trouvé.
+ * @param accountNumber numéro de compte à modifier
+ * @param label label à modifier
+ * @param masterAccountNumber le numéro du compte père
+ * @return
+ *
+ public String modifyAccount(String accountNumber, String label,
+ String type, String masterAccountNumber) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+
+ // Modifie le compte
+ // Recherche du compte père
+ Account masterAccount = accountDAO
+ .findByAccountNumber(masterAccountNumber);
+ result = modifyAccount(accountNumber, label, type, masterAccount);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier un compte à partir d'un compte DTO.
+ * @param accountDTO compte au format DTO qu'on souhaire modifier.
+ * @return
+ *
+ public String modifyAccount(AccountDTO accountDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper
+ .getAccountDAO(topiaContext);
+ // Recherche du compte père
+ Account masterAccount = accountDAO.findByAccountNumber(accountDTO
+ .getMasterAccount());
+ result = modifyAccount(accountDTO.getAccountNumber(), accountDTO
+ .getLabel(), accountDTO.getType(), masterAccount);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de mettre à jour le compte DTO ainsi que tous ses fils.
+ * Cette méthode permet d'ajouter, modifier, et supprimer un compte et
+ * ses enfants (et ainsi de suite).
+ * @param accountDTO
+ * @return
+ *
+ public String updateDTO(AccountDTO accountDTO) {
+ String result;
+ // Si le compte DTO père existe
+ if (existAccount(accountDTO.getAccountNumber())) {
+ // Modification du compte père
+ result = modifyAccount(accountDTO);
+ } else {
+ // Création du compte père
+ result = createAccount(accountDTO);
+ }
+ // Pour chaque enfant on lance l'update
+ for (AccountDTO accountChildDTO : accountDTO.getAccountChildDTO()) {
+ updateDTO(accountChildDTO);
+ }
+
+ // On recherche les comptes DTO effacés
+ List<Account> listAccountChild = searchListChildAccount(accountDTO
+ .getAccountNumber());
+ for (Account account : listAccountChild) {
+ // Si le compte n'est pas dans la liste, alors on efface
+ if (!accountDTO.existAccountChild(account.getAccountNumber())) {
+ result = removeAccount(account.getAccountNumber());
+ }
+ }
+ return result;
+ }*/
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/EntryServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/EntryServiceImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,381 @@
+/*
+ * *##% Callao EntryServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Entry;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Cette classe permet de contrôler les différentes saisies possibles dans
+ * Callao. Ces saisies sont transmises à la base de données par la classe
+ * Entry. Chaque action sur une entrée déclenche une création d'un log.
+ * Chaque opération comptable doit faire appel également au contrôl de la
+ * période comptable sur laquelle l'entry repose. Ainsi il n'est possible
+ * d'ajouter/modifier/supprimer une entrée si la période est bloquée.
+ *
+ * @author Rémi Chapelet
+ */
+public class EntryServiceImpl { // implements EntryService {
+
+ private static final Log log = LogFactory.getLog(EntryServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ private LogServiceImpl logServiceImpl = new LogServiceImpl();
+
+ // TODO A revoir car transaction a besoin de entry et vice versa
+ private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+
+ private AccountServiceImpl accountServiceImpl = new AccountServiceImpl();
+
+ public EntryServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Création d'une entrée comptable.
+ * La période ne doit PAS être bloquée.
+ *
+ * @return
+ */
+ public void createEntry(Entry entry /*String description, String amount, boolean debit,
+ String lettering, String detail, Transaction transaction,
+ Account account*/) {
+ /*String result = isCorrectEntry(transaction, account);
+ if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper
+ .getEntryDAO(topiaContext);
+ // Creation de l'entrée comptable
+ Entry newEntry = entryDAO.create();
+ newEntry.setDescription(description);
+ // On formate le nombre
+ newEntry.setAmount(numberUtil.format(amount));
+ newEntry.setDebit(debit);
+ newEntry.setLettering(lettering);
+ newEntry.setDetail(detail);
+ newEntry.setTransaction(transaction);
+ newEntry.setAccount(account);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ if (log.isInfoEnabled()) {
+ log.info("Ajout avec succes de l'entrée comptable.");
+ }
+ // Création du log
+ Date logDate = new Date();
+ logServiceImpl.addLog(logDate, transaction.getTransDate(),
+ ServiceHelper.LOG_ADD, transaction.getVoucherRef(),
+ transaction.getDescription(), detail, amount, debit,
+ lettering);
+
+ // Il renvoie soit l'identifiant topiaId ou SUCCESS.
+ result = newEntry.getTopiaId();
+ //result = ServiceHelper.RESPOND_SUCCESS;
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;*/
+ }
+
+ /*
+ * Permet de créer une entrée comptable à partir de son DTO.
+ * @param entryDTO
+ * @return
+ *
+ public String createEntry(EntryDTO entryDTO) {
+ // Recherche TransactionDTO
+ TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
+ Transaction transaction = transactionServiceImpl
+ .searchTransactionWithTopiaId(transactonDTO);
+ // Recherche AccountDTO
+ AccountDTO accountDTO = entryDTO.getAccountDTO();
+ Account account = accountServiceImpl.searchAccount(accountDTO
+ .getAccountNumber());
+ // Création entry
+ String result = createEntry(entryDTO.getDescription(), entryDTO
+ .getAmount(), entryDTO.isDebit(), entryDTO.getLettering(),
+ entryDTO.getDetail(), transaction, account);
+ return result;
+ }*/
+
+ /*
+ * Vérifie que les objets transaction et account ne sont pas nulls.
+ * @param transaction
+ * @param account
+ * @return
+ *
+ public String isCorrectEntry(Transaction transaction, Account account) {
+ String result = ServiceHelper.RESPOND_SUCCESS;
+ // Vérification si timeSpan et Journal existe bien
+ if (account == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création entry : Le account n'existe pas.");
+ }
+ result = ServiceHelper.ACCOUNT_NOT_EXIST;
+ }
+ if (transaction == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création entry : La transaction n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_EXIST;
+ }
+ return result;
+ }*/
+
+ /*
+ * Recherche toutes les entrées comptables d'une transaction.
+ * @param transaction
+ * @return
+ *
+ public List<Entry> searchEntryWithTransaction(Transaction transaction) {
+ List<Entry> listEntry = null;
+ if (transaction != null) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper
+ .getEntryDAO(topiaContext);
+ // Recherche
+ listEntry = entryDAO.findAllByTransaction(transaction);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return listEntry;
+ }*/
+
+ /*
+ * Recherche toutes les entrées comptables d'une transaction, et renvoie
+ * au format DTO.
+ * @param transaction
+ * @return
+ *
+ public List<EntryDTO> searchEntryDTOWithTransaction(Transaction transaction) {
+ List<EntryDTO> listEntryDTO = new ArrayList<EntryDTO>();
+ // Si la transaction est trouvée
+ if (transaction != null) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper
+ .getEntryDAO(topiaContext);
+ // Recherche toutes les entrées comptables de la transaction
+ List<Entry> listEntry = entryDAO
+ .findAllByTransaction(transaction);
+ // Pour chaque entry, on fait appel au convertisseur pour avoir en DTO
+ convertEntry.setTransaction(topiaContext);
+ for (Entry entry : listEntry) {
+ EntryDTO entryDTO = convertEntry.entryEntityToDto(entry);
+ // On ajoute le nouvel DTO
+ listEntryDTO.add(entryDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return listEntryDTO;
+ }*/
+
+ /*
+ * Recherche les entrées comptables pour une transaction donnée au format DTO.
+ * @param transactionTopiaId identifiant de la transaction
+ * @return
+ *
+ public List<EntryDTO> searchEntryDTOWithTransaction(
+ String transactionTopiaId) {
+ List<EntryDTO> listEntryDTO = new ArrayList<EntryDTO>();
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ // Recherche de la transaction
+ Transaction transaction = transactionServiceImpl
+ .searchTransactionWithTopiaId(transactionTopiaId);
+ // Si la transaction est trouvée
+ if (transaction != null) {
+ // Recherche toutes les entrées comptables de la transaction
+ List<Entry> listEntry = entryDAO
+ .findAllByTransaction(transaction);
+ // Pour chaque entry, on fait appel au convertisseur pour avoir en DTO
+ convertEntry.setTransaction(topiaContext);
+ for (Entry entry : listEntry) {
+ EntryDTO entryDTO = convertEntry.entryEntityToDto(entry);
+ // On ajoute l'entrée DTO
+ listEntryDTO.add(entryDTO);
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listEntryDTO;
+ }*/
+
+ /*
+ * Recherche les entrées comptables pour une transaction donnée au format DTO.
+ * @param transactionDTO
+ * @return
+ *
+ public List<EntryDTO> searchEntryDTOWithTransaction(
+ TransactionDTO transactionDTO) {
+ List<EntryDTO> listEntryOfTransaction = searchEntryDTOWithTransaction(transactionDTO
+ .getId());
+ return listEntryOfTransaction;
+ }*/
+
+ /*
+ * Permet d'effacer une entrée comptable à partir de son identifiant topia.
+ * @param topiaId
+ * @return
+ *
+ public String removeEntry(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ // Recherche de l'entry
+ Entry entryDelete = entryDAO.findByTopiaId(topiaId);
+ // Si l'entry existe alors on supprime
+ if (entryDelete != null) {
+ // Supprime
+ entryDAO.delete(entryDelete);
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ result = ServiceHelper.ENTRY_NOT_EXIST;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'effacer une entrée comptable au format DTO.
+ * @param entryDTO
+ * @return
+ *
+ public String removeEntry(EntryDTO entryDTO) {
+ String result = removeEntry(entryDTO.getId());
+ return result;
+ }*/
+
+ /*
+ * Modification d'une entrée comptable.
+ * @param topiaId
+ * @param description
+ * @param amount
+ * @param debit
+ * @param lettering
+ * @param detail
+ * @param transaction
+ * @param account
+ * @return
+ *
+ public String modifyEntry(String topiaId, String description,
+ String amount, boolean debit, String lettering, String detail,
+ Account account) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ // Recherche Entry
+ Entry entry = entryDAO.findByTopiaId(topiaId);
+ entry.setDescription(description);
+ // On formate le nombre
+ entry.setAmount(numberUtil.format(amount));
+ entry.setDebit(debit);
+ entry.setLettering(lettering);
+ entry.setDetail(detail);
+ entry.setAccount(account);
+ entry.update();
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Chargement DAO transaction
+ Transaction transaction = entry.getTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Edit avec succes de l'entrée comptable.");
+ }
+ // Création du log
+ Date logDate = new Date();
+ logServiceImpl.addLog(logDate, transaction.getTransDate(),
+ ServiceHelper.LOG_MODIFY, transaction.getVoucherRef(),
+ transaction.getDescription(), detail, amount, debit,
+ lettering);
+ result = ServiceHelper.RESPOND_SUCCESS;
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une entrée comptable.
+ * @param entryDTO
+ * @return
+ *
+ public String modifyEntry(EntryDTO entryDTO) {
+ // Recherche AccountDTO
+ AccountDTO accountDTO = entryDTO.getAccountDTO();
+ Account account = accountServiceImpl.searchAccount(accountDTO
+ .getAccountNumber());
+ // Modification entry
+ String result = modifyEntry(entryDTO.getId(),
+ entryDTO.getDescription(), entryDTO.getAmount(), entryDTO
+ .isDebit(), entryDTO.getLettering(), entryDTO
+ .getDetail(), account);
+ return result;
+ }*/
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/FilesServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FilesServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FilesServiceImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,667 @@
+/*
+ * *##% Callao FilesServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.dto.AccountDTO;
+import org.chorem.lima.business.dto.EntryDTO;
+import org.chorem.lima.business.dto.JournalDTO;
+import org.chorem.lima.business.dto.PeriodDTO;
+import org.chorem.lima.business.dto.TimeSpanDTO;
+import org.chorem.lima.business.dto.TransactionDTO;
+import org.chorem.lima.business.utils.DateUtil;
+import org.chorem.lima.business.utils.ServiceHelper;
+import org.jdom.Attribute;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+import org.jdom.xpath.XPath;
+import org.nuiton.topia.TopiaContext;
+
+/**
+ * Cette classe permet d'importer et exporter des données comptables. Ces données
+ * sont au format xml.
+ *
+ * @author Rémi Chapelet
+ */
+public class FilesServiceImpl { // implements FilesService {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(FilesServiceImpl.class);
+
+ static Element racine = new Element("Callao");
+
+ static org.jdom.Document document = new Document(racine);
+
+ private static DateUtil dateUtil = new DateUtil();
+
+ private AccountServiceImpl accountServiceImpl = new AccountServiceImpl();
+
+ private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
+
+ private JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
+
+ private PeriodServiceImpl periodServiceImpl = new PeriodServiceImpl();
+
+ private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
+
+ private TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+
+ /**
+ * Cete méthode permet d'exporter des données de Callao vers un fichier au
+ * format xml.
+ *
+ * @param nameFile
+ */
+ public void exportDatas(String nameFile) {
+ /*if (log.isDebugEnabled()) {
+ log.debug("Save file XML : ");
+ }
+
+ // Partie Informations
+ Element info = new Element("informations");
+ racine.addContent(info);
+ Attribute date = new Attribute("date", new Date().toString());
+ info.setAttribute(date);
+ Attribute user = new Attribute("user", "Name user");
+ info.setAttribute(user);
+ Attribute company = new Attribute("company", "Name company");
+ info.setAttribute(company);
+
+ // Partie Save
+
+ // Création Element save
+ Element save = new Element("save");
+ racine.addContent(save);
+
+ // Period
+
+ // Création élément liste de périods
+ Element periods = new Element("periods");
+ // Création élément liste de timespans
+ Element timeSpans = new Element("timespans");
+ save.addContent(periods);
+ save.addContent(timeSpans);
+ // Recherche de la liste de toutes les périodes et leurs timeSpans en DTO
+ List<PeriodDTO> listPeriodDTO = periodServiceImpl.getAllPeriod();
+ // Pour chaque période
+ for (PeriodDTO periodDTO : listPeriodDTO) {
+ // Création élément périod
+ Element period = new Element("period");
+ periods.addContent(period);
+ // Identifiant période
+ Attribute id = new Attribute("id", periodDTO.getId());
+ period.setAttribute(id);
+ // BeginPeriod
+ // Découpage date
+ String dateTab[] = dateUtil.arrayDate(periodDTO.getBeginPeriod());
+ Attribute beginYear = new Attribute("beginYear", dateTab[0]);
+ period.setAttribute(beginYear);
+ Attribute beginMonth = new Attribute("beginMonth", dateTab[1]);
+ period.setAttribute(beginMonth);
+ Attribute beginDay = new Attribute("beginDay", dateTab[2]);
+ period.setAttribute(beginDay);
+ // EndPeriod
+ dateTab = dateUtil.arrayDate(periodDTO.getEndPeriod());
+ Attribute endYear = new Attribute("endYear", dateTab[0]);
+ period.setAttribute(endYear);
+ Attribute endMonth = new Attribute("endMonth", dateTab[1]);
+ period.setAttribute(endMonth);
+ Attribute endDay = new Attribute("endDay", dateTab[2]);
+ period.setAttribute(endDay);
+ // Locked Period
+ if (periodDTO.isLocked()) {
+ Attribute locked = new Attribute("locked", "true");
+ period.setAttribute(locked);
+ } else {
+ Attribute locked = new Attribute("locked", "false");
+ period.setAttribute(locked);
+ }
+
+ // TimeSpan
+
+ // Recherche des timeSpans de la période
+ List<TimeSpanDTO> listTimeSpanDTO = periodDTO.getListTimeSpan();
+ // Pour chaque timeSpan
+ for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
+ Element timeSpan = new Element("timespan");
+ timeSpans.addContent(timeSpan);
+ // Identifiant timeSpan
+ Attribute idTimeSpan = new Attribute("id", timeSpanDTO.getId());
+ timeSpan.setAttribute(idTimeSpan);
+ Attribute idPeriod = new Attribute("idPeriod", periodDTO
+ .getId());
+ timeSpan.setAttribute(idPeriod);
+ // Begin TimeSpan
+ // Découpage date
+ dateTab = dateUtil.arrayDate(timeSpanDTO.getBeginTimeSpan());
+ Attribute beginYearTimeSpan = new Attribute("beginYear",
+ dateTab[0]);
+ timeSpan.setAttribute(beginYearTimeSpan);
+ Attribute beginMonthTimeSpan = new Attribute("beginMonth",
+ dateTab[1]);
+ timeSpan.setAttribute(beginMonthTimeSpan);
+ Attribute beginDayTimeSpan = new Attribute("beginDay",
+ dateTab[2]);
+ timeSpan.setAttribute(beginDayTimeSpan);
+ // End TimeSpan
+ dateTab = dateUtil.arrayDate(timeSpanDTO.getEndTimeSpan());
+ Attribute endYearTimeSpan = new Attribute("endYear", dateTab[0]);
+ timeSpan.setAttribute(endYearTimeSpan);
+ Attribute endMonthTimeSpan = new Attribute("endMonth",
+ dateTab[1]);
+ timeSpan.setAttribute(endMonthTimeSpan);
+ Attribute endDayTimeSpan = new Attribute("endDay", dateTab[2]);
+ timeSpan.setAttribute(endDayTimeSpan);
+ // Lock timeSpan
+ if (timeSpanDTO.isLocked()) {
+ Attribute locked = new Attribute("locked", "true");
+ timeSpan.setAttribute(locked);
+ } else {
+ Attribute locked = new Attribute("locked", "false");
+ timeSpan.setAttribute(locked);
+ }
+ }
+ }
+
+ // Journal
+
+ Element journals = new Element("journals");
+ save.addContent(journals);
+ List<JournalDTO> listJournalDTO = journalServiceImpl.getAllJournal();
+ for (JournalDTO journalDTO : listJournalDTO) {
+ Element journal = new Element("journal");
+ journals.addContent(journal);
+ // Identification du journal
+ Attribute idJournal = new Attribute("id", journalDTO.getId());
+ journal.setAttribute(idJournal);
+ // Label
+ Attribute label = new Attribute("label", journalDTO.getLabel());
+ journal.setAttribute(label);
+ // Prefix
+ Attribute prefix = new Attribute("prefix", journalDTO.getPrefix());
+ journal.setAttribute(prefix);
+ // Description
+ Attribute description = new Attribute("description", journalDTO
+ .getDescription());
+ journal.setAttribute(description);
+ }
+
+ // Account
+
+ Element accounts = new Element("accounts");
+ save.addContent(accounts);
+ List<AccountDTO> listAccountDTO = accountServiceImpl.getAllAccount();
+ // Appel une fonction récursive pour parcourir l'arborescence des comptes
+ accountXML(listAccountDTO, accounts);
+
+ // Transaction
+ Element transactions = new Element("transactions");
+ save.addContent(transactions);
+ Element entries = new Element("entries");
+ save.addContent(entries);
+ // Recherche de toutes les transactions
+ List<TransactionDTO> listTransactionDTO = transactionServiceImpl
+ .getAllTransactionDTO();
+ // Pour chaque transaction
+ for (TransactionDTO transactionDTO : listTransactionDTO) {
+ Element transaction = new Element("transaction");
+ transactions.addContent(transaction);
+ // Identification de la transaction
+ Attribute idTransaction = new Attribute("id", transactionDTO
+ .getId());
+ transaction.setAttribute(idTransaction);
+ // EntryDate
+ String dateTab[] = dateUtil
+ .arrayDate(transactionDTO.getEntryDate());
+ Attribute entryDateYear = new Attribute("entryDateYear", dateTab[0]);
+ transaction.setAttribute(entryDateYear);
+ Attribute entryDateMonth = new Attribute("entryDateMonth",
+ dateTab[1]);
+ transaction.setAttribute(entryDateMonth);
+ Attribute entryDateDay = new Attribute("entryDateDay", dateTab[2]);
+ transaction.setAttribute(entryDateDay);
+ // VoucherRef
+ Attribute voucherRef = new Attribute("voucherRef", transactionDTO
+ .getVoucherRef());
+ transaction.setAttribute(voucherRef);
+ // Description
+ Attribute description = new Attribute("description", transactionDTO
+ .getDescription());
+ transaction.setAttribute(description);
+ // Id journal
+ Attribute IdJournal = new Attribute("idJournal", transactionDTO
+ .getJournalDTO().getId());
+ transaction.setAttribute(IdJournal);
+ // Id timeSpan
+ Attribute IdTimeSpan = new Attribute("idTimeSpan", transactionDTO
+ .getTimeSpanDTO().getId());
+ transaction.setAttribute(IdTimeSpan);
+
+ // Entry
+ List<EntryDTO> listEntryDTO = entryServiceImpl
+ .searchEntryDTOWithTransaction(transactionDTO);
+ for (EntryDTO entryDTO : listEntryDTO) {
+ Element entry = new Element("entry");
+ entries.addContent(entry);
+ // Identification du entry
+ Attribute idEntry = new Attribute("id", entryDTO.getId());
+ entry.setAttribute(idEntry);
+ // Description
+ Attribute descriptionEntry = new Attribute("description",
+ entryDTO.getDescription());
+ entry.setAttribute(descriptionEntry);
+ // Amount
+ Attribute amount = new Attribute("amount", entryDTO.getAmount());
+ entry.setAttribute(amount);
+ // Lettering
+ Attribute lettering = new Attribute("lettering", entryDTO
+ .getLettering());
+ entry.setAttribute(lettering);
+ // Detail
+ Attribute detail = new Attribute("detail", entryDTO.getDetail());
+ entry.setAttribute(detail);
+ // Debit / crédit
+ if (entryDTO.isDebit()) {
+ Attribute debit = new Attribute("debit", "true");
+ entry.setAttribute(debit);
+ } else {
+ Attribute debit = new Attribute("debit", "false");
+ entry.setAttribute(debit);
+ }
+ // Transaction
+ Attribute idrefTransaction = new Attribute("idTransaction",
+ transactionDTO.getId());
+ entry.setAttribute(idrefTransaction);
+ // Account
+ Attribute idAccount = new Attribute("idAccount", entryDTO
+ .getAccountDTO().getId());
+ entry.setAttribute(idAccount);
+ }
+ }
+ //affiche();
+ enregistre(nameFile);
+ return ServiceHelper.RESPOND_SUCCESS;*/
+ }
+
+ /**
+ * Converti la liste des comptes pour être ajouté au document xml.
+ * @param listAccountDTO
+ * @param accounts
+ */
+ protected void accountXML(List<AccountDTO> listAccountDTO, Element accounts) {
+ /*for (AccountDTO accountDTO : listAccountDTO) {
+ Element account = new Element("account");
+ accounts.addContent(account);
+ // Identification du account
+ Attribute idAccount = new Attribute("id", accountDTO.getId());
+ account.setAttribute(idAccount);
+ // Label
+ Attribute label = new Attribute("label", accountDTO.getLabel());
+ account.setAttribute(label);
+ // Type
+ Attribute type = new Attribute("type", accountDTO.getType());
+ account.setAttribute(type);
+ // AccountNumber
+ Attribute accountNumber = new Attribute("accountNumber", accountDTO
+ .getAccountNumber());
+ account.setAttribute(accountNumber);
+ // MasterAccountNumber
+ Attribute masterAccountNumber = new Attribute("masterAccount",
+ accountDTO.getMasterAccount());
+ account.setAttribute(masterAccountNumber);
+ // Ajoute les comptes enfants à la liste
+ accountXML(accountDTO.getAccountChildDTO(), accounts);
+ }*/
+ }
+
+ // Affiche le fichier xml
+ /*static void affiche() {
+ try {
+ XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
+ sortie.output(document, System.out);
+ } catch (java.io.IOException e) {
+ }
+ }*/
+
+ /**
+ * Permet d'enregistrer le fichier xml.
+ * @param fichier
+ */
+ /*static void enregistre(String fichier) {
+ try {
+ XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
+ sortie.output(document, new FileOutputStream(fichier));
+ } catch (java.io.IOException e) {
+ }
+ }*/
+
+ /**
+ * Permet d'importer un fichier de données au format xml dans Callao. Si le
+ * fichier n'est pas disponible, il est alors renvoyé un message d'erreur.
+ * @param file
+ * @return
+ */
+ public void importDatas(String file) {
+ /*if (log.isDebugEnabled()) {
+ log.debug("Load file XML : ");
+ }
+ String result = ServiceHelper.RESPOND_ERROR;
+ boolean existError = false;
+
+
+ // Chargement du fichier et construction du Dom
+ try {
+ // On crée une instance de SAXBuilder
+ SAXBuilder sxb = new SAXBuilder();
+ document = sxb.build(file);
+ } catch (IOException e) {
+ log.error("Erreur lors de la lecture du fichier " + e.getMessage());
+ e.printStackTrace();
+ } catch (JDOMException e) {
+ log.error("Erreur lors de la construction du fichier JDOM "
+ + e.getMessage());
+ e.printStackTrace();
+ }
+
+
+ // Ecriture dans la base de données
+ try {
+ // Recherche de la racine
+ Element racine = document.getRootElement();
+
+ // Journal
+ XPath requeteXpath = XPath.newInstance("//journal");
+ List results = requeteXpath.selectNodes(racine);
+
+ Iterator iter = results.iterator();
+ // Pour tous les journaux
+ while (iter.hasNext()) {
+ Element noeudCourant = (Element) iter.next();
+ // Recherche attributs
+ String label = noeudCourant.getAttribute("label").getValue();
+ String prefix = noeudCourant.getAttribute("prefix").getValue();
+ String description = noeudCourant.getAttribute("description")
+ .getValue();
+ // Création bdd
+ result = journalServiceImpl.createJournal(label, prefix,
+ description);
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+ }
+
+ // Account
+ requeteXpath = XPath.newInstance("//account");
+ results = requeteXpath.selectNodes(racine);
+
+ iter = results.iterator();
+ // Pour tous les accounts
+ while (iter.hasNext()) {
+ Element noeudCourant = (Element) iter.next();
+ // Recherche attributs
+ String label = noeudCourant.getAttribute("label").getValue();
+ String accountNumber = noeudCourant.getAttribute(
+ "accountNumber").getValue();
+ String masterAccount = noeudCourant.getAttribute(
+ "masterAccount").getValue();
+ String typeAccount = noeudCourant.getAttribute("type")
+ .getValue();
+ // Création bdd
+ result = accountServiceImpl.createAccount(accountNumber, label,
+ masterAccount, typeAccount);
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+ }
+
+ // Period
+ requeteXpath = XPath.newInstance("//period");
+ results = requeteXpath.selectNodes(racine);
+
+ iter = results.iterator();
+ // Pour tous les periods
+ while (iter.hasNext()) {
+ Element noeudCourant = (Element) iter.next();
+ // Recherche attributs
+ String idPeriod = noeudCourant.getAttribute("id").getValue();
+ int year = Integer.parseInt(noeudCourant.getAttribute(
+ "beginYear").getValue());
+ int month = Integer.parseInt(noeudCourant.getAttribute(
+ "beginMonth").getValue());
+ int day = Integer.parseInt(noeudCourant
+ .getAttribute("beginDay").getValue());
+ Date beginPeriod = new Date(year - 1900, month, day);
+ year = Integer.parseInt(noeudCourant.getAttribute("endYear")
+ .getValue());
+ month = Integer.parseInt(noeudCourant.getAttribute("endMonth")
+ .getValue());
+ day = Integer.parseInt(noeudCourant.getAttribute("endDay")
+ .getValue());
+ Date endPeriod = new Date(year - 1900, month, day);
+ // Création bdd
+ result = periodServiceImpl.createPeriod(beginPeriod, endPeriod,
+ false);
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+
+ // Transaction
+ requeteXpath = XPath
+ .newInstance("//transaction[@idTimeSpan=//timespan[@idPeriod='"
+ + idPeriod + "']/@id]");
+ List resultsTransaction = requeteXpath.selectNodes(racine);
+ Iterator iterTrans = resultsTransaction.iterator();
+ // Pour tous les transactions
+ while (iterTrans.hasNext()) {
+ Element noeudCourantTrans = (Element) iterTrans.next();
+
+ // Recherche attributs
+
+ // Id transaction XMl
+ String idTransactionXML = noeudCourantTrans.getAttribute(
+ "id").getValue();
+ // Recherche du journal en DTO
+ String idJournal = noeudCourantTrans.getAttribute(
+ "idJournal").getValue();
+ requeteXpath = XPath.newInstance("//journal[@id='"
+ + idJournal + "']/@label");
+ String label = requeteXpath.valueOf(racine);
+ JournalDTO journalDTO = journalServiceImpl
+ .searchJournalDTOWithLabel(label);
+ // Recherche du timeSpan en DTO
+ String idtimeSpan = noeudCourantTrans.getAttribute(
+ "idTimeSpan").getValue();
+ requeteXpath = XPath.newInstance("//timespan[@id='"
+ + idtimeSpan + "']/@beginYear");
+ year = Integer.parseInt(requeteXpath.valueOf(racine));
+ requeteXpath = XPath.newInstance("//timespan[@id='"
+ + idtimeSpan + "']/@beginMonth");
+ month = Integer.parseInt(requeteXpath.valueOf(racine));
+ requeteXpath = XPath.newInstance("//timespan[@id='"
+ + idtimeSpan + "']/@beginDay");
+ day = Integer.parseInt(requeteXpath.valueOf(racine));
+ Date beginTimeSpan = new Date(year - 1900, month, day);
+ TimeSpanDTO timeSpanDTO = timeSpanServiceImpl
+ .searchTimeSpanDTOByDate(beginTimeSpan);
+
+ // Création de transaction DTO
+ TransactionDTO transactionDTO = new TransactionDTO();
+ transactionDTO.setJournalDTO(journalDTO);
+ transactionDTO.setTimeSpanDTO(timeSpanDTO);
+ // entryDate
+ year = Integer.parseInt(noeudCourantTrans.getAttribute(
+ "entryDateYear").getValue());
+ month = Integer.parseInt(noeudCourantTrans.getAttribute(
+ "entryDateMonth").getValue());
+ day = Integer.parseInt(noeudCourantTrans.getAttribute(
+ "entryDateDay").getValue());
+ Date entryDate = new Date(year - 1900, month, day);
+ transactionDTO.setEntryDate(entryDate);
+ // voucherRef
+ String voucherRef = noeudCourantTrans.getAttribute(
+ "voucherRef").getValue();
+ transactionDTO.setVoucherRef(voucherRef);
+ // description
+ String description = noeudCourantTrans.getAttribute(
+ "description").getValue();
+ transactionDTO.setDescription(description);
+
+ // Création bdd
+ String idTransactionCallao = transactionServiceImpl
+ .createTransaction(transactionDTO);
+
+ // Entry
+ requeteXpath = XPath.newInstance("//entry[@idTransaction='"
+ + idTransactionXML + "']");
+ List resultsEntry = requeteXpath.selectNodes(racine);
+
+ Iterator iterEntry = resultsEntry.iterator();
+ // Pour tous les entries
+ while (iterEntry.hasNext()) {
+ Element noeudEntry = (Element) iterEntry.next();
+
+ // Recherche attributs
+
+ // Transaction DTO
+ transactionDTO = transactionServiceImpl
+ .searchTransactionDTO(idTransactionCallao);
+ // Account DTO
+ String idAccount = noeudEntry.getAttribute("idAccount")
+ .getValue();
+ requeteXpath = XPath.newInstance("//account[@id='"
+ + idAccount + "']/@accountNumber");
+ String accountNumber = requeteXpath.valueOf(racine);
+ AccountDTO accountDTO = accountServiceImpl
+ .searchAccountDTO(accountNumber);
+ // Entry DTO
+ EntryDTO entryDTO = new EntryDTO();
+ entryDTO.setAccountDTO(accountDTO);
+ entryDTO.setTransactionDTO(transactionDTO);
+ // Description
+ description = noeudEntry.getAttribute("description")
+ .getValue();
+ entryDTO.setDescription(description);
+ // Amount
+ String amount = noeudEntry.getAttribute("amount")
+ .getValue();
+ entryDTO.setAmount(amount);
+ // Debit
+ boolean debit = noeudEntry.getAttribute("debit")
+ .getValue().equals("true");
+ entryDTO.setDebit(debit);
+ // Lettering
+ String lettering = noeudEntry.getAttribute("lettering")
+ .getValue();
+ entryDTO.setLettering(lettering);
+ // Detail
+ String detail = noeudEntry.getAttribute("detail")
+ .getValue();
+ entryDTO.setDetail(detail);
+ // Création bdd
+ result = transactionServiceImpl.addEntry(entryDTO);
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+ }
+ }
+
+
+ // Bloquer Period
+ boolean lock = noeudCourant.getAttribute("locked").getValue()
+ .equals("true");
+ // Si la période est bloquée
+ if (lock) {
+ // Bloque tous ses timeSpans
+ result = periodServiceImpl
+ .blockAllTimeSpanOfPeriod(periodServiceImpl
+ .searchPeriodWithDate(beginPeriod));
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+ // bloque la période
+ result = periodServiceImpl.blockPeriod(periodServiceImpl
+ .searchPeriodWithDate(beginPeriod));
+
+ } else {
+ // On regarde si il y a besoin de bloquer les timeSpans
+ requeteXpath = XPath.newInstance("//timespan[@idPeriod = '"
+ + idPeriod + "']");
+ List resultsTimeSpan = requeteXpath.selectNodes(racine);
+ Iterator iterTimeSpan = resultsTimeSpan.iterator();
+ // Pour tous les timeSpans
+ while (iterTimeSpan.hasNext()) {
+ Element noeudCourantTimeSpan = (Element) iterTimeSpan
+ .next();
+ // Recherche attributs
+ year = Integer.parseInt(noeudCourantTimeSpan
+ .getAttribute("beginYear").getValue());
+ month = Integer.parseInt(noeudCourantTimeSpan
+ .getAttribute("beginMonth").getValue());
+ day = Integer.parseInt(noeudCourantTimeSpan
+ .getAttribute("beginDay").getValue());
+ Date beginTimeSpan = new Date(year - 1900, month, day);
+ lock = noeudCourantTimeSpan.getAttribute("locked")
+ .getValue().equals("true");
+ // Bloque le timeSpan
+ if (lock) {
+ timeSpanServiceImpl
+ .blockTimeSpan(timeSpanServiceImpl
+ .searchTimeSpanByDate(beginTimeSpan));
+ }
+ // Control erreur
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ existError = true;
+ }
+ }
+ }
+
+ }
+
+ } catch (JDOMException e) {
+ log.error("Erreur JDOM " + e.getMessage());
+ e.printStackTrace();
+ }
+
+ // Détection des erreurs
+ if (!existError) {
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ return result;*/
+ }
+
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/FilesServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/JournalServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/JournalServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/JournalServiceImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,470 @@
+/*
+ * *##% Callao JournalServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Journal;
+import org.chorem.lima.entity.JournalDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.entity.Transaction;
+import org.chorem.lima.entity.TransactionDAO;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Implémente la fonction multi-journal. Il est possible de créer ici le
+ * journal des ventes, le journal des achats, etc.
+ *
+ * @author Rémi Chapelet
+ */
+public class JournalServiceImpl {
+
+ private static final Log log = LogFactory.getLog(JournalServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ //private ConvertJournal convertJournal = new ConvertJournal();
+
+ public JournalServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Création d'un journal. Il peut être unique sur son label (au choix).
+ *
+ * @param journal journal
+ * @throws LimaException
+ */
+ public void createJournal(Journal journal) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+
+ // Si on souhaite avoir un journal unique avec son label
+
+ Journal journal = searchJournalWithLabel(label);
+ // Si un journal existe déjà avec ce label
+ if (journal != null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Un journal avec le label " + label
+ + " existe déjà !");
+ }
+ result = ServiceHelper.JOURNAL_DOUBLE;
+ } else {
+ // Creation du journal
+ Journal newJournal = journalDAO.create();
+ newJournal.setLabel(label);
+ newJournal.setPrefix(prefix);
+ newJournal.setDescription(description);
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;*/
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // test si un journal de ce nom existe deja
+ JournalDAO journalDAO = LimaCallaoDAOHelper.getJournalDAO(transaction);
+ Journal existingJournal = journalDAO.findByLabel(journal.getLabel());
+ if (existingJournal != null) {
+ throw new LimaBusinessException(_("An journal already exists with this label : %s", journal.getLabel()));
+ }
+
+ // creation du journal
+ journalDAO.create(journal);
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Création d'un journal à partir de son DTO.
+ * @param journalDTO Journal au format DTO.
+ * @return
+ *
+ public String createJournal(JournalDTO journalDTO) {
+ String result;
+ result = createJournal(journalDTO.getLabel(), journalDTO.getPrefix(),
+ journalDTO.getDescription());
+ return result;
+ }*/
+
+ public List<Journal> getAllJournal() throws LimaException {
+ /*List<JournalDTO> listJournalDTO = new ArrayList<JournalDTO>();
+
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+ // Creation du journal
+ List<Journal> listJournal = journalDAO.findAll();
+ // Pour chaque journal, on le transforme en DTO
+ for (Journal journal : listJournal) {
+ // Converti en DTO
+ JournalDTO journalDTO = convertJournal
+ .journalEntityToDto(journal);
+ // Ajoute à la liste
+ listJournalDTO.add(journalDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listJournalDTO;*/
+
+ List<Journal> journalsList = new ArrayList<Journal>();
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // test si un journal de ce nom existe deja
+ JournalDAO journalDAO = LimaCallaoDAOHelper.getJournalDAO(transaction);
+ List<Journal> journals = journalDAO.findAll();
+ journalsList.addAll(journals);
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ }
+ }
+
+ return journalsList;
+ }
+
+ /*
+ * Permet de rechercher un journal existant à partir de son label.
+ * ATTENTION : il est possible que plusieurs journaux existent avec ce
+ * même label. La méthode renvoie le premier trouvé.
+ * @param prefix préfixe du journal recherché
+ * @return
+ *
+ public Journal searchJournalWithLabel(String label) {
+ Journal journalResult = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+ // Creation du journal
+ journalResult = journalDAO.findByLabel(label);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return journalResult;
+ }*/
+
+ /*
+ * Permet de rechercher un journal existant à partir du label.
+ * Le journal recherché est converti automatiquement en format DTO.
+ * @param prefix préfixe du journal recherché
+ * @return
+ *
+ public JournalDTO searchJournalDTOWithLabel(String label) {
+ Journal journal = searchJournalWithLabel(label);
+ JournalDTO journalDTO = convertJournal.journalEntityToDto(journal);
+ return journalDTO;
+ }*/
+
+ /*
+ * Permet de rechercher un journal unique identifé par son topiaId.
+ * @param topiaId identifiant du journal recherché
+ * @return
+ *
+ public Journal searchJournalWithTopiaId(String topiaId) {
+ Journal journalResult = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+ // Creation du journal
+ journalResult = journalDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return journalResult;
+ }*/
+
+ /*
+ * Permet de rechercher un journal existant à partir du topiaId.
+ * Le journal recherché est converti automatiquement en format DTO.
+ * @param prefix préfixe du journal recherché
+ * @return
+ *
+ public JournalDTO searchJournalDTOWithTopiaId(String topiaId) {
+ Journal journal = searchJournalWithTopiaId(topiaId);
+ JournalDTO journalDTO = convertJournal.journalEntityToDto(journal);
+ return journalDTO;
+ }*/
+
+ /*
+ * Permet de modifier un journal.
+ * @param label
+ * @param prefix
+ * @return
+ *
+ public String modifyJournal(String topiaId, String label, String prefix,
+ String description) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ Journal journalModify = searchJournalWithTopiaId(topiaId);
+ // Si le journal n'existe pas
+ if (journalModify == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le journal " + label + " n'existe pas !");
+ }
+ result = ServiceHelper.JOURNAL_NOT_EXIST;
+ } else // Sinon on modifie le journal
+ {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+ // Modifie le journal
+ journalModify.setPrefix(prefix);
+ journalModify.setDescription(description);
+ journalDAO.update(journalModify);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /**
+ * Permet d'effacer un journal dans la base de données.
+ *
+ * ATTENTION : si un journal est associé avec des transactions, il est alors
+ * impossible de supprimer celui-ci.
+ *
+ * @param prefix préfixe du journal à supprimer
+ * @return
+ * @throws LimaException
+ */
+ public void removeJournal(Journal journal) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ Journal journalDelete = searchJournalWithTopiaId(topiaId);
+ // Si le journal n'existe pas
+ if (journalDelete == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le journal " + topiaId + " n'existe pas !");
+ }
+ result = ServiceHelper.JOURNAL_NOT_EXIST;
+ } else // Sinon on efface le journal
+ {
+
+ // Vérifie si une transaction n'appartient pas à ce journal.
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche au moins une transaction avec ce journal.
+ Transaction transaction = transactionDAO
+ .findByJournal(journalDelete);
+ // Il existe au moins une transaction
+ if (transaction != null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le journal " + topiaId
+ + " possède des transactions comptables !");
+ }
+ result = ServiceHelper.JOURNAL_WITH_TRANSACTIONS;
+ } else {
+
+ // Efface le journal
+ // Chargement du DAO
+ JournalDAO journalDAO = LimaCallaoDAOHelper
+ .getJournalDAO(topiaContext);
+ // Supprime le journal
+ journalDAO.delete(journalDelete);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;*/
+
+ TopiaContext topiaTransaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ topiaTransaction = rootContext.beginTransaction();
+
+ // Vérifie si une transaction n'appartient pas à ce journal.
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
+ Transaction transaction = transactionDAO.findByJournal(journal);
+ if (transaction != null) {
+ throw new LimaBusinessException("Can't delete journal with transactions");
+ }
+
+ // test si un journal de ce nom existe deja
+ JournalDAO journalDAO = LimaCallaoDAOHelper.getJournalDAO(topiaTransaction);
+ journalDAO.delete(journal);
+
+ // commit
+ topiaTransaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ if (topiaTransaction != null) {
+ try {
+ topiaTransaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ finally {
+ if (topiaTransaction != null) {
+ try {
+ topiaTransaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create journal", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Permet d'effacer un journal dans la base de données.
+ * ATTENTION : si un journal est associé avec des transactions, il est alors
+ * impossible de supprimer celui-ci.
+ * @param journalDTO journal au format DTO à supprimer
+ * @return
+ *
+ public String removeJournal(JournalDTO journalDTO) {
+ String result = removeJournal(journalDTO.getId());
+ return result;
+ }*/
+
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/JournalServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,54 @@
+/* *##% Lima
+ * Copyright (C) 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+/**
+ * Lima business exception throw by a business service method
+ * that cannot execute successfully.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class LimaBusinessException extends LimaException {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -6876236663940184462L;
+
+ /**
+ * Constructs a new exception with the specified detail message.
+ *
+ * @param message message
+ */
+ public LimaBusinessException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a new exception with the specified detail message and cause.
+ *
+ * @param message message
+ * @param cause cause
+ */
+ public LimaBusinessException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/LogServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LogServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LogServiceImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,364 @@
+/*
+ * *##% Callao LogServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.EntryLog;
+import org.chorem.lima.entity.EntryLogDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Permet d'ajouter des logs au systeme.
+ *
+ * ATTENTION on ne peut supprimer un log.
+ *
+ * @author Rémi Chapelet
+ */
+public class LogServiceImpl { //implements LogService {
+
+ /** log */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(LogServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+
+ public LogServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Création d'un log dans le systeme.
+ *
+ * @param entryLog date de creation du log
+ * @throws LimaException
+ */
+ public void addLog(EntryLog entryLog) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryLogDAO logDAO = LimaCallaoDAOHelper.getEntryLogDAO(topiaContext);
+ // Creation du log
+ EntryLog newlog = logDAO.create();
+ newlog.setLogDate(logDate);
+ newlog.setTransDate(transDate);
+ newlog.setVoucherRef(voucherRef);
+ newlog.setType(type);
+ newlog.setTransDesc(transDesc);
+ newlog.setEntryDesc(entryDesc);
+ newlog.setAmount(amount);
+ newlog.setDebit(debit);
+ newlog.setLettering(lettering);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ // Affichage pour les logs
+ String topiaId = newlog.getTopiaId();
+ if (log.isInfoEnabled()) {
+ log.info("Log created: "+ topiaId);
+ }
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;*/
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // creation
+ EntryLogDAO entryLogDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(transaction);
+ entryLogDAO.create(entryLog);
+
+ // commit
+ transaction.commitTransaction();
+ } catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create entry log", ex);
+ } finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create entry log", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Création d'un log à partir d'un log DTO.
+ * @param logDTO log en format DTO qu'on souhaite créer
+ * @return
+ *
+ public String addLog (LogDTO logDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Vérifie si logDTO existe
+ if (logDTO != null)
+ {
+ result = addLog(logDTO.getLogDate(),logDTO.getTransDate(),logDTO.getType(),
+ logDTO.getVoucherRef(),logDTO.getTransDesc(),logDTO.getEntryDesc(),
+ logDTO.getAmount(),logDTO.isDebit(),logDTO.getLettering());
+ }
+ return result;
+ }*/
+
+ /**
+ * Recherche tous les logs dans la base de donnees.
+ *
+ * @return la liste des logs
+ * @throws LimaException
+ */
+ public List<EntryLog> listeAllLog() throws LimaException {
+ /*List<EntryLog> listelog = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryLogDAO logDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(topiaContext);
+ // recherche des log
+ listelog = logDAO.findAll();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ if (log.isInfoEnabled()) {
+ log.info("Search all logs");
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listelog;*/
+
+ List<EntryLog> entryLogsList = new ArrayList<EntryLog>();
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // creation
+ EntryLogDAO entryLogDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(transaction);
+ List<EntryLog> entryLogs = entryLogDAO.findAll();
+ entryLogsList.addAll(entryLogs);
+
+ // commit
+ transaction.commitTransaction();
+ } catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", ex);
+ }
+ throw new LimaException("Can't create entry log", ex);
+ } finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't create entry log", ex);
+ }
+ }
+ }
+
+ return entryLogsList;
+ }
+
+ /*
+ * Permet de renvoyer tous les logs au format DTO.
+ * @return
+ *
+ public List<LogDTO> listeAllLogDTO() {
+ List<LogDTO> listLogDTO = new ArrayList<LogDTO>();
+ // On recherche tous les logs.
+ List<EntryLog> listLog = listeAllLog();
+ // Pour chaque log, on le converti en logDTO et on l'ajoute à la nouvelle liste de DTO
+ for (EntryLog log : listLog) {
+ // conerti de l'entity en DTO
+ LogDTO logDTO = convertLog.logEntityToDto(log);
+ // Ajoute à la liste des logs DTO
+ listLogDTO.add(logDTO);
+ }
+ return listLogDTO;
+ }*/
+
+ /*
+ * Renvoie une liste de tous les logs suivant la date de creation
+ * @param datecreate date de creation des logs recherchés
+ * @return une liste des logs trouves
+ *
+ public List<EntryLog> searchLogWithDateCreate(Date dateCreate) {
+ List<EntryLog> listelog = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryLogDAO logDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(topiaContext);
+ // recherche des log
+ listelog = logDAO.findAllByLogDate(dateCreate);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ if (log.isInfoEnabled()) {
+ log.info("Log(s) find : " + listelog.size() + "log(s)");
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listelog;
+ }*/
+
+ /*
+ * Permet de rechercher tous les logs suivant la date de création, c'est à
+ * dire de l'opération effectuée sur une entry à un jour précis, et qui a
+ * déclenchée automatiquement une création de log.
+ * La méthode renvoie sous forme de liste, en convertissant les objets
+ * entitys en DTO.
+ * @param dateCreate date de création des logs recherchés
+ * @return
+ *
+ public List<LogDTO> searchLogDTOWithDateCreate(Date dateCreate) {
+ List<LogDTO> listLogDTO = new ArrayList<LogDTO>();
+ // On recherche tous les logs suivant la date de création.
+ List<EntryLog> listLog = searchLogWithDateCreate(dateCreate);
+ // Pour chaque log, on le converti en logDTO et on l'ajoute à la nouvelle liste de DTO
+ for (EntryLog log : listLog) {
+ // conerti de l'entity en DTO
+ LogDTO logDTO = convertLog.logEntityToDto(log);
+ // Ajoute à la liste des logs DTO
+ listLogDTO.add(logDTO);
+ }
+ return listLogDTO;
+ }*/
+
+ /*
+ * Recherche un log avec son identifiant topiaId.
+ * @param topiaId identifiant d'un log
+ * @return
+ *
+ public EntryLog searchLogWithTopiaId(String topiaId) {
+ EntryLog logSearch = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryLogDAO logDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(topiaContext);
+ // Creation du journal
+ logSearch = logDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return logSearch;
+ }*/
+
+ /*
+ * Efface un log : uniquement utilisé pour supprimer les logs dans les tests
+ * unitaires.
+ * @param topiaId identifiant du log à supprimer
+ * @return
+ *
+ public String removeLog(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ EntryLog logDelete = searchLogWithTopiaId(topiaId);
+ // Si le log n'existe pas
+ if (logDelete == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le log " + topiaId + " n'existe pas !");
+ }
+ } else // Sinon on efface le log
+ {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryLogDAO logDAO = LimaCallaoDAOHelper
+ .getEntryLogDAO(topiaContext);
+ // Supprime le log
+ logDAO.delete(logDelete);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de supprimer un log à partir de son DTO.
+ * @param logDTO log à supprimer
+ * @return
+ *
+ public String removeLog(LogDTO logDTO) {
+ String result = removeLog(logDTO.getId());
+ return result;
+ }*/
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/LogServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/PeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/PeriodServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/PeriodServiceImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,504 @@
+/*
+ * *##% Callao PeriodServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Period;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Gestion des périodes.
+ * Chaque période doit posséder 12 timespans mensuels.
+ * Une période ne peut être supprimée et débloquée.
+ *
+ * @author Rémi Chapelet
+ */
+public class PeriodServiceImpl { //implements PeriodService {
+
+ private static final Log log = LogFactory.getLog(PeriodServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
+
+ public PeriodServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Permet de créer une période principale. Elle a une durée de un an,
+ * composées de 12 périodes mensuelles. Elle correspond à l'exercice
+ * comptable. Pour créer une nouvelle période, la précédente doit être
+ * obligatoirement clôturée.
+ * @param beginTimeSpan date début de période
+ * @param endTimeSpan date fin de période
+ * @param lock Vrai si la période est bloquée
+ * @return
+ */
+ public void createPeriod(Period period /*Date beginTimeSpan, Date endTimeSpan, boolean lock*/) {
+ /*// Par défaut lock est à false
+ lock = false;
+ String result = ServiceHelper.RESPOND_ERROR;
+
+ try {
+ boolean correctPeriod = false;
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Creation de la periodDate
+ PeriodDates newPeriod = new PeriodDates(beginTimeSpan, endTimeSpan);
+
+ // Creation de la période
+ Period period = periodDAO.create();
+ period.setBeginPeriod(newPeriod.getFromDate());
+ period.setEndPeriod(newPeriod.getThruDate());
+ period.setLocked(lock);
+ // Vérification si la période est correcte
+ correctPeriod = isCorrectPeriod(period);
+ if (correctPeriod) {
+ // Si elle est correcte : Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Ajout exercice du " + beginTimeSpan.toString()
+ + " au " + endTimeSpan.toString());
+ }
+
+ //Ajout des timeSpans mensuels
+ //Par défaut, il prend seulement la date beginTimeSpan, et calcule
+ //la date de fin, c'est pourquoi il est laissé deux fois "beginTimeSpan"
+ TimeSpanServiceImpl timeSpanImpl = new TimeSpanServiceImpl();
+ boolean stop = false; // En cas d'erreur lors de la création d'un timeSpan.
+
+ List<Date> monthList = newPeriod.getMonths();
+
+ int max = monthList.size();
+ log.debug("la periode fait:" + max);
+ for (int i = 0; i < max; i++) {
+ // Création timeSpan
+ result = timeSpanImpl.createTimeSpan(monthList.get(i),
+ monthList.get(i), period, false);
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ stop = true;
+ if (log.isErrorEnabled()) {
+ log.error("Erreur lors de la création des " + max
+ + " timeSpans");
+ }
+ result = ServiceHelper.PERIOD_CREATE_TIMESPANS;
+ }
+ // Supprimer la periode si stop = true
+ }
+ if (stop == false) {
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result; */
+ }
+
+ /*
+ * Permet de créer une période à partir d'une période DTO.
+ * @param periodDTO période à créer au format DTO.
+ * @return
+ *
+ public String createPeriod(PeriodDTO periodDTO) {
+ String result = createPeriod(periodDTO.getBeginPeriod(), periodDTO
+ .getEndPeriod(), false);
+ // Tous les timeSpans sont automatiquement créés avec la méthode createPeriod
+ return result;
+ }*/
+
+ /*
+ * Permet de vérifier si la période est correcte (aucun chevauchement avec
+ * les autres périodes, période(s) précédente(s) bloquée(s), formée de 1 à 24
+ * mois).
+ * @param period période à tester si elle est correcte
+ * @return
+ *
+ private boolean isCorrectPeriod(Period period) {
+ // Calcul du nombre de mois pour que la période soit valide (12 mois)
+ int number_months = dateUtil.numberOfMonths(period.getBeginPeriod(),
+ period.getEndPeriod());
+ boolean result = true;
+
+ if (number_months == 0 && number_months >= 24) // Periode de 1mois a 24 mois
+ {
+ if (log.isErrorEnabled()) {
+ log.error("Période du "
+ + period.getBeginPeriod()
+ + " au "
+ + period.getEndPeriod()
+ + " : L'exercice doit faire au minimum 1 mois et au maximum 24 mois");
+ }
+ result = false;
+ } else {
+ // Période(s) précédente(s) bloquée(s).
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Recherche les périodes qui ne sont pas bloquées.
+ List<Period> listePeriod = periodDAO.findAllByLocked(false);
+ // Recherche la dernière période, les dates doivent se suivre
+ Date date_search = period.getBeginPeriod();
+ Period previousPeriod = periodDAO.findByEndPeriod(dateUtil
+ .previousDay(date_search));
+ // Nombre de périodes dans la base
+ int number_period = periodDAO.findAll().size();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ // Si il y a au moins une période trouvée
+ if (!(listePeriod.isEmpty())) {
+ if (log.isErrorEnabled()) {
+ log.error("Il existe au moins une période précédente non bloquée !");
+ }
+ result = false;
+ }
+ // Si la période précédente correspond au jour précédent
+ // et vérifie si ce n'est pas la première période
+ if (previousPeriod == null && number_period != 0) {
+ if (log.isErrorEnabled()) {
+ log.error("Votre période doit être collée "
+ + "aux autres périodes !"
+ + date_search.toString() + " PPP "
+ + dateUtil.previousDay(date_search).toString());
+ }
+ result = false;
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Cette méthode permet de bloquer une période. Elle doit vérifier que
+ * tous les timeSpans mensuels sont bloqués.
+ * @param
+ * @return
+ *
+ public String blockPeriod(Period period) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // La période ne doit pas être nulle
+ if (period != null) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Recherche tous les timeSpans de la période non bloquées
+ List<TimeSpan> listeTimeSpan = timeSpanDAO
+ .findAllByPeriod(period);
+ boolean existTimeSpanNotBlock = false;
+ for (TimeSpan timeSpan : listeTimeSpan) {
+ // Si timeSpan non bloqué
+ if (!timeSpan.getLocked()) {
+ existTimeSpanNotBlock = true;
+ if (log.isErrorEnabled()) {
+ log.error("Le timeSpan du "
+ + timeSpan.getBeginTimeSpan().toString()
+ + " au "
+ + timeSpan.getEndTimeSpan().toString()
+ + " non bloqué !");
+ }
+ result = ServiceHelper.PERIOD_TIMESPAN_NOT_BLOCK;
+ }
+ }
+ // Si il n'existe pas de timeSpan non bloqué
+ if (!(existTimeSpanNotBlock)) {
+ // Bloque la période
+ period.setLocked(true);
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ periodDAO.update(period);
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ if (log.isInfoEnabled()) {
+ log.info("Période "
+ + period.getBeginPeriod().toString() + " au "
+ + period.getEndPeriod().toString()
+ + " bloquée avec succès.");
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de bloquer une période. Avec la périodeDTO passée en paramètre, on
+ * effectue une recherche avec la date de début pour récupérer la période
+ * dans la base de données. Il est possible de l'identifier avec son topiaId,
+ * mais il y a plus de risque que cette mentien ne soit pas renseignée dans
+ * l'objet periodDTO.
+ * @param periodDTO
+ * @return
+ *
+ public String blockPeriod(PeriodDTO periodDTO) {
+ // Recherche de la période
+ Period period = searchPeriodWithDate(periodDTO.getBeginPeriod());
+ String result = blockPeriod(period);
+ return result;
+ }*/
+
+ /*
+ * Permet de bloquer TOUS les timeSpans de la période
+ * @param period
+ * @return
+ *
+ public String blockAllTimeSpanOfPeriod(Period period) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ if (period == null) {
+ if (log.isErrorEnabled()) {
+ log.error("La période ne peut bloquer ses périodes mensuelles, "
+ + "il faut une période en entrée.");
+ }
+ } else {
+ // On bloque chaque timeSpan
+ boolean ErrorBlockTimeSpan = false;
+ List<TimeSpanDTO> listTimeSpanDTO = timeSpanServiceImpl
+ .searchListTimeSpanDTO(period);
+ // tri la liste des timeSpans dans l'ordre croissant des dates
+ Collections.sort(listTimeSpanDTO);
+ for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
+ result = timeSpanServiceImpl.blockTimeSpan(timeSpanDTO);
+ if (result.equals(ServiceHelper.RESPOND_ERROR)) {
+ ErrorBlockTimeSpan = true;
+ }
+ }
+ // Si il n'y a pas eu d'erreurs pour bloquer les timespans
+ if (!ErrorBlockTimeSpan) {
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ if (log.isErrorEnabled()) {
+ log.error("Impossible de bloquer tous les timeSpans.");
+ }
+ result = ServiceHelper.PERIOD_ALL_TIMESPAN;
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Cette méthode est semblable à searchPeriodWithDateFirst. Elle permet
+ * de rechercher une période sans forcément connaître la date de départ. On
+ * donne une date quelconque, et elle retourne la période correspondante.
+ * @param d
+ * @return
+ *
+ public Period searchPeriodWithDate(Date d) {
+ Period period = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Recherche de toutes les périodes
+ List<Period> listePeriod = periodDAO.findAll();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ // Recherche de la période
+ for (Period periodSearch : listePeriod) {
+ // Recherche si la date d est entre la date de début et fin de la période
+ boolean periodBetweenDate = dateUtil.betweenDate(d,
+ periodSearch.getBeginPeriod(), periodSearch
+ .getEndPeriod());
+ // Si la date est comprise dans les limites de la période
+ if (periodBetweenDate) {
+ period = periodSearch;
+ }
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return period;
+ }*/
+
+ /*
+ * Permet de rechercher une période au format DTO avec une date. Cette date
+ * peut être quelconque (pas obligatoire d'être le premier jour de la période
+ * par exemple).
+ * @param d date comprise dans la période qu'on souhaite rechercher
+ * @return
+ *
+ public PeriodDTO searchPeriodDTOWithDate(Date d) {
+ Period period = searchPeriodWithDate(d);
+ // Converti la période en PeriodDTO
+ PeriodDTO periodDTO = convertPeriod.periodEntityToDto(period);
+ return periodDTO;
+ }*/
+
+ /*
+ * Permet de renvoyer tous les périodes en format DTO, avec tous les timeSpans
+ * en format DTO également.
+ * @return
+ *
+ public List<PeriodDTO> getAllPeriod() {
+ ArrayList<PeriodDTO> listAllPeriodDTO = new ArrayList<PeriodDTO>();
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Recherche de toutes les périodes
+ List<Period> listePeriod = periodDAO.findAll();
+ // Transforme les périodes en DTO
+ for (Period period : listePeriod) {
+ PeriodDTO periodDTO = convertPeriod.periodEntityToDto(period);
+ listAllPeriodDTO.add(periodDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listAllPeriodDTO;
+ }*/
+
+ /*
+ * Recherche une période précise, avec son identifiant topiaId.
+ * @param topiaId identifiant de la période
+ * @return
+ *
+ public Period searchPeriodWithTopiaId(String topiaId) {
+ Period periodSearch = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Creation du journal
+ periodSearch = periodDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return periodSearch;
+ }*/
+
+
+ /*
+ * Efface une période dans la base de données. Tous les timeSpans sont
+ * également effacés. Cette méthode est uniquement utilisée pour les tests
+ * unitaires.
+ * @param period
+ * @return
+ *
+ public String removePeriod(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ Period periodDelete = searchPeriodWithTopiaId(topiaId);
+ // Si la période n'existe pas
+ if (periodDelete == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("La période " + topiaId + " n'existe pas !");
+ }
+ result = ServiceHelper.PERIOD_NOT_EXIST;
+ } else // Sinon on efface la période
+ {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ PeriodDAO periodDAO = LimaCallaoDAOHelper
+ .getPeriodDAO(topiaContext);
+ // Débloque la période
+ periodDelete.setLocked(false);
+ // Mise à jour dans la bdd
+ periodDAO.update(periodDelete);
+ // Création BDD
+ topiaContext.commitTransaction();
+
+ // Supprime les timeSpans de la période
+ List<TimeSpanDTO> listTimeSpanDTO = timeSpanServiceImpl
+ .searchListTimeSpanDTO(periodDelete);
+ // tri la liste des timeSpans dans l'ordre décroissant des dates
+ Collections.sort(listTimeSpanDTO, Collections.reverseOrder());
+ // Débloque les timeSpans
+ for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
+ TimeSpan timeSpan = timeSpanServiceImpl
+ .searchTimeSpanByDate(timeSpanDTO);
+ // Si le timeSpan est bloqué
+ if (timeSpanDTO.isLocked()) {
+ // débloque le timeSpan
+ timeSpanServiceImpl.unblockTimeSpan(timeSpan);
+ }
+ }
+ // Efface les timeSpans
+ for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
+ TimeSpan timeSpan = timeSpanServiceImpl
+ .searchTimeSpanByDate(timeSpanDTO);
+ // efface le timeSpan
+ timeSpanServiceImpl.removeTimeSpan(timeSpan);
+ }
+
+
+ //Supprime la période
+ periodDAO.delete(periodDelete);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'effacer une période au format DTO.
+ * @param periodDTO la période à supprimer
+ * @return
+ *
+ public String removePeriod(PeriodDTO periodDTO) {
+ String result = removePeriod(periodDTO.getId());
+ return result;
+ }*/
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/PeriodServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,61 @@
+package org.chorem.lima.business;
+
+import org.nuiton.topia.TopiaContext;
+
+public class ReportServiceImpl { //implements ReportService {
+
+ //@Override
+ public String generateAccount(String number, String amount, String label) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String generateBalanceSheet(String period) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String generateCashFlowStatement(String period) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String generateGeneralLedger(String period) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String generateIncomeStatement(String period) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String generateJournal(String type, String period) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public String[] getMethods() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //@Override
+ public void destroy() {
+ // TODO Auto-generated method stub
+
+ }
+
+ //@Override
+ public void init(TopiaContext arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/TimeSpanServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/TimeSpanServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/TimeSpanServiceImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,533 @@
+/*
+ * *##% Callao TimeSpanServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.TimeSpan;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Gestion des périodes intermédiaires durant l'exercice.
+ * Chaque timeSpan sera fixe, et devra correspondre à un mois complet.
+ *
+ * @author Rémi Chapelet
+ */
+public class TimeSpanServiceImpl { //implements TimeSpanService {
+
+ /** log */
+ private static final Log log = LogFactory.getLog(TimeSpanServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+
+ public TimeSpanServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Création d'une période timeSpan mensuelle avec une date de début et de fin. Une période
+ * peut être bloquée ou non.
+ * @param beginTimeSpan date de début de période
+ * @param endTimeSpan date de fin de période
+ * @param locked est à vrai si la période doit être bloquée.
+ * @return
+ */
+ public void createTimeSpan(TimeSpan timeSpan /*Date beginTimeSpan, Date endTimeSpan,
+ Period period, boolean locked*/) {
+/*
+ // timeSpan correspond à une période mensuelle.
+ // La fonction va donc prendre seulement pour date de référence la
+ // date beginTimeSpan. Elle calcule automatiquement la date de fin
+ // suivant le mois.
+ DateUtil dateutil = new DateUtil();
+ // Initialise la date de début au premier du mois
+ beginTimeSpan = dateutil.InitDateFirstDayMonth(beginTimeSpan);
+ // Initialise la date de fin au dernier du mois
+ endTimeSpan = dateutil.InitDateEndDayMonth(beginTimeSpan);
+ if (log.isInfoEnabled()) {
+ log.info("Nouveau timeSpan du " + beginTimeSpan.toString() + " au "
+ + endTimeSpan.toString());
+ }
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Creation du timespan
+ TimeSpan newtimeSpan = timeSpanDAO.create();
+ newtimeSpan.setBeginTimeSpan(beginTimeSpan);
+ newtimeSpan.setEndTimeSpan(endTimeSpan);
+ newtimeSpan.setLocked(locked);
+ newtimeSpan.setPeriod(period);
+ // Création BDD
+ topiaContext.commitTransaction();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ if (log.isInfoEnabled()) {
+ log.info("Ajout avec succes du timeSpan");
+ }
+ return ServiceHelper.RESPOND_SUCCESS;
+ } catch (TopiaException e) {
+ log.error(e);
+ return ServiceHelper.RESPOND_ERROR;
+ }*/
+ }
+
+ /*
+ * Permet de trouver un timespan directement avec une date. La date peut
+ * être quelconque. Exemple : d = 17 sept 2000, renvoie la période du
+ * 1 sept au 30 sept 2000.
+ * @param d
+ * @return
+ *
+ public TimeSpan searchTimeSpanByDate(Date d) {
+ TimeSpan timeSpan = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Par précaution, on initialise la date au debut du mois
+ DateUtil dateutil = new DateUtil();
+ // Recherche du timeSpan
+ Date searchDate = dateutil.InitDateFirstDayMonth(d);
+ timeSpan = timeSpanDAO.findByBeginTimeSpan(searchDate);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return timeSpan;
+ }*/
+
+ /*
+ * Recherche un timeSpan précis, avec sa date de création.
+ * @param timeSpanDTO timeSpan au format DTO qu'on recherche
+ * @return
+ *
+ public TimeSpan searchTimeSpanByDate(TimeSpanDTO timeSpanDTO) {
+ TimeSpan timeSpan = searchTimeSpanByDate(timeSpanDTO.getBeginTimeSpan());
+ return timeSpan;
+ }*/
+
+ /*
+ * Recherche un timeSpan UNIQUE. Celui est identifié par son topiaId.
+ * @param topiaId Identifiant du timeSpan recherché
+ * @return
+ *
+ public TimeSpan searchTimeSpanWithTopiaId(String topiaId) {
+ TimeSpan timeSpan = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Recherche du timeSpan
+ timeSpan = timeSpanDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return timeSpan;
+ }*/
+
+ /*
+ * Permet de rechercher un timeSpan à l'aide d'une date. Il fait appel
+ * à la méthode searchTimeSpanByDate.
+ * La méthode renvoie un objet DTO.
+ * @param d
+ * @return
+ *
+ public TimeSpanDTO searchTimeSpanDTOByDate(Date d) {
+ TimeSpan timeSpan = searchTimeSpanByDate(d);
+ TimeSpanDTO timeSpanDTO = convertTimeSpan.timeSpanEntityToDto(timeSpan);
+ return timeSpanDTO;
+ }*/
+
+ /*
+ * Permet de faire une recherche de tous les timeSpans d'une période.
+ * @param period
+ * @return
+ *
+ public List<TimeSpan> searchListTimeSpan(Period period) {
+ List<TimeSpan> listTimeSpan = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Recherche les timeSpans avec cette période
+ listTimeSpan = timeSpanDAO.findAllByPeriod(period);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listTimeSpan;
+ }*/
+
+ /*
+ * Permet de rechercher tous les timeSpans suivant une période donnée.
+ * Chaque timeSpan est converti ensuite en DTO.
+ * @param period
+ * @return
+ *
+ public List<TimeSpanDTO> searchListTimeSpanDTO(Period period) {
+ List<TimeSpanDTO> listTimeSpanDTO = new ArrayList<TimeSpanDTO>();
+ List<TimeSpan> listTimeSpan = searchListTimeSpan(period);
+ for (TimeSpan timeSpan : listTimeSpan) {
+ TimeSpanDTO timeSpanDTO = convertTimeSpan
+ .timeSpanEntityToDto(timeSpan);
+ listTimeSpanDTO.add(timeSpanDTO);
+ }
+ return listTimeSpanDTO;
+ }*/
+
+ /*
+ * Permet de bloquer un timespan, celle-ci ne doit pas être bloquée.
+ * La fonction doit s'assurer que les timeSpans précédents doivent être
+ * bloqués.
+ * Les transactions doivent être équilibrées
+ * @param timespan période qui doit être fermée
+ * @param period période (12 smois)
+ *
+ public String blockTimeSpan(TimeSpan timespan) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Si la période n'est pas déjà fermée.
+ if (timespan.getLocked()) {
+ if (log.isInfoEnabled()) {
+ log.info("Timespan deja bloqué !");
+ }
+ } else {
+ Period period = getPeriodWithTimeSpan(timespan);
+ if (period.getLocked()) {
+ if (log.isErrorEnabled()) {
+ log.error("La période du timespan est bloquée !");
+ }
+ } else {
+ // Vérifie si tous les timeSpans précédents sont bloqués
+ boolean AllTimeSpanBlock = alltimeSpanBlocked(timespan, period);
+ if (AllTimeSpanBlock) {
+ // Enregistrement dans la base de données
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext
+ .beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+
+ // Vérifie si les transactons sont équilibrées
+ List<Transaction> listTransaction = transactionServiceImpl
+ .searchListTransactionWithTimeSpan(timespan);
+ boolean isTransactionBalanced = true;
+ boolean existTransactionNotBalanced = false;
+ for (Transaction transaction : listTransaction) {
+ isTransactionBalanced = transactionServiceImpl
+ .isTransactionBalanced(transaction);
+ if (!isTransactionBalanced) {
+ if (log.isInfoEnabled()) {
+ log.info("La transaction n'est pas bloquée.");
+ }
+ existTransactionNotBalanced = true;
+ }
+ }
+ if (!existTransactionNotBalanced) {
+ // Bloque la période
+ timespan.setLocked(true);
+ // Mise à jour de timespan dans la BDD
+ timeSpanDAO.update(timespan);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Timespan bloqué avec succès");
+ }
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ result = ServiceHelper.TRANSACTION_NOT_BALANCED;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ } else {
+ if (log.isErrorEnabled()) {
+ log.error("Il existe un ou plusieurs timespans précédents"
+ + " non bloqués.");
+ }
+ result = ServiceHelper.TIMESPAN_PREC_NOT_BLOCK;
+ }
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de bloquer une période au format DTO.
+ *
+ * @param timespanDTO
+ * @return
+ *
+ public String blockTimeSpan(TimeSpanDTO timespanDTO) {
+ return blockTimeSpan(searchTimeSpanByDate(timespanDTO));
+ }*/
+
+ /*
+ * Permet de débloquer un timespan, à condition que les timespans suivants
+ * celui-ci soient bien débloqués.
+ * @param timespan
+ * @param period
+ * @return
+ *
+ public String unblockTimeSpan(TimeSpan timespan) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Si le timspan n'est pas bloqué
+ if (!timespan.getLocked()) {
+ if (log.isWarnEnabled()) {
+ log.warn("Timespan non bloqué !");
+ }
+ } else {
+ Period period = getPeriodWithTimeSpan(timespan);
+ if (period.getLocked()) {
+ if (log.isErrorEnabled()) {
+ log.error("La période du timespan est bloquée !");
+ }
+ } else {
+ boolean NextTimeSpanUnblock = nextTimeSpanUnblock(timespan,
+ period);
+ // Si aucun timespan suivant bloqué
+ if (NextTimeSpanUnblock) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext
+ .beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // débloque la période
+ timespan.setLocked(false);
+ // Mise à jour de timespan dans la BDD
+ timeSpanDAO.update(timespan);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Timespan débloqué avec succès");
+ }
+ result = ServiceHelper.RESPOND_SUCCESS;
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ } else {
+ result = ServiceHelper.TIMESPAN_NEXT_NOT_BLOCK;
+ }
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de bloquer une période au format DTO.
+ *
+ * @param timespanDTO
+ * @return
+ *
+ public String unblockTimeSpan(TimeSpanDTO timespanDTO) {
+ return unblockTimeSpan(searchTimeSpanByDate(timespanDTO));
+ }*/
+
+ /*
+ * Cette méthode va rechercher tous les timeSpans non bloqués après
+ * le timeSpan renseigné en paramètre.
+ * Si elle trouve au moins un timeSpan NON bloqué, elle renvoie alors faux.
+ * Cette méthode permet essentiellement de définir si il est possible
+ * ou non de bloquer un timeSpan. A savoir, un timeSpan ne peut être bloqué,
+ * si il existe des timeSpans suivant (dans le calendrier) qui sont non
+ * bloqués.
+ * @param timespan
+ * @param period
+ * @return
+ *
+ private boolean nextTimeSpanUnblock(TimeSpan timespan, Period period) {
+ boolean NextTimeSpanUnblock = false;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Recherche des TimeSpans avec la même période.
+ // (on doit récupérer normalement 12 timeSpans)
+ List<TimeSpan> listeTimeSpanOfPeriod = timeSpanDAO
+ .findAllByPeriod(period);
+ NextTimeSpanUnblock = true;
+ for (TimeSpan timeSpanNext : listeTimeSpanOfPeriod) {
+ // Si le timespan est après celui qu'on souhaite bloquer ET est non bloqué
+ if (timeSpanNext.getBeginTimeSpan().compareTo(
+ timespan.getBeginTimeSpan()) == 1
+ && timeSpanNext.getLocked()) {
+ NextTimeSpanUnblock = false;
+ if (log.isInfoEnabled()) {
+ log.info("Timespan " + timeSpanNext.toString()
+ + " est bloqué");
+ }
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return NextTimeSpanUnblock;
+ }*/
+
+ /*
+ * Permet de renvoyer une période dont appartient le timeSpan.
+ * @param timeSpan timeSpan dont on souhaite retourner la période
+ * @return
+ *
+ private Period getPeriodWithTimeSpan(TimeSpan timeSpan) {
+ PeriodServiceImpl periodServiceImpl = new PeriodServiceImpl();
+ Date beginTimeSpan = timeSpan.getBeginTimeSpan();
+ Period period = periodServiceImpl.searchPeriodWithDate(beginTimeSpan);
+ return period;
+ }*/
+
+ /*
+ * Cette méthode renvoie vrai lorsque tous les timespans de la période
+ * précédent au timespan en paramètre sont bloqués.
+ * @param timespan
+ * @param period le paramètre period est important, en effet un timespan ne
+ * peut être indépendant.
+ * @return
+ *
+ private boolean alltimeSpanBlocked(TimeSpan timespan, Period period) {
+ boolean AllTimeSpanBlock = false;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Recherche des TimeSpans avec la même période.
+ // (on doit récupérer normalement 12 timeSpans)
+ List<TimeSpan> listeTimeSpanOfPeriod = timeSpanDAO
+ .findAllByPeriod(period);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ // On contrôle que les timeSpans précédents sont bloqués.
+ AllTimeSpanBlock = true;
+ for (TimeSpan timeSpanPrev : listeTimeSpanOfPeriod) {
+ // Si la période est avant celle qu'on souhaite bloquer ET est non bloquée
+ if (timeSpanPrev.getBeginTimeSpan().compareTo(
+ timespan.getBeginTimeSpan()) == -1
+ && !timeSpanPrev.getLocked()) {
+ AllTimeSpanBlock = false;
+ if (log.isInfoEnabled()) {
+ log.info("Timespan " + timeSpanPrev.toString()
+ + " non bloqué");
+ }
+ }
+ }
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return AllTimeSpanBlock;
+ }*/
+
+ /*
+ * Permet d'effacer un timeSpan. Ce dernier ne doit pas être bloqué.
+ * @param timeSpan
+ * @return
+ *
+ public String removeTimeSpan(TimeSpan timeSpan) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Si le timspan est bloqué
+ if (timeSpan.getLocked()) {
+ if (log.isWarnEnabled()) {
+ log.warn("Timespan bloqué !");
+ }
+ } else {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Mise à jour de timespan dans la BDD
+ timeSpanDAO.delete(timeSpan);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Timespan supprimé avec succès");
+ }
+ result = ServiceHelper.RESPOND_SUCCESS;
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Vérifie si le timeSpan donné en paramètre est bloqué ou non.
+ * @param timeSpan
+ * @return
+ *
+ public boolean isTimeSpanBlocked(TimeSpan timeSpan) {
+ boolean isTimeSpanBlocked = true;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
+ .getTimeSpanDAO(topiaContext);
+ // Mise à jour de timespan dans la BDD
+ TimeSpan timeSpanSearch = timeSpanDAO.findByTopiaId(timeSpan
+ .getTopiaId());
+ isTimeSpanBlocked = timeSpanSearch.getLocked();
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return isTimeSpanBlocked;
+ }*/
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/TimeSpanServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionServiceImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,745 @@
+/*
+ * *##% Callao TransactionServiceImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.dto.EntryDTO;
+import org.chorem.lima.business.dto.LogDTO;
+import org.chorem.lima.business.dto.TransactionDTO;
+import org.chorem.lima.business.utils.ServiceHelper;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.Journal;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.entity.TimeSpan;
+import org.chorem.lima.entity.Transaction;
+import org.chorem.lima.entity.TransactionDAO;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * Cette classe permet la création d'une transaction comptable dans l'application.
+ * Toute action sur une transaction entraîne automatiquement une création de log.
+ * Une transaction est composée d'entrées comptables.
+ * Les actions sur les transactions sont soumises au statut de celle-ci, si elle
+ * est dans une période bloquée ou non.
+ *
+ * @author Rémi Chapelet
+ */
+public class TransactionServiceImpl {
+
+ private static final Log log = LogFactory
+ .getLog(TransactionServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ private LogServiceImpl logServiceImpl = new LogServiceImpl();
+
+ private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
+
+ private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
+
+ public TransactionServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Permet de créer une transaction comptable. Pour ajouter une transaction,
+ * le timeSpan doit être non bloqué.
+ * @param entryDate
+ * @param voucherRef
+ * @param description
+ * @param timespan
+ * @param journal
+ * @return
+ */
+ public void createTransaction(Transaction transaction /*Date entryDate, String voucherRef,
+ String description, TimeSpan timeSpan, Journal journal*/) {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ String isCorrectTransaction = isCorrectTransaction(timeSpan,
+ journal);
+ if (isCorrectTransaction.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Creation de la transaction
+ Transaction newtransaction = transactionDAO.create();
+ newtransaction.setTransDate(entryDate);
+ newtransaction.setVoucherRef(voucherRef);
+ newtransaction.setDescription(description);
+ newtransaction.setTimeSpan(timeSpan);
+ newtransaction.setJournal(journal);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Ajout avec succes de la transaction");
+ }
+
+ // Il renvoie soit l'identifiant topiaId ou SUCCESS.
+ result = newtransaction.getTopiaId();
+ //result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ result = isCorrectTransaction;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;*/
+ }
+
+ /*
+ * Permet de créer une transaction à partir d'une transaction DTO.
+ * ATTENTION : si le journal ou timespan n'existe pas, l'ajout ne peut se
+ * faire. Si on souhaite, on peut créer le journal automatiquement lors de
+ * l'ajout de la transaction si il n'existe pas. Pour le timeSpan, il n'est
+ * pas cohérent qu'il n'existe pas. On ne peut travailler que sur une période
+ * comptable existante, et par conséquent il ne faut pas le créer.
+ * @param transactionDTO
+ * @return
+ *
+ public String createTransaction(TransactionDTO transactionDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Vérifie que transactionDTO possède un journalDTO et un timeSpanDTO
+ if (transactionDTO.getJournalDTO() == null
+ || transactionDTO.getTimeSpanDTO() == null) {
+ if (log.isErrorEnabled()) {
+ log.error("L'objet transactionDTO ne possède pas de timeSpan ET/OU de journal.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ } else {
+ // Recherche du journal
+ JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
+ Journal journal = journalServiceImpl
+ .searchJournalWithLabel(transactionDTO.getJournalDTO()
+ .getLabel());
+ // Recherche du timeSpan
+ TimeSpan timeSpan = timeSpanServiceImpl
+ .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
+ .getBeginTimeSpan());
+
+ // Vérification si timeSpan et Journal existe bien
+ if (journal == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le journal "
+ + transactionDTO.getJournalDTO().getLabel()
+ + " n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ } else {
+ if (timeSpan == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le timeSpan "
+ + transactionDTO.getTimeSpanDTO().toString()
+ + " n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
+ } else {
+ result = createTransaction(transactionDTO.getEntryDate(),
+ transactionDTO.getVoucherRef(), transactionDTO
+ .getDescription(), timeSpan, journal);
+ }
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une transaction. Cette dernière est identifiée par la
+ * clé topiaId.
+ * @param topiaId
+ * @param entryDate
+ * @param voucherRef
+ * @param description
+ * @param timespan
+ * @param journal
+ * @return
+ *
+ public String modifyTransaction(String topiaId, Date entryDate,
+ String voucherRef, String description, TimeSpan timeSpan,
+ Journal journal) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Vérification que la transaction existe bien
+ Transaction transaction = transactionDAO.findByTopiaId(topiaId);
+ if (transaction == null) {
+ if (log.isInfoEnabled()) {
+ log.info("La transaction " + voucherRef
+ + " n'existe pas. (identifiant " + topiaId + ")");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_EXIST;
+ } else {
+ // Vérification si la transaction possède de bons paramètres
+ String correct = isCorrectTransaction(timeSpan, journal);
+ // Si la transaction est correcte
+ if (correct.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Modification
+ transaction.setTransDate(entryDate);
+ transaction.setVoucherRef(voucherRef);
+ transaction.setDescription(description);
+ transaction.setTimeSpan(timeSpan);
+ transaction.setJournal(journal);
+ transaction.update();
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une transaction à partir d'une transaction DTO.
+ * Elle va rechercher le journal et le timespan correspondants.
+ * @param transactionDTO
+ * @return
+ *
+ public String modifyTransaction(TransactionDTO transactionDTO) {
+ // Recherche du journal
+ JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
+ Journal journal = journalServiceImpl
+ .searchJournalWithLabel(transactionDTO.getJournalDTO()
+ .getLabel());
+ // Recherche du timeSpan
+ TimeSpan timeSpan = timeSpanServiceImpl
+ .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
+ .getBeginTimeSpan());
+ // Appel pour la modification
+ String result = modifyTransaction(transactionDTO.getId(),
+ transactionDTO.getEntryDate(), transactionDTO.getVoucherRef(),
+ transactionDTO.getDescription(), timeSpan, journal);
+ return result;
+ }*/
+
+ /*
+ * Recherche une transaction unique avec son identifiant TopiaId.
+ * @param topiaId
+ * @return
+ *
+ public Transaction searchTransactionWithTopiaId(String topiaId) {
+ Transaction transaction = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ transaction = transactionDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return transaction;
+ }*/
+
+ /*
+ * Recherche une transaction unique à partir d'une transaction DTO.
+ * @param transactionDTO
+ * @return
+ *
+ public Transaction searchTransactionWithTopiaId(
+ TransactionDTO transactionDTO) {
+ Transaction transaction = searchTransactionWithTopiaId(transactionDTO
+ .getId());
+ return transaction;
+ }*/
+
+ /*
+ * Recherche une transaction dans la base de données, et renvoie celle-ci
+ * sous format DTO. Nous ne pouvons pas appeler la méthode searchTransactionWithTopiaId
+ * du fait que lors de la convertion, nous avons besoin du journal et du
+ * timeSpan. Or il ne faut donc pas de fermeture de connexion à la base de
+ * données pour celà.
+ * @param topiaId
+ * @return
+ *
+ public TransactionDTO searchTransactionDTO(String topiaId) {
+ TransactionDTO transactionDTO = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ Transaction transaction = transactionDAO.findByTopiaId(topiaId);
+ // Converti la transaction en DTO
+ convertTransaction.setTransaction(rootContext);
+ transactionDTO = convertTransaction
+ .transactionEntityToDto(transaction);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return transactionDTO;
+ }*/
+
+ /*
+ * Recherche toutes les transactions qui correspondent à un timespan.
+ * @param timeSpan
+ * @return
+ *
+ public List<Transaction> searchListTransactionWithTimeSpan(TimeSpan timeSpan) {
+ List<Transaction> listTransaction = null;
+ if (timeSpan != null) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ listTransaction = transactionDAO.findAllByTimeSpan(timeSpan);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return listTransaction;
+ }*/
+
+ /*
+ * Recherche les transactions DTO d'un timeSpan
+ * @param timeSpan
+ * @return
+ *
+ public List<TransactionDTO> searchListTransactionDTOWithTimeSpan(
+ TimeSpan timeSpan) {
+ List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
+ if (timeSpan != null) {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ List<Transaction> listTransaction = transactionDAO
+ .findAllByTimeSpan(timeSpan);
+ // Converti la transaction en DTO
+ convertTransaction.setTransaction(rootContext);
+ for (Transaction transaction : listTransaction) {
+ TransactionDTO transactionDTO = convertTransaction
+ .transactionEntityToDto(transaction);
+ listTransactionDTO.add(transactionDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ }
+ return listTransactionDTO;
+ }*/
+
+ /*
+ * Recherche toutes les transactions appartenant à un même journal donné
+ * en paramètre.
+ * @param journal
+ * @return
+ *
+ public List<Transaction> searchListTransactionWithJournal(Journal journal) {
+ List<Transaction> listTransaction = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ listTransaction = transactionDAO.findAllByJournal(journal);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listTransaction;
+ }*/
+
+ /*
+ * Permet de rechercher toutes les transactions dans la base de données,
+ * avec en retour une liste de transactions au format DTO.
+ * @return
+ *
+ public List<TransactionDTO> getAllTransactionDTO() {
+ List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ List<Transaction> listTransaction = transactionDAO.findAll();
+ // Converti la transaction en DTO
+ convertTransaction.setTransaction(rootContext);
+ for (Transaction transaction : listTransaction) {
+ TransactionDTO transactionDTO = convertTransaction
+ .transactionEntityToDto(transaction);
+ listTransactionDTO.add(transactionDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listTransactionDTO;
+ }*/
+
+ /*
+ * Cette méthode permet de vérifier si une transaction possède des paramètres
+ * corrects.
+ * Un journal doit exister.
+ * Un timeSpan doit exister et être non bloqué.
+ * @param timeSpan
+ * @param journal
+ * @return
+ *
+ public String isCorrectTransaction(TimeSpan timeSpan, Journal journal) {
+ String result = ServiceHelper.RESPOND_SUCCESS;
+ // Vérification si timeSpan et Journal existe bien
+ if (journal == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le journal n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ }
+ if (timeSpan == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le timeSpan n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
+ } else {
+ // Vérifie si le timeSpan est bloqué
+ if (timeSpan.getLocked()) {
+ if (log.isErrorEnabled()) {
+ log.error("Le timeSpan est bloqué ! Il est donc impossible"
+ + " d'ajouter une transaction sur cette période. ("
+ + "Période du " + timeSpan + ")");
+ }
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'effacer une transaction dans la base de données.
+ * ATTENTION : Elle supprime également toutes les entées comptables
+ * associées. Une transaction appartenant à un timeSpan bloqué ne peut être
+ * supprimée.
+ * @return
+ *
+ public String removeTransaction(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche de l'entry
+ Transaction transaction = transactionDAO.findByTopiaId(topiaId);
+ // Transaction doit exister
+ if (transaction != null) {
+ // Vérifie si la transaction est non bloquée.
+ if (!isTransactionBlocked(transaction)) {
+ // Supprime tous les entrys de la transactions
+ List<Entry> listEntry = entryServiceImpl
+ .searchEntryWithTransaction(transaction);
+ for (Entry entry : listEntry) {
+ result = removeEntry(entry.getTopiaId());
+ }
+ // Supprime la transaction
+ transactionDAO.delete(transaction);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("La transaction a été supprimée avec succès.");
+ }
+ result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ // Transaction bloquée
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ } else {
+ result = ServiceHelper.TRANSACTION_NOT_EXIST;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Supprime une transaction au format DTO.
+ * @param transactionDTO
+ * @return
+ *
+ public String removeTransaction(TransactionDTO transactionDTO) {
+ String result = removeTransaction(transactionDTO.getId());
+ return result;
+ }*/
+
+ /*
+ * Permet d'ajouter une entrée comptable pour une transaction donnée.
+ * ATTENTION : la transaction doit être NON bloquée.
+ *
+ * @param description
+ * @param amount
+ * @param debit
+ * @param lettering
+ * @param detail
+ * @param transaction
+ * @return
+ *
+ public String addEntry(String description, String amount, boolean debit,
+ String lettering, String detail, Transaction transaction,
+ Account account) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Si la transaction est non bloquée
+ if (!isTransactionBlocked(transaction)) {
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+ result = entryServiceImpl.createEntry(description, amount, debit,
+ lettering, detail, transaction, account);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'ajouter une entrée comptable pour une transaction donnée.
+ * L'entrée est sous format DTO.
+ *
+ * @param entryDTO
+ * @return
+ *
+ public String addEntry(EntryDTO entryDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Recherche TransactionDTO
+ TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
+ Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
+ // Si la transaction est non bloquée
+ if (!isTransactionBlocked(transaction)) {
+
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+ result = entryServiceImpl.createEntry(entryDTO);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une entrée comptable.
+ * ATTENTION : la transaction doit être NON bloquée.
+ *
+ * @param topiaId
+ * @param description
+ * @param amount
+ * @param debit
+ * @param lettering
+ * @param detail
+ * @param transaction
+ * @param account
+ * @return
+ *
+ public String modifyEntry(String topiaId, String description,
+ String amount, boolean debit, String lettering, String detail,
+ Transaction transaction, Account account) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ if (!isTransactionBlocked(transaction)) {
+ result = entryServiceImpl.modifyEntry(topiaId, description, amount,
+ debit, lettering, detail, account);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une entrée.
+ * @param entryDTO
+ * @return
+ *
+ public String modifyEntry(EntryDTO entryDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Recherche TransactionDTO
+ TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
+ Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
+ if (!isTransactionBlocked(transaction)) {
+ result = entryServiceImpl.modifyEntry(entryDTO);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'effacer une entrée comptable. Elle est identifiée par son identifiant
+ * topiaID. Une entrée peut être supprimée seulement si elle est non bloquée.
+ * @param topiaId
+ * @return
+ *
+ public String removeEntry(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ // Recherche de l'entry
+ Entry entryDelete = entryDAO.findByTopiaId(topiaId);
+ // Entry doit exister
+ if (entryDelete != null) {
+ // Prend la transaction dont appartient entry
+ Transaction transaction = entryDelete.getTransaction();
+ // Vérifie si la transaction est non bloquée.
+ if (!isTransactionBlocked(transaction)) {
+ // Création d'un log DTO
+ LogDTO logDTO = new LogDTO("", new Date(),
+ ServiceHelper.LOG_REMOVE, transaction
+ .getTransDate(), transaction
+ .getVoucherRef(), transaction
+ .getDescription(), entryDelete
+ .getDescription(), entryDelete.getAmount(),
+ entryDelete.getDebit(), entryDelete.getLettering());
+ // Appel pour supprimer l'entrée
+ result = entryServiceImpl.removeEntry(topiaId);
+ // Si la suppression s'est bien déroulée, création log
+ if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Ajout du log
+ logServiceImpl.addLog(logDTO);
+ }
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ } else {
+ result = ServiceHelper.ENTRY_NOT_EXIST;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de supprimer une entrée à partir d'un DTO.
+ * @param entryDTO
+ * @return
+ *
+ public String removeEntry(EntryDTO entryDTO) {
+ String result = removeEntry(entryDTO.getId());
+ return result;
+ }*/
+
+ /*
+ * Permet de vérifier si une transaction est dans une période bloquée ou non
+ * @param transaction
+ * @return
+ *
+ public boolean isTransactionBlocked(Transaction transaction) {
+ boolean isTransactionBlocked = true;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ Transaction transactionSearch = transactionDAO
+ .findByTopiaId(transaction.getTopiaId());
+ isTransactionBlocked = timeSpanServiceImpl
+ .isTimeSpanBlocked(transactionSearch.getTimeSpan());
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return isTransactionBlocked;
+ }*/
+
+ /*
+ * Permet de vérifier si une transaction est équilibrée.
+ * @param transaction
+ * @return
+ *
+ public boolean isTransactionBalanced(Transaction transaction) {
+ List<EntryDTO> ListEntryDTO = entryServiceImpl
+ .searchEntryDTOWithTransaction(transaction);
+ float debit = 0;
+ float credit = 0;
+ // Pour toutes les entrées comptables trouvées
+ for (EntryDTO entryDTO : ListEntryDTO) {
+ // Si entrée au debit
+ if (entryDTO.isDebit()) {
+ debit = debit
+ + Float.parseFloat(entryDTO.getAmount().replaceFirst(
+ ",", "."));
+ } else {
+ credit = credit
+ + Float.parseFloat(entryDTO.getAmount().replaceFirst(
+ ",", "."));
+ }
+ }
+ // Vérifie si le debit == credit
+ boolean isTransactionBalanced = debit == credit;
+ return isTransactionBalanced;
+ }*/
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/UserServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/UserServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/UserServiceImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,116 @@
+/*
+ * *##% Callao
+ * Copyright (C) 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.entity.User;
+import org.chorem.lima.entity.UserDAO;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+
+/**
+ * User service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class UserServiceImpl {
+
+ /** log */
+ private static final Log log = LogFactory.getLog(UserServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ public UserServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Add new user.
+ *
+ * @param name new user name
+ * @throws LimaException
+ */
+ public void addUser(User user/*String name*/) throws LimaException {
+ /*// Attention doublon utilisateur
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ UsersDAO userdao = LimaCallaoDAOHelper.getUsersDAO(topiaContext);
+ // Création de l'user
+ Users newuser = userdao.create();
+ newuser.setMatcher(name);
+ // Création BDD
+ topiaContext.commitTransaction();
+ topiaContext.closeContext();
+ if (log.isInfoEnabled()) {
+ log.info("Add user : " + name);
+ }
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't create user", ex);
+ throw new LimaException("Can't create user", ex);
+ }
+
+ }*/
+ }
+
+ /**
+ * Find user with name.
+ *
+ * @param name
+ * @throws LimaException
+ */
+ public void findUser(String name) throws LimaException {
+ /*try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ UsersDAO userdao = LimaCallaoDAOHelper.getUsersDAO(topiaContext);
+ // Recherche du user
+ Users newuser = userdao.findByMatcher(name);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ if (newuser == null) {
+ throw new LimaBusinessException("can't find user " + name);
+ }
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't find user", ex);
+ throw new LimaException("Can't find user", ex);
+ }
+ }*/
+ }
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/UserServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertAccount.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertAccount.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertAccount.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,103 @@
+/**
+ * *##% Callao ConvertAccount
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.convertObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.business.dto.AccountDTO;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Transforme les objets Account : DTO, DAO et entity
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class ConvertAccount extends ConvertTopiaContext {
+
+ private static final Log log = LogFactory.getLog(ConvertAccount.class);
+
+ public void accountDtoToDao()
+ {
+
+ }
+
+ public void accountDaoToDto()
+ {
+
+ }
+
+ /**
+ * Transforme une entité Account en DTO.
+ * Les enfants sont également transformés.
+ * @param account
+ * @param accountChild
+ * @return
+ */
+ public AccountDTO accountEntityToDto(Account account,List<Account> accountChild)
+ {
+ AccountDTO accountDTO = new AccountDTO();
+ accountDTO.setId(account.getTopiaId());
+ accountDTO.setAccountNumber(account.getAccountNumber());
+ accountDTO.setLabel(account.getLabel());
+ accountDTO.setType(account.getType());
+ accountDTO.setAccountChildDTO(null);
+ /**
+ * Ajout des comptes enfants
+ */
+ try {
+ // Chargement du DAO
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(getTransaction());
+ // recherche des enfants
+ accountChild = accountDAO.findAllByMasterAccount(account);
+ // Création de la liste des enfants DTO
+ List<AccountDTO> newListDTO = new ArrayList<AccountDTO>();
+ for (Account newAccount : accountChild)
+ {
+ // On recherche les enfants de l'enfant
+ List<Account> ListAccount = accountDAO.findAllByMasterAccount(newAccount);
+ // Création de l'enfant en DTO
+ AccountDTO newAccountDTO = accountEntityToDto(newAccount,ListAccount);
+ // Ajout de l'enfant à la liste
+ newListDTO.add(newAccountDTO);
+ }
+ // Ajout de la liste des enfants au père DTO
+ accountDTO.setAccountChildDTO(newListDTO);
+ // Recherche du pere
+ Account masterAccount = accountDAO.findContainsSubAccount(account);
+ // Ajout du numéro de compte père au DTO
+ if (masterAccount != null)
+ {
+ accountDTO.setMasterAccount(masterAccount.getAccountNumber());
+ }
+ }catch (TopiaException e) {
+ log.error(e);
+ }
+ return accountDTO;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertAccount.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertEntry.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertEntry.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertEntry.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,74 @@
+/**
+ * *##% Callao ConvertEntry
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.convertObject;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.business.dto.AccountDTO;
+import org.chorem.lima.business.dto.EntryDTO;
+import org.chorem.lima.business.dto.TransactionDTO;
+
+/**
+ * Transforme les objets Entry : DTO, DAO et entity
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class ConvertEntry extends ConvertTopiaContext {
+
+ private static final Log log = LogFactory.getLog(ConvertEntry.class);
+
+ private static ConvertTransaction convertTransaction = new ConvertTransaction();
+
+ private static ConvertAccount convertAccount = new ConvertAccount();
+
+ /**
+ * Permet de transformer une entité entry en objet DTO
+ * @param entry
+ * @return
+ */
+ public EntryDTO entryEntityToDto(Entry entry)
+ {
+ EntryDTO entryDTO = new EntryDTO();
+ entryDTO.setId(entry.getTopiaId());
+ entryDTO.setDescription(entry.getDescription());
+ entryDTO.setAmount(entry.getAmount());
+ entryDTO.setDebit(entry.getDebit());
+ entryDTO.setLettering(entry.getLettering());
+ entryDTO.setDetail(entry.getDetail());
+ /**
+ * Converti la transaction en DTO
+ */
+ TransactionDTO transactionDTO = convertTransaction.transactionEntityToDto(entry.getTransaction());
+ entryDTO.setTransactionDTO(transactionDTO);
+ /**
+ * Converti le compte en DTO
+ */
+ convertAccount.setTransaction(getTransaction());
+ AccountDTO accountDTO = convertAccount.accountEntityToDto(entry.getAccount(),null);
+ entryDTO.setAccountDTO(accountDTO);
+ return entryDTO;
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertEntry.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertJournal.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertJournal.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertJournal.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,56 @@
+/**
+ * *##% Callao ConvertJournal
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.convertObject;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Journal;
+import org.chorem.lima.business.dto.JournalDTO;
+
+/**
+ * Transforme les objets Account : DTO, DAO et entity
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class ConvertJournal extends ConvertTopiaContext {
+
+ private static final Log log = LogFactory.getLog(ConvertJournal.class);
+
+
+ /**
+ * Permet de transformer une entité journal en objet DTO
+ * @param journal
+ * @return
+ */
+ public JournalDTO journalEntityToDto(Journal journal)
+ {
+ JournalDTO journalDTO = new JournalDTO();
+ journalDTO.setId(journal.getTopiaId());
+ journalDTO.setLabel(journal.getLabel());
+ journalDTO.setPrefix(journal.getPrefix());
+ journalDTO.setDescription(journal.getDescription());
+ return journalDTO;
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertJournal.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertLog.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertLog.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertLog.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,60 @@
+/**
+ * *##% Callao ConvertLog
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.convertObject;
+
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.EntryLog;
+import org.chorem.lima.business.dto.LogDTO;
+
+/**
+ * Transforme les objets Log : DTO, DAO et entity
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class ConvertLog extends ConvertTopiaContext {
+
+ private static final org.apache.commons.logging.Log log = LogFactory.getLog(ConvertAccount.class);
+
+
+ /**
+ * Permet de transformer une entité journal en objet DTO
+ * @param journal
+ * @return
+ */
+ public LogDTO logEntityToDto(EntryLog log)
+ {
+ LogDTO logDTO = new LogDTO();
+ logDTO.setId(log.getTopiaId());
+ logDTO.setLogDate(log.getLogDate());
+ logDTO.setType(log.getType());
+ logDTO.setTransDate(log.getTransDate());
+ logDTO.setVoucherRef(log.getVoucherRef());
+ logDTO.setTransDesc(log.getTransDesc());
+ logDTO.setEntryDesc(log.getEntryDesc());
+ logDTO.setAmount(log.getAmount());
+ logDTO.setDebit(log.getDebit());
+ logDTO.setLettering(log.getLettering());
+ return logDTO;
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertLog.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertPeriod.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertPeriod.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertPeriod.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,71 @@
+/*
+ * *##% Callao ConvertPeriod
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.convertObject;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Period;
+import org.chorem.lima.entity.TimeSpan;
+import org.chorem.lima.business.TimeSpanServiceImpl;
+import org.chorem.lima.business.dto.PeriodDTO;
+import org.chorem.lima.business.dto.TimeSpanDTO;
+
+/**
+ * Transforme les objets Period : DTO, DAO et entity
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class ConvertPeriod extends ConvertTopiaContext {
+
+ private static final Log log = LogFactory.getLog(ConvertPeriod.class);
+
+ private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
+
+
+ public PeriodDTO periodEntityToDto(Period period)
+ {
+ PeriodDTO periodDTO = null;
+ /*if (period != null)
+ {
+ periodDTO = new PeriodDTO();
+ periodDTO.setId(period.getTopiaId());
+ periodDTO.setBeginPeriod(period.getBeginPeriod());
+ periodDTO.setEndPeriod(period.getEndPeriod());
+ periodDTO.setLocked(period.getLocked());
+
+ // Converti les timeSpans en timeSpanDTO
+ List<TimeSpan> listTimeSpan = timeSpanServiceImpl.searchListTimeSpan(period);
+ ConvertTimeSpan convertTimeSpan = new ConvertTimeSpan();
+ for (TimeSpan timeSpan : listTimeSpan)
+ {
+ // Converti le timeSpan
+ TimeSpanDTO timeSpanDTO = convertTimeSpan.timeSpanEntityToDto(timeSpan);
+ // Ajoute le timeSpanDTO à periodDTO
+ periodDTO.addTimeSpan(timeSpanDTO);
+ }
+ }*/
+ return periodDTO;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertPeriod.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTimeSpan.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTimeSpan.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTimeSpan.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,63 @@
+/**
+ * *##% Callao ConvertTimeSpan
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.convertObject;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.TimeSpan;
+import org.chorem.lima.entity.TimeSpanDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.business.dto.TimeSpanDTO;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Transforme les objets TimeSpan : DTO, DAO et entity
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class ConvertTimeSpan extends ConvertTopiaContext {
+
+ private static final Log log = LogFactory.getLog(ConvertTimeSpan.class);
+
+
+ /**
+ * Transforme un timeSpan entity en timeSpan DTO
+ * @param account
+ * @param accountChild
+ * @return
+ */
+ public TimeSpanDTO timeSpanEntityToDto(TimeSpan timeSpan)
+ {
+ TimeSpanDTO timeSpanDTO = null;
+ if (timeSpan != null)
+ {
+ timeSpanDTO = new TimeSpanDTO();
+ timeSpanDTO.setId(timeSpan.getTopiaId());
+ timeSpanDTO.setBeginTimeSpan(timeSpan.getBeginTimeSpan());
+ timeSpanDTO.setEndTimeSpan(timeSpan.getEndTimeSpan());
+ timeSpanDTO.setLocked(timeSpan.getLocked());
+ }
+ return timeSpanDTO;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTimeSpan.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTopiaContext.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTopiaContext.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTopiaContext.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,54 @@
+/**
+ * *##% Callao ConvertTopiaContext
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.convertObject;
+
+import org.nuiton.topia.TopiaContext;
+
+/**
+ * Permet aux classes convert***.java de convertir les objets.
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class ConvertTopiaContext {
+
+ private TopiaContext topiaContext = null;
+
+ public ConvertTopiaContext ()
+ {
+ }
+
+ /**
+ * Permet d'initialiser le TopiaContext qui sera utilisé pour convertir les
+ * objets entités.
+ * @param transaction
+ */
+ public void setTransaction (TopiaContext topiaContext)
+ {
+ this.topiaContext = topiaContext;
+ }
+
+ public TopiaContext getTransaction ()
+ {
+ return topiaContext;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTopiaContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTransaction.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTransaction.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTransaction.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,69 @@
+/**
+ * *##% Callao ConvertTimeSpan
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.convertObject;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Transaction;
+import org.chorem.lima.business.dto.JournalDTO;
+import org.chorem.lima.business.dto.TimeSpanDTO;
+import org.chorem.lima.business.dto.TransactionDTO;
+
+/**
+ * Transforme les objets TimeSpan : DTO, DAO et entity
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class ConvertTransaction extends ConvertTopiaContext {
+
+ private static final Log log = LogFactory.getLog(ConvertTransaction.class);
+
+ private ConvertJournal convertJournal = new ConvertJournal();
+
+ private ConvertTimeSpan convertTimeSpan = new ConvertTimeSpan();
+
+ /**
+ *
+ * @param transaction
+ * @return
+ */
+ public TransactionDTO transactionEntityToDto(Transaction transaction)
+ {
+ TransactionDTO transactionDTO = new TransactionDTO();
+ transactionDTO.setId(transaction.getTopiaId());
+ transactionDTO.setEntryDate(transaction.getTransDate());
+ transactionDTO.setVoucherRef(transaction.getVoucherRef());
+ transactionDTO.setDescription(transaction.getDescription());
+ /**
+ * Converti le journal en DTO
+ */
+ JournalDTO journalDTO = convertJournal.journalEntityToDto(transaction.getJournal());
+ transactionDTO.setJournalDTO(journalDTO);
+ /**
+ * Converti le timeSpan en DTO
+ */
+ TimeSpanDTO timeSpanDTO = convertTimeSpan.timeSpanEntityToDto(transaction.getTimeSpan());
+ transactionDTO.setTimeSpanDTO(timeSpanDTO);
+ return transactionDTO;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/ConvertTransaction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/data/Balance.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/data/Balance.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/data/Balance.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,135 @@
+/* *##%
+ Copyright (C) 2009-2010 Lima Callao
+ *##%*/
+package org.chorem.lima.business.data;
+
+import java.beans.PropertyChangeListener;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.chorem.lima.entity.Account;
+
+/**
+ * DTO implantation for Balance entity.
+ */
+public class Balance implements java.io.Serializable {
+
+ private java.lang.String name;
+ private java.lang.String type;
+ private java.lang.String debit;
+ private java.lang.String credit;
+ private java.lang.String position;
+ public Account account;
+
+ protected java.beans.PropertyChangeSupport p;
+
+ /**
+ * Default constructor of BalanceDTO.
+ */
+ public Balance() {
+ p = new java.beans.PropertyChangeSupport(this);
+ }
+
+ /**
+ * Constructor of BalanceDTO with all parameters.
+ */
+ public Balance(java.lang.String name, java.lang.String type, java.lang.String debit, java.lang.String credit, java.lang.String position, Account account ) {
+ this();
+ this.name = name;
+ this.type = type;
+ this.debit = debit;
+ this.credit = credit;
+ this.position = position;
+ this.account = account;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ p.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ p.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public void setName(java.lang.String value) {
+ java.lang.String oldValue = this.name;
+ this.name = value;
+ p.firePropertyChange("name", oldValue, value);
+ }
+
+ public java.lang.String getName() {
+ return name;
+ }
+
+ public void setType(java.lang.String value) {
+ java.lang.String oldValue = this.type;
+ this.type = value;
+ p.firePropertyChange("type", oldValue, value);
+ }
+
+ public java.lang.String getType() {
+ return type;
+ }
+
+ public void setDebit(java.lang.String value) {
+ java.lang.String oldValue = this.debit;
+ this.debit = value;
+ p.firePropertyChange("debit", oldValue, value);
+ }
+
+ public java.lang.String getDebit() {
+ return debit;
+ }
+
+ public void setCredit(java.lang.String value) {
+ java.lang.String oldValue = this.credit;
+ this.credit = value;
+ p.firePropertyChange("credit", oldValue, value);
+ }
+
+ public java.lang.String getCredit() {
+ return credit;
+ }
+
+ public void setPosition(java.lang.String value) {
+ java.lang.String oldValue = this.position;
+ this.position = value;
+ p.firePropertyChange("position", oldValue, value);
+ }
+
+ public java.lang.String getPosition() {
+ return position;
+ }
+
+ public void setAccount(Account value) {
+ Account oldValue = this.account;
+ this.account = value;
+ p.firePropertyChange("account", oldValue, value);
+ }
+
+ public Account getAccount() {
+ return account;
+ }
+
+
+ @Override
+ public String toString() {
+ String result = new ToStringBuilder(this).
+ append("name", this.name).
+ append("type", this.type).
+ append("debit", this.debit).
+ append("credit", this.credit).
+ append("position", this.position).
+ append("account", this.account).
+ toString();
+ return result;
+ }
+
+} //BalanceDTO
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/data/Balance.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/data/Bilan.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/data/Bilan.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/data/Bilan.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,96 @@
+/* *##%
+ Copyright (C) 2009-2010 Lima Callao
+ *##%*/
+package org.chorem.lima.business.data;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * DTO implantation for Bilan entity.
+ */
+public class Bilan implements java.io.Serializable {
+
+ private java.lang.String name;
+ private java.lang.String total;
+ private java.lang.String depreciation;
+
+ protected java.beans.PropertyChangeSupport p;
+
+ /**
+ * Default constructor of BilanDTO.
+ */
+ public Bilan() {
+ p = new java.beans.PropertyChangeSupport(this);
+ }
+
+ /**
+ * Constructor of BilanDTO with all parameters.
+ */
+ public Bilan(java.lang.String name, java.lang.String total, java.lang.String depreciation ) {
+ this();
+ this.name = name;
+ this.total = total;
+ this.depreciation = depreciation;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ p.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ p.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public void setName(java.lang.String value) {
+ java.lang.String oldValue = this.name;
+ this.name = value;
+ p.firePropertyChange("name", oldValue, value);
+ }
+
+ public java.lang.String getName() {
+ return name;
+ }
+
+ public void setTotal(java.lang.String value) {
+ java.lang.String oldValue = this.total;
+ this.total = value;
+ p.firePropertyChange("total", oldValue, value);
+ }
+
+ public java.lang.String getTotal() {
+ return total;
+ }
+
+ public void setDepreciation(java.lang.String value) {
+ java.lang.String oldValue = this.depreciation;
+ this.depreciation = value;
+ p.firePropertyChange("depreciation", oldValue, value);
+ }
+
+ public java.lang.String getDepreciation() {
+ return depreciation;
+ }
+
+
+ @Override
+ public String toString() {
+ String result = new ToStringBuilder(this).
+ append("name", this.name).
+ append("total", this.total).
+ append("depreciation", this.depreciation).
+ toString();
+ return result;
+ }
+
+} //BilanDTO
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/data/Bilan.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/AccountDTO.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/dto/AccountDTO.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/dto/AccountDTO.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,247 @@
+/**
+ * *##% Callao AccountDTO
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.dto;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Classe DTO - représente un objet compte pour le Plan Comptable Général (PCG)
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class AccountDTO {
+
+ private String id; // Identifiant Topia
+
+ private String accountNumber;
+
+ private String label;
+
+ private String masterAccount;
+
+ private List<AccountDTO> accountChildDTO;
+
+ private String type;
+
+ public AccountDTO ()
+ {
+ this.id = "";
+ this.accountNumber = "0";
+ this.label = "";
+ this.masterAccount = "0";
+ this.accountChildDTO = new ArrayList<AccountDTO>();
+ this.type = "actif"; // Par défaut actif
+ }
+
+ public AccountDTO (String id, String accountNumber, String label,String masterAccount, List<AccountDTO> accountChildDTO,String type)
+ {
+ this.id = id;
+ this.accountNumber = accountNumber;
+ this.label = label;
+ this.masterAccount = masterAccount;
+ this.type = type;
+ // Si la liste est vide, il faut l'initialiser
+ if (accountChildDTO == null )
+ {
+ this.accountChildDTO = new ArrayList<AccountDTO>();
+ } else
+ {
+ this.accountChildDTO = accountChildDTO;
+ }
+ }
+
+ /**
+ * Permet d'ajouter un compte fils
+ * @param accountChildDTO
+ */
+ public void addAccountChild (AccountDTO accountChildDTO)
+ {
+ // Si le numéro père/fils correspond
+ if ( this.accountNumber.equals(accountChildDTO.getMasterAccount()) )
+ {
+ // Non présent
+ if ( !existAccountChild(accountChildDTO) )
+ {
+ this.accountChildDTO.add(accountChildDTO);
+ }
+ }
+ }
+
+ /**
+ * Permet d'enlever un compte fils
+ * @param accountChildDTO
+ */
+ public void removeAccountChild (AccountDTO accountChildDTO)
+ {
+ AccountDTO accountDeleteDTO = null;
+ // recherche du compte
+ for (AccountDTO accountChild : this.accountChildDTO)
+ {
+ if (accountChild.getAccountNumber().equals(accountChildDTO.getAccountNumber()))
+ {
+ accountDeleteDTO = accountChild;
+ }
+ }
+ // Si le compte à supprimer est trouvé, on le supprime
+ if ( accountDeleteDTO != null )
+ {
+ this.accountChildDTO.remove(accountDeleteDTO);
+ }
+ }
+
+ /**
+ * Permet d'afficher tous les comptes enfants
+ */
+ public void toStringAccountChild ()
+ {
+ int i = 0;
+ for (AccountDTO accountDTO : this.accountChildDTO)
+ {
+ System.out.println("Compte "+accountDTO.getAccountNumber()+" : "+accountDTO.getLabel());
+ i++;
+ }
+ System.out.println("Nombre de compte(s) enfant(s) : "+i);
+ }
+
+ /**
+ * Permet de vérifier si un compte DTO fait parti des enfants
+ * @param accountDTO
+ * @return
+ */
+ public boolean existAccountChild (AccountDTO accountDTO)
+ {
+ boolean exist = false;
+ for (AccountDTO accountChild : this.accountChildDTO)
+ {
+ if (accountChild.getAccountNumber().equals(accountDTO.getAccountNumber()))
+ {
+ exist = true;
+ }
+ }
+ return exist;
+ }
+
+ /**
+ * Permet de vérifier si un compte DTO fait parti des enfants
+ * @param accountDTO
+ * @return
+ */
+ public boolean existAccountChild (String accountNumber)
+ {
+ boolean exist = false;
+ for (AccountDTO accountChild : this.accountChildDTO)
+ {
+ if (accountChild.getAccountNumber().equals(accountNumber))
+ {
+ exist = true;
+ }
+ }
+ return exist;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the accountNumber
+ */
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ /**
+ * @param accountNumber the accountNumber to set
+ */
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ /**
+ * @return the label
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * @param label the label to set
+ */
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ /**
+ * @return the accountChildDTO
+ */
+ public List<AccountDTO> getAccountChildDTO() {
+ return accountChildDTO;
+ }
+
+ /**
+ * @param accountChildDTO the accountChildDTO to set
+ */
+ public void setAccountChildDTO(List<AccountDTO> accountChildDTO) {
+ this.accountChildDTO = accountChildDTO;
+ }
+
+ /**
+ * @return the masterAccount
+ */
+ public String getMasterAccount() {
+ return masterAccount;
+ }
+
+ /**
+ * @param masterAccount the masterAccount to set
+ */
+ public void setMasterAccount(String masterAccount) {
+ this.masterAccount = masterAccount;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/AccountDTO.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/EntryDTO.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/dto/EntryDTO.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/dto/EntryDTO.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,206 @@
+/**
+ * *##% Callao EntryDTO
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.dto;
+
+
+/**
+ * Classe DTO - représente un objet entry
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class EntryDTO {
+
+ private String id; // Identifiant Topia
+
+ private String description;
+
+ private String amount;
+
+ private boolean debit;
+
+ private String lettering;
+
+ private String detail;
+
+ private TransactionDTO transactionDTO;
+
+ private AccountDTO accountDTO;
+
+
+ public EntryDTO ()
+ {
+ this.id = "";
+ this.description = "";
+ this.amount = "";
+ this.debit = false;
+ this.lettering = "";
+ this.detail = "";
+ this.transactionDTO = null;
+ this.accountDTO = null;
+ }
+
+ public EntryDTO (String id, String description,String amount,boolean debit,
+ String lettering,String detail,TransactionDTO transactionDTO,AccountDTO accountDTO)
+ {
+ // Initialisation pour les variables chaines de caractères / Null
+ if (description == null ) {
+ description = "";
+ }
+ if (lettering == null ) {
+ lettering = "";
+ }
+ if (detail == null ) {
+ detail = "";
+ }
+ this.id = id;
+ this.description = description;
+ this.amount = amount;
+ this.debit = debit;
+ this.lettering = lettering;
+ this.detail = detail;
+ this.transactionDTO = transactionDTO;
+ this.accountDTO = accountDTO;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ if (description == null ) {
+ description = "";
+ }
+ this.description = description;
+ }
+
+ /**
+ * @return the amount
+ */
+ public String getAmount() {
+ return amount;
+ }
+
+ /**
+ * @param amount the amount to set
+ */
+ public void setAmount(String amount) {
+ this.amount = amount;
+ }
+
+ /**
+ * @return the debit
+ */
+ public boolean isDebit() {
+ return debit;
+ }
+
+ /**
+ * @param debit the debit to set
+ */
+ public void setDebit(boolean debit) {
+ this.debit = debit;
+ }
+
+ /**
+ * @return the lettering
+ */
+ public String getLettering() {
+ return lettering;
+ }
+
+ /**
+ * @param lettering the lettering to set
+ */
+ public void setLettering(String lettering) {
+ if (lettering == null ) {
+ lettering = "";
+ }
+ this.lettering = lettering;
+ }
+
+ /**
+ * @return the detail
+ */
+ public String getDetail() {
+ return detail;
+ }
+
+ /**
+ * @param detail the detail to set
+ */
+ public void setDetail(String detail) {
+ if (detail == null ) {
+ detail = "";
+ }
+ this.detail = detail;
+ }
+
+ /**
+ * @return the transactionDTO
+ */
+ public TransactionDTO getTransactionDTO() {
+ return transactionDTO;
+ }
+
+ /**
+ * @param transactionDTO the transactionDTO to set
+ */
+ public void setTransactionDTO(TransactionDTO transactionDTO) {
+ this.transactionDTO = transactionDTO;
+ }
+
+ /**
+ * @return the accountDTO
+ */
+ public AccountDTO getAccountDTO() {
+ return accountDTO;
+ }
+
+ /**
+ * @param accountDTO the accountDTO to set
+ */
+ public void setAccountDTO(AccountDTO accountDTO) {
+ this.accountDTO = accountDTO;
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/EntryDTO.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/JournalDTO.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/dto/JournalDTO.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/dto/JournalDTO.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,118 @@
+/**
+ * *##% Callao JournalDTO
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.dto;
+
+
+/**
+ * Classe DTO - représente un objet compte pour le Plan Comptable Général (PCG)
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class JournalDTO {
+
+ private String id; // Identifiant Topia
+
+ private String label;
+
+ private String prefix;
+
+ private String description;
+
+
+ public JournalDTO ()
+ {
+ this.id = "";
+ this.label = "";
+ this.prefix = "";
+ this.description = "";
+ }
+
+ public JournalDTO (String id, String label,String prefix,String description)
+ {
+ // Initialisation pour les variables chaines de caractères / Null
+ if (description == null ) {
+ description = "";
+ }
+ this.id = id;
+ this.label = label;
+ this.prefix = prefix;
+ this.description = description;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the label
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * @param label the label to set
+ */
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ /**
+ * @return the prefix
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /**
+ * @param prefix the prefix to set
+ */
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/JournalDTO.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/LogDTO.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/dto/LogDTO.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/dto/LogDTO.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,225 @@
+/**
+ * *##% Callao LogDTO
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.dto;
+
+import java.util.Date;
+
+/**
+ * Classe DTO - représente un objet log
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class LogDTO {
+
+ private String id; // Identifiant Topia
+
+ private Date logDate;
+
+ private String type;
+
+ private Date transDate;
+
+ private String voucherRef;
+
+ private String transDesc;
+
+ private String entryDesc;
+
+ private String amount;
+
+ private boolean debit;
+
+ private String lettering;
+
+
+
+ public LogDTO ()
+ {
+ this.id = "";
+ this.logDate = new Date();
+ this.type = "";
+ this.transDate = new Date();
+ this.voucherRef = "";
+ this.transDesc = "";
+ this.entryDesc = "";
+ this.amount = "";
+ this.debit = false;
+ this.lettering = "";
+ }
+
+ public LogDTO (String id, Date logDate,String type,Date transDate,
+ String voucherRef, String transDesc, String entryDesc,String amount,
+ boolean debit, String lettering)
+ {
+ this.id = id;
+ this.logDate = logDate;
+ this.type = type;
+ this.transDate = transDate;
+ this.voucherRef = voucherRef;
+ this.transDesc = transDesc;
+ this.entryDesc = entryDesc;
+ this.amount = amount;
+ this.debit = debit;
+ this.lettering = lettering;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the logDate
+ */
+ public Date getLogDate() {
+ return logDate;
+ }
+
+ /**
+ * @param logDate the logDate to set
+ */
+ public void setLogDate(Date logDate) {
+ this.logDate = logDate;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @return the transDate
+ */
+ public Date getTransDate() {
+ return transDate;
+ }
+
+ /**
+ * @param transDate the transDate to set
+ */
+ public void setTransDate(Date transDate) {
+ this.transDate = transDate;
+ }
+
+ /**
+ * @return the voucherRef
+ */
+ public String getVoucherRef() {
+ return voucherRef;
+ }
+
+ /**
+ * @param voucherRef the voucherRef to set
+ */
+ public void setVoucherRef(String voucherRef) {
+ this.voucherRef = voucherRef;
+ }
+
+ /**
+ * @return the transDesc
+ */
+ public String getTransDesc() {
+ return transDesc;
+ }
+
+ /**
+ * @param transDesc the transDesc to set
+ */
+ public void setTransDesc(String transDesc) {
+ this.transDesc = transDesc;
+ }
+
+ /**
+ * @return the entryDesc
+ */
+ public String getEntryDesc() {
+ return entryDesc;
+ }
+
+ /**
+ * @param entryDesc the entryDesc to set
+ */
+ public void setEntryDesc(String entryDesc) {
+ this.entryDesc = entryDesc;
+ }
+
+ /**
+ * @return the amount
+ */
+ public String getAmount() {
+ return amount;
+ }
+
+ /**
+ * @param amount the amount to set
+ */
+ public void setAmount(String amount) {
+ this.amount = amount;
+ }
+
+ /**
+ * @return the debit
+ */
+ public boolean isDebit() {
+ return debit;
+ }
+
+ /**
+ * @param debit the debit to set
+ */
+ public void setDebit(boolean debit) {
+ this.debit = debit;
+ }
+
+ /**
+ * @return the lettering
+ */
+ public String getLettering() {
+ return lettering;
+ }
+
+ /**
+ * @param lettering the lettering to set
+ */
+ public void setLettering(String lettering) {
+ this.lettering = lettering;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/LogDTO.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/PeriodDTO.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/dto/PeriodDTO.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/dto/PeriodDTO.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,268 @@
+/**
+ * *##% Callao PeriodDTO
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.dto;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import org.chorem.lima.business.utils.DateUtil;
+
+/**
+ * Classe DTO - représente un objet Period.
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class PeriodDTO {
+
+ private String id; // Identifiant Topia
+
+ private Date beginPeriod;
+
+ private Date endPeriod;
+
+ private boolean locked;
+
+ private List<TimeSpanDTO> listTimeSpan;
+
+ private static DateUtil dateUtil = new DateUtil();
+
+ public PeriodDTO ()
+ {
+ this.id = "";
+ this.beginPeriod = new Date();
+ this.beginPeriod = dateUtil.InitDateFirstDayMonth(this.beginPeriod);
+ this.endPeriod = new Date();
+ this.endPeriod = dateUtil.InitDateEndDayMonth(this.endPeriod);
+ this.locked = false;
+ this.listTimeSpan = new ArrayList<TimeSpanDTO>();
+ }
+
+ public PeriodDTO (String id, Date beginPeriod, Date endPeriod, boolean locked, List<TimeSpanDTO> listTimeSpan)
+ {
+ this.id = id;
+ this.beginPeriod = dateUtil.InitDateFirstDayMonth(beginPeriod);
+ this.endPeriod = dateUtil.InitDateEndDayMonth(endPeriod);
+ this.locked = locked;
+ // Si la liste est vide, il faut l'initialiser
+ if (listTimeSpan == null )
+ {
+ this.listTimeSpan = new ArrayList<TimeSpanDTO>();
+ } else
+ {
+ // Vérification de chaque timeSpan
+ for (TimeSpanDTO timeSpanDTO : this.listTimeSpan)
+ {
+ // Ajout du timeSpan avec vérification
+ addTimeSpan(timeSpanDTO);
+ }
+ }
+ }
+
+ /**
+ * Permet de vérifier pour chaque timeSpan. Il doit en avoir 12. Chaque date
+ * doit être comprise dans la période.
+ * @param listTimeSpan
+ * @return
+ */
+ public boolean isCorrectTimeSpan (TimeSpanDTO timeSpanDTO)
+ {
+ boolean result = false;
+ if (timeSpanDTO != null )
+ {
+ // Si le timeSpan n'existe pas déjà
+ if (!existTimeSpan(timeSpanDTO))
+ {
+ // Vérification du nombre de timeSpan appartenant à la période (12 timeSpans)
+ if (getListTimeSpan().size() < 12)
+ {
+ // Si la date de début du timeSpan est avant/après la période
+ if ( dateUtil.betweenDate(timeSpanDTO.getBeginTimeSpan(),this.beginPeriod,this.endPeriod)
+ && dateUtil.betweenDate(timeSpanDTO.getEndTimeSpan(),this.beginPeriod,this.endPeriod) )
+ {
+ result = true;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Ajoute un timeSpan dans la liste.
+ * @param timeSpanDTO
+ */
+ public void addTimeSpan (TimeSpanDTO timeSpanDTO)
+ {
+ // Si le timeSpan est correct
+ if (isCorrectTimeSpan(timeSpanDTO))
+ {
+ this.getListTimeSpan().add(timeSpanDTO);
+ // Tri la liste dans l'ordre croissant des timeSpans
+ Collections.sort(getListTimeSpan());
+ }
+ }
+
+ /**
+ * Vérifie si le timeSpan n'existe pas déja dans la base de données.
+ * @param timeSpanDTO
+ * @return
+ */
+ public boolean existTimeSpan (TimeSpanDTO timeSpanDTO)
+ {
+ boolean exist = false;
+ for (TimeSpanDTO timeSpanDtoOfList : this.getListTimeSpan())
+ {
+ // Si l'identifiant est non vide
+ if ( !(timeSpanDTO.getId().equals("")) )
+ {
+ // Compare sur l'identifiant.
+ if (timeSpanDtoOfList.getId().equals(timeSpanDTO.getId()))
+ {
+ exist = true;
+ }
+ }
+ /**
+ * Compare sur les dates (il est possible que le DTO ne possède pas
+ * encore son identifiant topiaId.
+ */
+ // Si la date de début du timeSpan dans la liste est égal au timeSpan donné en paramètre
+ if (timeSpanDtoOfList.getBeginTimeSpan().compareTo(timeSpanDTO.getBeginTimeSpan()) == 0)
+ {
+ exist = true;
+ }
+ }
+ return exist;
+ }
+
+ /**
+ * Permet de bloquer une période.
+ * ATTENTION : tous les timeSpans, qui composent la période, doivent être
+ * bloqués. Une période peut être bloquée, MAIS pas être débloquée.
+ */
+ public void blockPeriod ()
+ {
+ // Vérifie si la période n'est pas déjà bloquée.
+ if ( !isLocked() )
+ {
+ // Test pour les timeSpans si ils sont bien bloqués
+ boolean existTimeSpanDTONotBlocked = false;
+ for (TimeSpanDTO timeSpanDTO : this.listTimeSpan)
+ {
+ // Si le timeSpan est bloqué
+ if (timeSpanDTO.isLocked())
+ {
+ existTimeSpanDTONotBlocked = true;
+ }
+ }
+ // Si tous les timeSpans sont bloqués, on bloque la période
+ if (existTimeSpanDTONotBlocked)
+ {
+ this.locked = true;
+ }
+ }
+ }
+
+ /**
+ * Permet de bloquer tous les timeSpans.
+ */
+ public void blockAllTimeSpan ()
+ {
+ for (TimeSpanDTO timeSpanDTO : this.listTimeSpan)
+ {
+ timeSpanDTO.setLocked(true);
+ }
+ }
+
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the beginPeriod
+ */
+ public Date getBeginPeriod() {
+ return beginPeriod;
+ }
+
+ /**
+ * @param beginPeriod the beginPeriod to set
+ */
+ public void setBeginPeriod(Date beginPeriod) {
+ this.beginPeriod = dateUtil.InitDateFirstDayMonth(beginPeriod);
+ }
+
+ /**
+ * @return the endPeriod
+ */
+ public Date getEndPeriod() {
+ return endPeriod;
+ }
+
+ /**
+ * @param endPeriod the endPeriod to set
+ */
+ public void setEndPeriod(Date endPeriod) {
+ this.endPeriod = dateUtil.InitDateEndDayMonth(endPeriod);
+ }
+
+ /**
+ * @return the locked
+ */
+ public boolean isLocked() {
+ return locked;
+ }
+
+ /**
+ * @param locked the locked to set
+ */
+ public void setLocked(boolean locked) {
+ blockPeriod();
+ }
+
+ /**
+ * @return the listTimeSpan
+ */
+ public List<TimeSpanDTO> getListTimeSpan() {
+ return listTimeSpan;
+ }
+
+ /**
+ * @param listTimeSpan the listTimeSpan to set
+ */
+ public void setListTimeSpan(List<TimeSpanDTO> listTimeSpan) {
+ this.listTimeSpan = listTimeSpan;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/PeriodDTO.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/TimeSpanDTO.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/dto/TimeSpanDTO.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/dto/TimeSpanDTO.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,137 @@
+/**
+ * *##% Callao TimeSpanDTO
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.dto;
+
+import java.util.Date;
+
+import org.chorem.lima.business.utils.DateUtil;
+
+/**
+ * Classe DTO - représente une période (TimeSpan) mensuelle
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class TimeSpanDTO implements Comparable {
+
+ private String id; // Identifiant Topia
+
+ private Date beginTimeSpan;
+
+ private Date endTimeSpan;
+
+ private boolean locked;
+
+ private static DateUtil dateUtil = new DateUtil();
+
+
+ public TimeSpanDTO ()
+ {
+ this.id = "";
+ this.beginTimeSpan = new Date();
+ this.beginTimeSpan = dateUtil.InitDateFirstDayMonth(this.beginTimeSpan);
+ this.endTimeSpan = new Date();
+ this.endTimeSpan = dateUtil.InitDateEndDayMonth(this.endTimeSpan);
+ this.locked = false;
+ }
+
+ public TimeSpanDTO (String id, Date beginTimeSpan,Date endTimeSpan,boolean locked)
+ {
+ this.id = id;
+ this.beginTimeSpan = dateUtil.InitDateFirstDayMonth(beginTimeSpan);
+ this.endTimeSpan = dateUtil.InitDateEndDayMonth(endTimeSpan);
+ this.locked = locked;
+ }
+
+ /**
+ * Implémente la classe comparable pour permettre le tri d'une liste avec
+ * des objets timeSpanDTO.
+ * @param other
+ * @return
+ */
+ @Override
+ public int compareTo(Object other) {
+ int result = 1;
+ Date date1 = ((TimeSpanDTO) other).beginTimeSpan;
+ Date date2 = this.beginTimeSpan;
+ result = dateUtil.compareDate(date2,date1);
+ return result;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the beginTimeSpan
+ */
+ public Date getBeginTimeSpan() {
+ return beginTimeSpan;
+ }
+
+ /**
+ * @param beginTimeSpan the beginTimeSpan to set
+ */
+ public void setBeginTimeSpan(Date beginTimeSpan) {
+ this.beginTimeSpan = dateUtil.InitDateFirstDayMonth(beginTimeSpan);
+ }
+
+ /**
+ * @return the endTimeSpan
+ */
+ public Date getEndTimeSpan() {
+ return endTimeSpan;
+ }
+
+ /**
+ * @param endTimeSpan the endTimeSpan to set
+ */
+ public void setEndTimeSpan(Date endTimeSpan) {
+ this.endTimeSpan = dateUtil.InitDateEndDayMonth(endTimeSpan);
+ }
+
+ /**
+ * @return the locked
+ */
+ public boolean isLocked() {
+ return locked;
+ }
+
+ /**
+ * @param locked the locked to set
+ */
+ public void setLocked(boolean locked) {
+ this.locked = locked;
+ }
+
+
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/TimeSpanDTO.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/TransactionDTO.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/dto/TransactionDTO.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/dto/TransactionDTO.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,163 @@
+/**
+ * *##% Callao TransactionDTO
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.dto;
+
+import java.util.Date;
+
+/**
+ * Classe DTO - représente une transaction comptable.
+ *
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 use entities instead
+ */
+public class TransactionDTO {
+
+ private String id; // Identifiant Topia
+
+ private Date entryDate;
+
+ private String voucherRef;
+
+ private String description;
+
+ private TimeSpanDTO timeSpanDTO;
+
+ private JournalDTO journalDTO;
+
+
+ public TransactionDTO ()
+ {
+ this.id = "";
+ this.entryDate = new Date();
+ this.voucherRef = "";
+ this.description = "";
+ }
+
+ public TransactionDTO (String id, Date entryDate,String voucherRef,String description)
+ {
+ // Initialisation pour les variables chaines de caractères / Null
+ if (voucherRef == null ) {
+ voucherRef = "";
+ }
+ if (description == null ) {
+ description = "";
+ }
+ this.id = id;
+ this.entryDate = entryDate;
+ this.voucherRef = voucherRef;
+ this.description = description;
+ this.timeSpanDTO = null;
+ this.journalDTO = null;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the entryDate
+ */
+ public Date getEntryDate() {
+ return entryDate;
+ }
+
+ /**
+ * @param entryDate the entryDate to set
+ */
+ public void setEntryDate(Date entryDate) {
+ this.entryDate = entryDate;
+ }
+
+ /**
+ * @return the voucherRef
+ */
+ public String getVoucherRef() {
+ return voucherRef;
+ }
+
+ /**
+ * @param voucherRef the voucherRef to set
+ */
+ public void setVoucherRef(String voucherRef) {
+ if (voucherRef == null ) {
+ voucherRef = "";
+ }
+ this.voucherRef = voucherRef;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ if (description == null ) {
+ description = "";
+ }
+ this.description = description;
+ }
+
+ /**
+ * @return the journalDTO
+ */
+ public JournalDTO getJournalDTO() {
+ return journalDTO;
+ }
+
+ /**
+ * @param journalDTO the journalDTO to set
+ */
+ public void setJournalDTO(JournalDTO journalDTO) {
+ this.journalDTO = journalDTO;
+ }
+
+ /**
+ * @return the timeSpanDTO
+ */
+ public TimeSpanDTO getTimeSpanDTO() {
+ return timeSpanDTO;
+ }
+
+ /**
+ * @param timeSpanDTO the timeSpanDTO to set
+ */
+ public void setTimeSpanDTO(TimeSpanDTO timeSpanDTO) {
+ this.timeSpanDTO = timeSpanDTO;
+ }
+
+
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/dto/TransactionDTO.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DateUtil.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DateUtil.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DateUtil.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,185 @@
+/**
+ * *##% Callao DateUtil
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.utils;
+
+import java.util.Date;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * Cette classe permet de manipuler des dates.
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0, use commons lang or nuiton dateutils
+ */
+public class DateUtil {
+
+ /** log */
+ private static final org.apache.commons.logging.Log log = LogFactory.getLog(DateUtil.class);
+
+
+ /**
+ * Initialise la date d'entrée le premier du mois à minuit.
+ * Exemple : 15 janvier 2009, alors date de sortie 1 Janvier 2009 00h00m00s
+ * @param d date
+ * @return
+ */
+ public Date InitDateFirstDayMonth (Date d)
+ {
+ Date date_result = new Date(d.getYear(),d.getMonth(),1,0,0,0);
+ return date_result;
+ }
+
+ /**
+ * Permet de retourner la date de fin de mois. Si on lui donne la date
+ * 5 Janv 2000, elle retourne alors 31 Jan 2000.
+ * @param d date de référence
+ * @return la date du fin de mois
+ */
+ public Date InitDateEndDayMonth (Date d)
+ {
+ Calendar c = new GregorianCalendar (d.getYear()+1900,d.getMonth(),d.getDate());
+ // Calcul le dernier jour du mois, prend en compte les années bixestiles
+ Integer maxDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
+ //Date dateEnd = new Date(d.getYear(),d.getMonth(),maxDay,23,59,59);
+ Calendar dateEnd = new GregorianCalendar (d.getYear()+1900,d.getMonth(),maxDay,23,59,59);
+ Date result = dateEnd.getTime();
+ return result;
+ }
+
+ /**
+ * Permet de comparer deux dates. Si d1 est plus grande que d2, alors true
+ * @param d1 Date 1
+ * @param d2 Date 2
+ * @return
+ */
+ public boolean DateGreatThan (Date d1, Date d2)
+ {
+ boolean result = false;
+ long diff = d1.getTime() - d2.getTime();
+ if (diff > 0 )
+ {
+ result=true;
+ }
+ return result;
+ }
+
+ /**
+ * Permet de calculer le nombre de mois entre les deux dates.
+ * @param d1 date 1
+ * @param d2 date 2
+ * @return
+ */
+ public int numberOfMonths (Date d1, Date d2)
+ {
+ GregorianCalendar gc1 = new GregorianCalendar();
+ gc1.setTime(d1);
+ GregorianCalendar gc2 = new GregorianCalendar();
+ gc2.setTime(d2);
+ int number_months = 0;
+ gc1.add(GregorianCalendar.MONTH, 1);
+ while(gc1.compareTo(gc2)<=0) {
+ number_months++;
+ gc1.add(GregorianCalendar.MONTH, 1);
+ }
+ return number_months;
+ }
+
+ /**
+ * Permet de renvoyer la date précédente à celle donnée en paramètre.
+ * Exemple : d = 17 avril 2000, return 16 avril 2000
+ * @param d
+ * @return
+ */
+ public Date previousDay(Date d)
+ {
+ Calendar c = new GregorianCalendar (d.getYear()+1900,d.getMonth(),d.getDate(),23,59,59);
+ // Calcul le jour précédent
+ c.add(Calendar.DATE, -1);
+ Date result = c.getTime();
+ return result;
+ }
+
+ /**
+ * Permet de copier une date.
+ * @param d
+ * @return
+ */
+ public Date copyDate (Date d)
+ {
+ Date date_result = new Date(d.getYear(),d.getMonth(),d.getDay(),d.getHours(),d.getMinutes(),d.getSeconds());
+ return date_result;
+ }
+
+ /**
+ * Implémentation de compareTO. Si il y a besoin, il est possible de la modifier.
+ * @param d1
+ * @param d2
+ * @return
+ */
+ public int compareDate(Date d1, Date d2)
+ {
+ return d1.compareTo(d2);
+ }
+
+ /**
+ * Permet de renvoyer vrai si une date d donnée est entre deux dates.
+ * @param d date se trouvant ou non dans la période
+ * @param dateBegin date de début de période
+ * @param dateEnd date de fin de période
+ * @return
+ */
+ public boolean betweenDate (Date d, Date dateBegin, Date dateEnd)
+ {
+ boolean result = false;
+ if ( ( (compareDate(d,dateBegin) == 0) || (compareDate(d,dateBegin) == 1) )
+ && ( (compareDate(d,dateEnd) == 0) || (compareDate(d,dateEnd) == -1) ) )
+ {
+ result = true;
+ }
+ return result;
+ }
+
+ /**
+ * Permet de découper une date dans un tableau.
+ * Indices :
+ * 0 : année
+ * 1 : mois
+ * 2 : jour
+ * @param d
+ * @return
+ */
+ public String[] arrayDate (Date d)
+ {
+ String dateTab[] = new String[3];
+ // année
+ dateTab[0] = Integer.toString(d.getYear()+1900);
+ // mois
+ dateTab[1] = Integer.toString(d.getMonth());
+ // jour
+ dateTab[2] = Integer.toString(d.getDate());
+ return dateTab;
+ }
+
+
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DateUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/NumberUtil.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/NumberUtil.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/NumberUtil.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,103 @@
+/**
+ * *##% Callao NumberUtil
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.utils;
+
+
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Cette classe permet de manipuler des nombres.
+ * Elle est utilisée essentiellement au niveau des entrées comptables afin de
+ * formater tous les nombres suivant la norme comptabilité choisie.
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0, use {@link NumberFormat} directly
+ */
+public class NumberUtil {
+
+ /** log */
+ private static final Log log = LogFactory.getLog(NumberUtil.class);
+
+ public static NumberFormat numberFormat;
+
+ public static final String format = "%0$10.2f";
+
+
+ /**
+ * Instancie la classe NumberFormat. Elle va permettre d'apporter des méthodes
+ * pour manipuler les chaines de caractères et les nombres.
+ * On doit définir la variable locale.
+ * @return
+ */
+ public static NumberFormat getNumberFormat() {
+ if (numberFormat == null) {
+ numberFormat = NumberFormat.getNumberInstance(Locale.FRENCH);
+ }
+ return numberFormat;
+ }
+
+ /**
+ * Format la chaine de caractère en nombre.
+ * @param amount
+ */
+ public Double formatNumber (String amount)
+ {
+ Double numberDouble;
+ try {
+ Number number = getNumberFormat().parse(amount);
+ numberDouble = number.doubleValue();
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ return numberDouble;
+ }
+
+
+ /**
+ * Formate un nombre sous format Double en renvoyant en chaîne de caractère.
+ * Il utilise la variable "format" pour définir le formatage ainsi que la
+ * variable locale.
+ * @param number
+ * @return
+ */
+ public String format(double number)
+ {
+ return String.format(Locale.FRENCH, format, number).trim();
+ }
+
+ /**
+ * Formate un nombre sous format String.
+ * @param theDouble
+ * @return
+ */
+ public String format(String amount)
+ {
+ return format(formatNumber(amount));
+ }
+
+
+
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/NumberUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ServiceHelper.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ServiceHelper.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ServiceHelper.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,87 @@
+/**
+ * *##% Callao ServiceHelper
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.utils;
+
+/**
+ * Définition des messages acceptés par Callao
+ * @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0, with no replacement (Exception)
+ */
+public interface ServiceHelper {
+
+ /**
+ * Réponses utilisées par la couche métier Callao
+ */
+ public static final String RESPOND_SUCCESS = "success";
+ public static final String RESPOND_ERROR = "error";
+
+ /**
+ * Account Error
+ */
+ public static final String ACCOUNT_DOUBLE = "account_double";
+ public static final String ACCOUNT_NOT_MASTER = "account_not_master";
+ public static final String ACCOUNT_NOT_EXIST = "account_not_exist";
+ public static final String ACCOUNT_WITH_ENTRIES = "account_with_entries";
+
+ /**
+ * Entries Error
+ */
+ public static final String ENTRY_NOT_EXIST = "entry_not_exist";
+
+ /**
+ * Journal
+ */
+ public static final String JOURNAL_DOUBLE = "journal_double";
+ public static final String JOURNAL_NOT_EXIST = "journal_not_exist";
+ public static final String JOURNAL_WITH_TRANSACTIONS = "journal_with_transactions";
+
+ /**
+ * Period
+ */
+ public static final String PERIOD_CREATE_TIMESPANS = "period_create_timespan";
+ public static final String PERIOD_TIMESPAN_NOT_BLOCK = "period_timespan_not_block";
+ public static final String PERIOD_TIMESPAN_BLOCK = "period_timespan_block";
+ public static final String PERIOD_ALL_TIMESPAN = "period_all_timespan";
+ public static final String PERIOD_NOT_EXIST = "period_not_exist";
+
+ /**
+ * TimeSpan
+ */
+ public static final String TIMESPAN_PREC_NOT_BLOCK = "timespan_prec_not_block";
+ public static final String TIMESPAN_NEXT_NOT_BLOCK = "timespan_next_not_block";
+
+ /**
+ * Transaction
+ */
+ public static final String TRANSACTION_NOT_JOURNAL = "transaction_not_journal";
+ public static final String TRANSACTION_NOT_TIMESPAN = "transaction_not_timespan";
+ public static final String TRANSACTION_TIMESPAN_BLOCKED = "transaction_timespan_blocked";
+ public static final String TRANSACTION_NOT_EXIST = "transaction_not_exist";
+ public static final String TRANSACTION_NOT_BALANCED = "transaction_not_balanced";
+
+ /**
+ * Définition des types de logs possibles
+ */
+ public static final String LOG_ADD = "add";
+ public static final String LOG_MODIFY = "modify";
+ public static final String LOG_REMOVE = "remove";
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ServiceHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/resources/lima.properties
===================================================================
--- trunk/lima-business/src/main/resources/lima.properties (rev 0)
+++ trunk/lima-business/src/main/resources/lima.properties 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,17 @@
+# Proprietes par defaut pour une base de donnees de type H2
+hibernate.hbm2ddl.auto=update
+hibernate.show_sql=false
+
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.username=sa
+hibernate.connection.password=
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.connection.url=jdbc:h2:file:~/.lima/limadb
+
+# Permet de preciser les classes a utiliser
+#topia.persistence.classes=org.chorem.callao.entity.AccountImpl, \
+#org.chorem.callao.entity.ClientImpl, \
+#org.chorem.callao.entity.EntryImpl, org.chorem.callao.entity.PeriodImpl, \
+#org.chorem.callao.entity.JournalImpl, org.chorem.callao.entity.ProjectImpl, \
+#org.chorem.callao.entity.TimeSpanImpl, org.chorem.callao.entity.TransactionImpl, \
+#org.chorem.callao.entity.UsersImpl, org.chorem.callao.entity.LogImpl
Added: trunk/lima-business/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-business/src/main/resources/log4j.properties (rev 0)
+++ trunk/lima-business/src/main/resources/log4j.properties 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,10 @@
+# Global logging configuration
+log4j.rootLogger=WARN, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+# package level
+log4j.logger.org.chorem.lima=DEBUG
Added: trunk/lima-business/src/main/resources/save_callao.dtd
===================================================================
--- trunk/lima-business/src/main/resources/save_callao.dtd (rev 0)
+++ trunk/lima-business/src/main/resources/save_callao.dtd 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!ELEMENT lima-callao (informations,save)>
+<!ELEMENT informations>
+<!ATTLIST informations
+ date CDATA #REQUIRED
+ user CDATA #REQUIRED
+ company CDATA #REQUIRED>
+<!ELEMENT save (periods,timespans,journals,accounts,transactions,entries)>
+<!ELEMENT periods (period*)>
+<!ATTLIST period
+ id ID #REQUIRED
+ beginYear CDATA #REQUIRED
+ beginMonth CDATA #REQUIRED
+ beginDay CDATA #REQUIRED
+ endYear CDATA #REQUIRED
+ endMonth CDATA #REQUIRED
+ endDay CDATA #REQUIRED
+ locked CDATA #REQUIRED>
+<!ELEMENT timespans (timespan*)>
+<!ATTLIST timespan
+ id ID #REQUIRED
+ idPeriod IDREF #REQUIRED
+ beginYear CDATA #REQUIRED
+ beginMonth CDATA #REQUIRED
+ beginDay CDATA #REQUIRED
+ endYear CDATA #REQUIRED
+ endMonth CDATA #REQUIRED
+ endDay CDATA #REQUIRED
+ locked CDATA #REQUIRED>
+<!ELEMENT journals (journal*)>
+<!ATTLIST journal
+ id ID #REQUIRED
+ label CDATA #REQUIRED
+ prefix CDATA #REQUIRED
+ description CDATA #REQUIRED>
+<!ELEMENT accounts (account*)>
+<!ATTLIST account
+ id ID #REQUIRED
+ label CDATA #REQUIRED
+ accountNumber CDATA #REQUIRED
+ masterAccount CDATA #REQUIRED>
+<!ELEMENT transactions (transaction*)>
+<!ATTLIST transaction
+ id ID #REQUIRED
+ entryDateYear CDATA #REQUIRED
+ entryDateMonth CDATA #REQUIRED
+ entryDateDay CDATA #REQUIRED
+ voucherRef CDATA #REQUIRED
+ description CDATA #REQUIRED
+ idJournal IDREF #REQUIRED
+ idTimeSpan IDREF #REQUIRED>
+<!ELEMENT entries (entry*)>
+<!ATTLIST entry
+ id ID #REQUIRED
+ description CDATA #REQUIRED
+ amount CDATA #REQUIRED
+ lettering CDATA #REQUIRED
+ detail CDATA #REQUIRED
+ idAccount IDREF #REQUIRED>
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,237 @@
+package org.chorem.lima.business;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.dto.AccountDTO;
+import org.chorem.lima.business.utils.ServiceHelper;
+import org.chorem.lima.entity.Account;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests pour la gestion des comptes dans le plan comptable
+ *
+ * Vérification sur l'ajout, la modification et suppression d'un compte.
+ * Il existe également des tests sur des actions à partir de DTO. La classe
+ * AccountServiceImplTest possède une méthode upload qui, à partir d'un DTO,
+ * va mettre à jour automatiquement dans la base de données.
+ *
+ * @author Rémi Chapelet
+ */
+public class AccountServiceImplTest {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(AccountServiceImplTest.class);
+
+ private static AccountServiceImpl instance;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ /**
+ * On nettoie la base de données
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ //instance.removeAccount("4");
+ //instance.removeAccount("5");
+ }
+
+ @Before
+ public void setUp() {
+ //instance = new AccountServiceImpl();
+ }
+
+ public AccountServiceImplTest() {
+ }
+
+
+ /**
+ * Création d'un compte dans le plan comptable
+ */
+ @Test
+ public void createAccountTest ()
+ {
+ /*// On ajoute le compte 4 - Comptes de tiers
+ String result = instance.createAccount("4", "Comptes de tiers", "0","actif");
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+ // On ajoute de nouveau le compte 4 - Comptes de tiers
+ result = instance.createAccount("4", "Le nom n'a pas d'importance", "0","actif");
+ Assert.assertEquals(ServiceHelper.ACCOUNT_DOUBLE,result);*/
+ }
+
+ /**
+ * Permet de tester l'ajout des comptes sous format DTO. La grande différence
+ * entre la création classique, l'applicaion va enregistrer tous les comptes
+ * enfants.
+ */
+ @Test
+ public void createAccountDTOTest ()
+ {
+ /*String result;
+ // Création des comptes DTO
+ AccountDTO accountDTO = new AccountDTO("","5","COMPTES FINANCIERS","0",null,"actif");
+ AccountDTO accountChildDTO = new AccountDTO("","50","Valeurs mobilières de placement","5",null,"actif");
+ accountDTO.addAccountChild(accountChildDTO);
+ accountChildDTO = new AccountDTO("","51","Banques établissements financiers et assimilés","5",null,"actif");
+ accountDTO.addAccountChild(accountChildDTO);
+ AccountDTO accountChilChilddDTO = new AccountDTO("","511","Valeurs à l'encaissement","51",null,"actif");
+ accountChildDTO.addAccountChild(accountChilChilddDTO);
+ accountChilChilddDTO = new AccountDTO("","512","Banques","51",null,"actif");
+ accountChildDTO.addAccountChild(accountChilChilddDTO);
+ // Pour afficher les comptes enfants
+ //accountDTO.toStringAccountChild();
+
+ // Création dans la base de données. Les comptes 5, 50, 51, 511 et 512 sont créés.
+ result = instance.createAccount(accountDTO);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);*/
+ }
+
+
+ /**
+ * Recherche d'un compte dans le plan comptable à partir d'un numéro de
+ * compte.
+ */
+ @Test
+ public void searchAccountTest ()
+ {
+ /*// On recherche le compte 4 - Comptes de tiers
+ Account result = instance.searchAccount("4");
+ Assert.assertEquals("Comptes de tiers",result.getLabel());*/
+ }
+
+
+ /**
+ * Recherche d'un compte dans le plan comptable à partir d'un numéro de
+ * compte. Il renvoie un objet DTO compte
+ */
+ @Test
+ public void searchAccountDTOTest ()
+ {
+ /*// On recherche le compte 4 - Comptes de tiers
+ AccountDTO result = instance.searchAccountDTO("4");
+ Assert.assertEquals("Comptes de tiers",result.getLabel());*/
+ }
+
+
+ /**
+ * Permet de tester le nombre d'enfants renvoyés appartenant à un père.
+ */
+ @Test
+ public void searchListAccountTest ()
+ {
+ /*// On recherche le compte 5 - COMPTES FINANCIERS
+ Account account = instance.searchAccount("5");
+ List<Account> listAccount = instance.searchListChildAccount(account);
+ // Il possède les comptes 50 et 51
+ Assert.assertEquals(2,listAccount.size());*/
+ }
+
+
+ /**
+ * Permet de tester le nombre d'enfants renvoyés appartenant à un père.
+ */
+ @Test
+ public void searchListAccountDTOTest ()
+ {
+ /*// On recherche le compte 5 - COMPTES FINANCIERS
+ AccountDTO accountDTO = instance.searchAccountDTO("5");
+ // Il possède les comptes 50 et 51
+ Assert.assertEquals(2,accountDTO.getAccountChildDTO().size());*/
+ }
+
+
+ /**
+ * Permet de tester la méthode recherchant tous les comptes au format DTO.
+ */
+ @Test
+ public void getAllAccountTest ()
+ {
+ /*List<AccountDTO> listAccountDTO = instance.getAllAccount();
+ // doit être égal à 2 (compte 4 et 5)
+ Assert.assertEquals(2,listAccountDTO.size());*/
+ }
+
+
+ /**
+ * Permet de tester si un compte est bien effacé. Si celui-ci n'existe pas
+ * un message d'avertissement doit apparaître.
+ * On supprime un compte avec seulement son numéro de compte (supposé/vérifié
+ * unique lors de la création).
+ */
+ @Test
+ public void removeAccountTest ()
+ {
+ /*String result;
+ // Création de comptes
+ instance.createAccount("40", "Fournisseurs", "4","actif");
+ instance.createAccount("41", "Usagers", "4","actif");
+ instance.createAccount("44", "Etat", "4","actif");
+
+ // On souhaite supprimer le compte 41. Ce compte existe bien. Il ne possède
+ // pas de fils. La suppression se déroule bien.
+ result = instance.removeAccount("41");
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+ // On recherche les fils du compte 4
+ List<Account> listAccount = instance.searchListChildAccount("4");
+ // Il ne doit en possèder que 2 (au lieu de 3)
+ Assert.assertEquals(2,listAccount.size());
+
+ // On souhaite supprimer le compte 422, ce dernier n'existe pas. La
+ // suppression ne peut s'effectuer.
+ result = instance.removeAccount("422");
+ Assert.assertEquals(ServiceHelper.ACCOUNT_NOT_EXIST,result);*/
+ }
+
+
+ /**
+ * Cette méthode permet de tester la mise à jour d'un compte au format DTO.
+ * Il suffit d'envoyer un compte DTO avec des ajouts, modifications, et
+ * suppression. Il est automatiquement mis à jour dans Callao.
+ * Cette méthode est intéressante, mais demande de la ressource importante.
+ * Dans ce test, nous utilitons le compte numéro 5. Ce dernier a pour enfants
+ * 50 et 51, dont 51 a à son tour les comptes enfants 511 et 512.
+ * Nous ajoutons un compte supplémentaire 53 à 5. Nous modifions une valeur
+ * sur le compte 5, et supprimons le compte 51 (et ses enfants).
+ */
+ @Test
+ public void updateTest ()
+ {
+ /*String result;
+ // On recherche le compte 5 - COMPTES FINANCIERS
+ AccountDTO accountDTO = instance.searchAccountDTO("5");
+ // {ETAPE 1} Modification du nom pour le compte 5
+ accountDTO.setLabel("COMPTES FINANCIERS modifié");
+ // {ETAPE 2} Ajout du compte 53
+ AccountDTO accountChildDTO = new AccountDTO("","53","Caisse","5",null,"actif");
+ accountDTO.addAccountChild(accountChildDTO);
+ // {ETAPE 3} Supprime le compte 51 (ainsi que ses enfants 511 et 512)
+ AccountDTO accountremoveDTO = instance.searchAccountDTO("51");
+ accountDTO.removeAccountChild(accountremoveDTO);
+ // Met à jour le compte 5 DTO dans la bdd ainsi que toutes les {ETAPE *}
+ result = instance.updateDTO(accountDTO);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+
+ // Vérification ETAPE
+
+ // ETAPE 1
+ Account account = instance.searchAccount("5");
+ Assert.assertEquals("COMPTES FINANCIERS modifié",account.getLabel());
+ // ETAPE 2
+ account = instance.searchAccount("53");
+ Assert.assertEquals("Caisse",account.getLabel());
+ // ETAPE 3
+ account = instance.searchAccount("5"); // les comptes fils de 5
+ List<Account> listAccount = instance.searchListChildAccount(account);
+ // Il doit avoir 50 et 53
+ Assert.assertEquals(2,listAccount.size());*/
+ }
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,60 @@
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.LogFactory;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests pour la gestion des entrées comptables
+ *
+ * La classe entry est une composte de la classe Transaction. En effet, cette
+ * dernière réunnit beaucoup de classes. Afin de faciliter la gestion des tests,
+ * la classe Test Transaction permet de tester également les entrys.
+ *
+ * @author Rémi Chapelet
+ */
+public class EntryServiceImplTest {
+
+ /** log. */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(EntryServiceImplTest.class);
+
+ private static EntryServiceImpl instance;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ /**
+ * On nettoie la base de données
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+
+ }
+
+ @Before
+ public void setUp() {
+ instance = new EntryServiceImpl();
+ }
+
+ public EntryServiceImplTest() {
+ }
+
+ /**
+ * Cette classe permet de contrôler les différentes saisies possibles dans
+ * Callao. Ces saisies sont transmises à la base de données par la classe
+ * Entry.
+ */
+ @Test
+ public void createEntryTest() {
+ /*String result = instance.createEntry("description", "200", true,
+ "lettering", "detail", null, null);
+ Assert.assertEquals(ServiceHelper.TRANSACTION_NOT_EXIST, result);*/
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,62 @@
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.LogFactory;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+/**
+ * Tests pour la gestion des comptes dans le plan comptable
+ *
+ * Vérification sur l'ajout, la modification et suppression d'un compte.
+ * Il existe également des tests sur des actions à partir de DTO. La classe
+ * AccountServiceImplTest possède une méthode upload qui, à partir d'un DTO,
+ * va mettre à jour automatiquement dans la base de données.
+ *
+ * @author Rémi Chapelet
+ */
+public class FilesServiceImplTest {
+
+ /** log. */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(FilesServiceImplTest.class);
+
+ private static FilesServiceImpl instance;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ /**
+ * On nettoie la base de données
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+
+ }
+
+ @Before
+ public void setUp() {
+ instance = new FilesServiceImpl();
+ }
+
+ public FilesServiceImplTest() {
+ }
+
+ /**
+ * Permet de tester la sauvegarde en document xml.
+ * Il existe un fichier dtd externe :
+ * 'callao-service/src/main/resources/save-callao.dtd'
+ */
+ @Test
+ public void fileTest() {
+ // Création sauvegarde
+ //String result = instance.exportDatas("/tmp/callao_save.xml");
+ //Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+ // Chargement sauvegarde
+ //instance.importDatas("/home/bombjack/save_big_lima");
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,128 @@
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.LogFactory;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rémi Chapelet
+ */
+public class GeneratorTest {
+
+ /** log. */
+ private static final org.apache.commons.logging.Log log = LogFactory.getLog(TransactionServiceImplTest.class);
+
+ private static TransactionServiceImpl instanceTransaction;
+ private static PeriodServiceImpl instancePeriod;
+ private static TimeSpanServiceImpl instanceTimespan;
+ private static JournalServiceImpl instanceJournal;
+ private static AccountServiceImpl instanceAccount;
+ private static String topiaIDTransaction;
+
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ @Before
+ public void setUp() {
+ instanceTransaction = new TransactionServiceImpl();
+ instancePeriod = new PeriodServiceImpl();
+ instanceTimespan = new TimeSpanServiceImpl();
+ instanceJournal = new JournalServiceImpl();
+ instanceAccount = new AccountServiceImpl();
+ }
+
+
+ /**
+ * Permet de tester l'ajout d'un timspan
+ */
+ @Test
+ public void generate ()
+ {
+ /*
+ // Création Journal
+ instanceJournal.createJournal("Journal des ventes", "jv","description");
+ instanceJournal.createJournal("Journal des achats", "ja","description");
+ instanceJournal.createJournal("Journal de trésorerie", "jt","description");
+ instanceJournal.createJournal("Journal des opérations diverses", "OD","description");
+ instanceJournal.createJournal("Journal de banque 1", "jb1","description");
+ instanceJournal.createJournal("Journal de banque 2", "jb2","description");
+ instanceJournal.createJournal("Journal de banque 3", "jb3","description");
+ instanceJournal.createJournal("Journal de banque 4", "jb4","description");
+ instanceJournal.createJournal("Journal de banque 5", "jb5","description");
+ instanceJournal.createJournal("Journal de banque 6", "jb6","description");
+ instanceJournal.createJournal("Journal de banque 7", "jb7","description");
+ instanceJournal.createJournal("Journal de banque 8", "jb8","description");
+
+ // Création account
+ instanceAccount.createAccount(1, "COMPTES DE CAPITAUX", null);
+ instanceAccount.createAccount(2, "COMPTES D'IMMOBILISATIONS", null);
+ instanceAccount.createAccount(3, "COMPTES DE STOCKS ET EN-COURS ", null);
+ instanceAccount.createAccount(4, "COMPTES DE TIERS ", null);
+ instanceAccount.createAccount(5, "COMPTES FINANCIERS", null);
+ instanceAccount.createAccount(6, "COMPTES DE CHARGES", null);
+ instanceAccount.createAccount(7, "COMPTES DE PRODUITS", null);
+ instanceAccount.createAccount(8, "COMPTES SPECIAUX", null);
+ instanceAccount.createAccount(10, "Capital et réserves", 1);
+ instanceAccount.createAccount(106, "Réserves", 10);
+ instanceAccount.createAccount(1061, "Réserve légale",106 );
+ instanceAccount.createAccount(1062, "Réserves indisponibles", 106);
+ instanceAccount.createAccount(1063, "Réserves statutaires ou contractuelles", 106);
+ instanceAccount.createAccount(1064, "Réserves réglementées", 106);
+ instanceAccount.createAccount(1068, "Autres réserves", 106);
+ instanceAccount.createAccount(11, "Report à nouveau (solde créditeur ou débiteur)", 1);
+ instanceAccount.createAccount(12, "Résultat de l'exercice (bénéfice ou perte)", 1);
+ instanceAccount.createAccount(14, "Provisions réglementées", 1);
+ instanceAccount.createAccount(15, "Provisions pour risques et charges", 1);
+ instanceAccount.createAccount(151, "Provisions pour risques", 15);
+ instanceAccount.createAccount(155, "Provisions pour impôts", 15);
+ instanceAccount.createAccount(20, "Immobilisations incorporelles", 2);
+ instanceAccount.createAccount(201, "Frais d'établissement", 20);
+ instanceAccount.createAccount(207, "Fonds commercial", 20);
+ instanceAccount.createAccount(21, "Immobilisations corporelles", 2);
+
+
+
+
+ Date beginTimeSpan;
+ Date endTimeSpan;
+ Date dateSearch;
+
+ for (int annee = 109 ; annee < 115 ; annee++)
+ {
+ beginTimeSpan = new Date(annee,0,1);
+ endTimeSpan = new Date(annee,11,31);
+ instancePeriod.createPeriod(beginTimeSpan, endTimeSpan, false);
+
+ for (int mois = 0 ; mois<11 ; mois++)
+ {
+ dateSearch = new Date(annee,mois,1);
+ TimeSpan timespan = instanceTimespan.searchTimeSpanByDate(dateSearch);
+
+ for (int j=0 ; j<50 ; j++)
+ {
+ Journal journal = instanceJournal.searchJournalWithLabel("Journal des ventes");
+
+ topiaIDTransaction = instanceTransaction.createTransaction(dateSearch, "Facture 6", "description transaction", timespan, journal);
+
+ Transaction transaction = instanceTransaction.searchTransactionWithTopiaId(topiaIDTransaction);
+
+ Account account = instanceAccount.searchAccount(1);
+
+ instanceTransaction.addEntry("entree1", "300", false, "lettering", "detail", transaction,account);
+ instanceTransaction.addEntry("entree2", "300", true, "lettering", "detail", transaction,account);
+ }
+ }
+ Period period = instancePeriod.searchPeriodWithDate(beginTimeSpan);
+ instancePeriod.blockAllTimeSpanOfPeriod(period);
+ instancePeriod.blockPeriod(period);
+ }
+ */
+ }
+
+
+}
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/JournalServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/JournalServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/JournalServiceImplTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,98 @@
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.LogFactory;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests pour la gestion des journaux
+ *
+ * L'application peut gérer plusieurs journaux pour la gestion des transactions.
+ * Il est tester ici l'ajout, la recherche.
+ *
+ * @author Rémi Chapelet
+ */
+public class JournalServiceImplTest {
+
+ /** log. */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(JournalServiceImplTest.class);
+
+ private static JournalServiceImpl instance;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ /**
+ * On nettoie la base de données
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ /*List<JournalDTO> list = instance.getAllJournal();
+ // On supprime chaque journal
+ for (JournalDTO journalDTO : list) {
+ instance.removeJournal(journalDTO);
+ }*/
+ }
+
+ @Before
+ public void setUp() {
+ instance = new JournalServiceImpl();
+ }
+
+ public JournalServiceImplTest() {
+ }
+
+ /**
+ * Permet de tester l'ajout d'un journal dans la base de données.
+ */
+ @Test
+ public void createJournalTest() {
+ /*String result = instance.createJournal("Journal des ventes", "jdv",
+ "description");
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);*/
+ }
+
+ /**
+ * Permet de tester l'ajout d'un journal sous format DTO.
+ */
+ @Test
+ public void createJournalDTOTest() {
+ /*JournalDTO journalDTO = new JournalDTO("", "Journal des achats", "jda",
+ "description");
+ String result = instance.createJournal(journalDTO);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);*/
+ }
+
+ /**
+ * Permet de tester la recherche d'un journal suivant son préfixe.
+ */
+ @Test
+ public void searchJournalWithLabelTest() {
+ /*Journal result = instance.searchJournalWithLabel("Journal des ventes");
+ Assert.assertEquals("Journal des ventes", result.getLabel());
+ result = instance.searchJournalWithLabel("Journal des achats");
+ Assert.assertEquals("Journal des achats", result.getLabel());*/
+ }
+
+ /**
+ * Permet de tester la modification d'un journal suivant son préfixe.
+ */
+ @Test
+ public void modifyJournalTest() {
+ /*Journal journal = instance.searchJournalWithLabel("Journal des ventes");
+ Assert.assertEquals("Journal des ventes", journal.getLabel());
+ String result = instance.modifyJournal(journal.getTopiaId(),
+ "Journal des ventes", "new_prefix", "new_description");
+ // Recherche du journal dans la bdd
+ JournalDTO journalDTO = instance
+ .searchJournalDTOWithLabel("Journal des ventes");
+ Assert.assertEquals("new_prefix", journalDTO.getPrefix());*/
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/JournalServiceImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/LogServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/LogServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/LogServiceImplTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,109 @@
+package org.chorem.lima.business;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.dto.LogDTO;
+import org.chorem.lima.entity.EntryLog;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests pour la gestion des timespans
+ * @author Rémi Chapelet
+ */
+public class LogServiceImplTest {
+
+ /** log. */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(UserServiceImplTest.class);
+
+ private static LogServiceImpl instance;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ @Before
+ public void setUp() {
+ instance = new LogServiceImpl();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ /*List<LogDTO> list = instance.listeAllLogDTO();
+ for (LogDTO logDTO : list)
+ {
+ instance.removeLog(logDTO);
+ }*/
+ }
+
+ /**
+ * Permet de tester la recherche de tous les logs
+ */
+ @Test
+ public void listeAllLogTest() {
+ /*// Ajout d'un log
+ Date logDate = new Date(2008,1,1);
+ Date transDate = new Date();
+ instance.addLog(logDate, transDate, "test", "test", "test",
+ "test", "test", true, "test");
+ // Recherche des logs
+ List<EntryLog> result = instance.listeAllLog();
+ if (log.isDebugEnabled()) {
+ log.debug("Nombre de log : " + result.size());
+ }
+ // trouve un log
+ Assert.assertEquals(1,result.size());*/
+ }
+
+ /**
+ * Test de la fonction de recherche de tous les logs suivant la date
+ * de création
+ */
+ @Test
+ public void searchDateCreateTest() {
+ /*// Ajout d'un log avec comme date de creation 01/01/2009
+ Date logDate = new Date(2009,1,1);
+ Date transDate = new Date();
+ instance.addLog(logDate, transDate, "test", "test", "test",
+ "test", "test", true, "test");
+ // Recherche des logs suivant la date
+ List<EntryLog> result = instance.searchLogWithDateCreate(logDate);
+ if (log.isDebugEnabled()) {
+ log.debug("Nombre de log recherche pour la date de creation : "
+ + result.size());
+ }
+ // Apres avoir inséré un log a la date, il doit obligatoirement
+ // avoir au moins un log.
+ Assert.assertEquals(1,result.size());*/
+ }
+
+ /**
+ * Permet de tester la recherche de logs en format DTO.
+ */
+ @Test
+ public void searchLogDTOWithDateCreate() {
+
+ // Création de trois logs DTO
+ /*Date logDate = new Date(2000,1,1);
+ Date transDate = new Date();
+ // Création logDTO
+ LogDTO logDTO = new LogDTO("",logDate, "test", transDate, "test", "test",
+ "test", "test", true, "test");
+ // Ajout de trois logs
+ instance.addLog(logDTO);
+ instance.addLog(logDTO);
+ instance.addLog(logDTO);
+ // Recherche de ses trois logs sous forme de list de DTO
+ List<LogDTO> listLogDTO = instance.searchLogDTOWithDateCreate(logDate);
+ Assert.assertEquals(3,listLogDTO.size());*/
+ }
+
+}
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/LogServiceImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/PeriodServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/PeriodServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/PeriodServiceImplTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,197 @@
+package org.chorem.lima.business;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.dto.PeriodDTO;
+import org.chorem.lima.business.dto.TimeSpanDTO;
+import org.chorem.lima.business.utils.ServiceHelper;
+import org.chorem.lima.entity.Period;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests pour la gestion des périodes
+ *
+ * Fonctions :
+ * _ création d'une période
+ * _ valider une période (si elle est correcte)
+ * _ bloquer une période (ATTENTION : on ne peut débloquer une période !)
+ * _ rechercher une période
+ *
+ * @author Rémi Chapelet
+ */
+public class PeriodServiceImplTest {
+
+ /** log. */
+ private static final Log log = LogFactory
+ .getLog(PeriodServiceImplTest.class);
+
+ private static PeriodServiceImpl instance;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ /**
+ * On nettoie la base de données
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ /*Date d = new Date(110,0,1);
+ PeriodDTO periodDTO = instance.searchPeriodDTOWithDate(d);
+ instance.removePeriod(periodDTO);
+ d = new Date(109,0,1);
+ periodDTO = instance.searchPeriodDTOWithDate(d);
+ instance.removePeriod(periodDTO);*/
+ }
+
+ /**
+ * Permet de tester l'ajout d'une période.
+ */
+ @Test
+ public void createPeriodTest() {
+ /*String result;
+ // debut 1 janvier 2009
+ Date beginPeriod = new Date(109, 0, 1);
+ // fin 31 décembre 2009
+ Date endPeriod = new Date(109, 11, 31);
+ // Création période avec son découpage sur 12 mois
+ result = instance.createPeriod(beginPeriod, endPeriod, false);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);*/
+ }
+
+ /**
+ * Permet de tester si différentes périodes sont correctes ou non
+ * La création d'une nouvelle période doit remplir ce contrat.
+ * On définit plusieurs périodes pour les créer dans Callao. Pour chaque
+ * création, la période est testée si elle est correcte ou non.
+ */
+ @Test
+ public void isCorrectPeriodTest() {
+ /*// Période déja créée Jan 2009 - Déc 2009 (et non bloquée) (createPeriodTest)
+ // debut 1 janvier 2010
+ Date beginPeriod = new Date(110, 0, 1);
+ // fin 1 février 2010
+ Date endPeriod = new Date(110, 1, 1);
+ String result;
+ // Cette période est non correcte, car il n'y a pas 12 mois complets
+ // Et la période précédente est non bloquée.
+ result = instance.createPeriod(beginPeriod, endPeriod, false);
+ Assert.assertEquals(ServiceHelper.RESPOND_ERROR, result);
+ // Création période sur 12 mois, MAIS période précédente non bloquée !
+ // fin 31 décembre 2010 pour avoir 12 mois complets
+ endPeriod = new Date(110, 11, 31);
+ result = instance.createPeriod(beginPeriod, endPeriod, false);
+ Assert.assertEquals(ServiceHelper.RESPOND_ERROR, result);
+ // Période précédente non bloquée et non collée au niveau des dates
+ // de début et fin
+ // debut 1 avril 2009
+ beginPeriod = new Date(109, 3, 1);
+ // fin 31 mars 2010
+ endPeriod = new Date(110, 2, 31);
+ result = instance.createPeriod(beginPeriod, endPeriod, false);
+ Assert.assertEquals(ServiceHelper.RESPOND_ERROR, result);
+ // Création période qui chevauche la période 2009.
+ // debut 1 fevrier 2008
+ beginPeriod = new Date(108, 1, 1);
+ // fin 1 janvier 2009
+ endPeriod = new Date(109, 0, 1);
+ result = instance.createPeriod(beginPeriod, endPeriod, false);
+ Assert.assertEquals(ServiceHelper.RESPOND_ERROR, result);*/
+ }
+
+ /**
+ * Permet de tester la recherche sur les périodes. Il suffit de donner une
+ * date quelconque, il est renvoyé alors la période dont l'intervalle de
+ * temps comprend cette date.
+ */
+ @Test
+ public void searchPeriodWithDateTest() {
+ /*// Période créée Jan 2009 - Déc 2009 (et non bloquée) (createPeriodTest)
+ // Date recherchée 17 avril 2009
+ Date dateSearch = new Date(109, 3, 17);
+ Period period = instance.searchPeriodWithDate(dateSearch);
+ assertTrue(period != null); // Période trouvée
+ // Date recherchée 17 septembre 2000
+ dateSearch = new Date(100, 8, 17);
+ period = instance.searchPeriodWithDate(dateSearch);
+ assertTrue(period == null); // Période non trouvée
+ // Recherche la période sur la date de debut de période.
+ // Date recherchée 1 janvier 2009
+ dateSearch = new Date(109, 0, 1);
+ period = instance.searchPeriodWithDate(dateSearch);
+ assertTrue(period != null); // Période trouvée
+ // Recherche la période sur la date de fin de période.
+ // Date recherchée 31 décembre 2009
+ dateSearch = new Date(109, 11, 31);
+ period = instance.searchPeriodWithDate(dateSearch);
+ assertTrue(period != null); // Période trouvée*/
+ }
+
+ /**
+ * Permet de tester si les périodes peuvent être bloquées ou non
+ * Test également la fonction permettant de bloquer tous les timespans
+ * d'une période.
+ */
+ @Test
+ public void blockPeriodTest() {
+ /*// Période créée Jan 2009 - Déc 2009 (et non bloquée) (createPeriodTest)
+ // debut 1 janvier 2009
+ Date beginTimeSpan = new Date(109, 0, 1);
+ String result;
+ // On souhaite bloquer la période, MAIS les timeSpans ne le sont pas
+ // On recherche la période Jan 2009 - Déc 2009
+ Period period = instance.searchPeriodWithDate(beginTimeSpan);
+ result = instance.blockPeriod(period);
+ Assert.assertEquals(ServiceHelper.PERIOD_TIMESPAN_NOT_BLOCK, result);
+ // On bloque tous les timeSpans et la période ensuite
+ result = instance.blockAllTimeSpanOfPeriod(period);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);
+ // On bloque de nouveau la période
+ result = instance.blockPeriod(period);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);*/
+ }
+
+ /**
+ * Permet de tester les objets DTO pour la période.
+ * Création d'une période 2015 avec la création des 12 timeSpans
+ */
+ @Test
+ public void PeriodDTOTest() {
+ /*// Création période DTO
+ Date dateBegin = new Date(110, 0, 1);
+ Date dateEnd = new Date(110, 11, 31);
+ PeriodDTO periodDTO = new PeriodDTO();
+ periodDTO.setBeginPeriod(dateBegin);
+ periodDTO.setEndPeriod(dateEnd);
+ // Création BDD
+ String result = instance.createPeriod(periodDTO);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);*/
+ }
+
+ /**
+ * Permet de tester la transformation d'une période en DTO avec ses timeSpans
+ * associés.
+ */
+ @Test
+ public void searchPeriodDTOTest() {
+ /*// Cherche la période 2009
+ Date dateBegin = new Date(109, 0, 1);
+ PeriodDTO periodDTO = instance.searchPeriodDTOWithDate(dateBegin);
+ Assert.assertEquals(dateBegin, periodDTO.getBeginPeriod());
+ // Recherche des timeSpanDTO
+ List<TimeSpanDTO> listTimeSpanDTO = periodDTO.getListTimeSpan();
+ // Nombre 12 timeSpans mensuels
+ Assert.assertEquals(12, listTimeSpanDTO.size());*/
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/PeriodServiceImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/TimeSpanServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/TimeSpanServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/TimeSpanServiceImplTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,97 @@
+package org.chorem.lima.business;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.utils.ServiceHelper;
+import org.chorem.lima.entity.TimeSpan;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests pour la gestion des timespans
+ *
+ * Fonctions :
+ * _ création d'un timespan
+ * _ bloquer un timespan
+ * _ débloquer un timespan
+ * _ rechercher un timespan
+ * _ rechercher une période à partir d'un timespan
+ *
+ * @author Rémi Chapelet
+ */
+public class TimeSpanServiceImplTest {
+
+ /** log. */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(TimeSpanServiceImplTest.class);
+
+ private static TimeSpanServiceImpl instance;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ /**
+ * On nettoie la base de données
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ /*Date beginTimeSpan = new Date(111,0,1);
+ TimeSpan timeSpan = instance.searchTimeSpanByDate(beginTimeSpan);
+ instance.removeTimeSpan(timeSpan);*/
+ }
+
+ @Before
+ public void setUp() {
+ instance = new TimeSpanServiceImpl();
+ }
+
+ public TimeSpanServiceImplTest() {
+ }
+
+ /**
+ * Permet de tester l'ajout d'un timspan
+ */
+ @Test
+ public void createTimeSpanTest() {
+ /*// debut 1 janvier 2011
+ Date beginTimeSpan = new Date(111, 0, 1);
+ // fin 15 janvier 2011
+ Date endTimeSpan = new Date(111, 0, 15);
+ String result;
+
+ // Création du timespan du 1 janvier au 31 janvier.
+ // Malgre la date de fin du 15 janvier, elle ne prend en compte que la
+ // date de début. La période a pour valeur nulle, et le timepsan est
+ // non bloqué.
+ result = instance.createTimeSpan(beginTimeSpan, endTimeSpan, null,
+ false);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);*/
+ }
+
+ /**
+ * Permet de tester la fonction rechercher pour un timespan. Si ce dernier
+ * n'est pas trouvé, l'objet de retour est nul.
+ */
+ @Test
+ public void findTimeSpanByMonthYearTest() {
+ /*// Il existe déja une période du 1 jan 2011 au 31 jan 2011 (createTimeSpanTest)
+ // debut 1 janvier 2011
+ Date dateSearch = new Date(111, 0, 1);
+ TimeSpan timespan = instance.searchTimeSpanByDate(dateSearch);
+ assertTrue(timespan != null); // Trouve bien le timespan
+ // debut 1 mai 2011
+ dateSearch = new Date(111, 4, 1);
+ timespan = instance.searchTimeSpanByDate(dateSearch);
+ assertTrue(timespan == null); // Ne le trouve pas */
+ }
+
+}
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/TimeSpanServiceImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/TransactionServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/TransactionServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/TransactionServiceImplTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,619 @@
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests pour la gestion des transactions
+ *
+ * Cette classe de test est principale au bon fonctionnement de l'application.
+ * Elle centralise au maximum l'ensemble des règles de la couche métier. En effet
+ * elle possède le plus de liens avec les autres classes.
+ * A partir de la classe de test, nous allons créer plusieurs transactions pour
+ * vérifier le bon fonctionnement des classes réunies ensemble.
+ *
+ * @author Rémi Chapelet
+ */
+public class TransactionServiceImplTest {
+
+ /** log. */
+ private static final Log log = LogFactory
+ .getLog(TransactionServiceImplTest.class);
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ /**
+ * On nettoie la base de données
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ /*LogServiceImpl serviceLog = new LogServiceImpl();
+ // Supprime Log
+ List<LogDTO> listLog = serviceLog.listeAllLogDTO();
+ for (LogDTO logDTO : listLog)
+ {
+ serviceLog.removeLog(logDTO);
+ }*/
+
+ }
+
+ /**
+ * Permet de tester l'ajout d'un timspan
+ */
+ @Test
+ public void createTransactionTest() {
+ /*log.info("BEGIN createTransactionTest()");
+
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+
+ // Creation Period & TimeSpan (default period 01/01/2010 -> 31/12/2010)
+ TimeSpan timespan = createPeriod(servicePeriod);
+
+ // Creation Journal
+ Journal journal = createJournal(serviceJournal,"Journal transaction", "jt","description");
+
+ // Test creationTransaction avec Journal et TimeSpan
+ String transactionId = createTransaction(serviceTransaction, "Facture 6", "description transaction", timespan, journal);
+
+ // NETTOYAGE TEST
+ removeTransaction(serviceTransaction, transactionId);
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // FIN NETTOYAGE TEST
+ */
+ }
+
+ /**
+ * Recherche des transactions.
+ */
+ @Test
+ public void searchTransactionTest() {
+ /*log.info("BEGIN searchTransactionTest()");
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+
+ // PREPARATION TEST
+ // Default period 01/01/2010 -> 31/12/2010
+ TimeSpan timespan = createPeriod(servicePeriod);
+ Journal journal = createJournal(serviceJournal,"Journal transaction", "jt","description");
+ String transactionId = createTransaction(serviceTransaction, "Facture 6", "description transaction", timespan, journal);
+ // FIN PREPARATION TEST
+
+ // Recherche de la transaction suivant ce timeSpan.
+ List<Transaction> listTransaction = serviceTransaction.searchListTransactionWithTimeSpan(timespan);
+ Assert.assertEquals(1,listTransaction.size());
+ // On prend le premier élément de la liste de transactions
+ Transaction transaction = listTransaction.get(0);
+ // Si c'est la bonne transaction
+ Assert.assertEquals("Facture 6",transaction.getVoucherRef());
+
+ // NETTOYAGE TEST
+ removeTransaction(serviceTransaction, transactionId);
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // FIN NETTOYAGE TEST */
+ }
+
+ /**
+ * Permet de tester la recherche d'une transaction avec son identifiant.
+ * Ce dernier est une chaine de caractère. Elle a été inscrite dans la variable
+ * topiaIdTransaction dans les tests auparavant afin d'éviter les mêmes recherches
+ * pour chaque test.
+ */
+ @Test
+ public void searchWithTopiaIdTest() {
+ /*log.info("BEGIN searchWithTopiaIdTest()");
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+
+ // PREPARATION TEST
+ // Default period 01/01/2010 -> 31/12/2010
+ TimeSpan timespan = createPeriod(servicePeriod);
+ Journal journal = createJournal(serviceJournal,"Journal transaction", "jt","description");
+ String transactionId = createTransaction(serviceTransaction, "Facture 6", "description transaction", timespan, journal);
+ // FIN PREPARATION TEST
+
+ // Recherche de la transaction avec son identifiant.
+ Transaction transaction = serviceTransaction.searchTransactionWithTopiaId(transactionId);
+ // Si c'est la bonne transaction
+ Assert.assertEquals("Facture 6",transaction.getVoucherRef());
+
+ // NETTOYAGE TEST
+ removeTransaction(serviceTransaction, transactionId);
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // FIN NETTOYAGE TEST */
+ }
+
+ /**
+ * Recherche d'une transaction, retourner sous format DTO.
+ */
+ @Test
+ public void searchTransactionDTOTest() {
+ /*log.info("BEGIN searchTransactionDTOTest()");
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+
+ // PREPARATION TEST
+ // Default period 01/01/2010 -> 31/12/2010
+ TimeSpan timespan = createPeriod(servicePeriod);
+ Journal journal = createJournal(serviceJournal,"Journal transaction", "jt","description");
+ String transactionId = createTransaction(serviceTransaction, "Facture 6", "description transaction", timespan, journal);
+ // FIN PREPARATION TEST
+
+ // Recherche de la transaction à l'aide de son identifiant.
+ TransactionDTO transactionDTO = serviceTransaction.searchTransactionDTO(transactionId);
+ // Vérifie si la transaction DTO est correcte.
+ Assert.assertEquals("Facture 6",transactionDTO.getVoucherRef());
+ // Charge le journalDTO à partir de la transactionDTO
+ JournalDTO journalDTO = transactionDTO.getJournalDTO();
+ Assert.assertEquals("jt",journalDTO.getPrefix()); // Si c'est le bon journal
+ // Charge le timespanDTO à partir de la transactionDTO
+ TimeSpanDTO timeSpanDTO = transactionDTO.getTimeSpanDTO();
+ // debut 1 janvier 2010 - vérifie si c'est la même période
+ Date beginTimeSpan = new Date(110,0,1);
+ Assert.assertEquals(beginTimeSpan,timeSpanDTO.getBeginTimeSpan());
+
+ // NETTOYAGE TEST
+ removeTransaction(serviceTransaction, transactionId);
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // FIN NETTOYAGE TEST */
+ }
+
+ /**
+ * Test la modification d'une transaction.
+ */
+ @Test
+ public void modifyTransactionTest() {
+ /*log.info("BEGIN modifyTransactionTest()");
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+
+ // PREPARATION TEST
+ // Default period 01/01/2010 -> 31/12/2010
+ TimeSpan timespan = createPeriod(servicePeriod);
+ Journal journal = createJournal(serviceJournal,"Journal transaction", "jt","description");
+ String transactionId = createTransaction(serviceTransaction, "Facture 6", "description transaction", timespan, journal);
+ TransactionDTO transactionDTO = serviceTransaction.searchTransactionDTO(transactionId);
+ // FIN PREPARATION TEST
+
+ // On modifie la référence du fichier.
+ transactionDTO.setVoucherRef("Nouvelle facture");
+ String result = serviceTransaction.modifyTransaction(transactionDTO);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+ // On recherche la transaction dans la base de données.
+ Transaction transaction = serviceTransaction.searchTransactionWithTopiaId(transactionId);
+ Assert.assertEquals("Nouvelle facture",transaction.getVoucherRef());
+
+ // NETTOYAGE TEST
+ removeTransaction(serviceTransaction, transactionId);
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // FIN NETTOYAGE TEST */
+ }
+
+ /**
+ * Permet de tester l'ajout d'une transaction au format DTO.
+ */
+ @Test
+ public void createTransactionDTOTest() {
+ /*log.info("BEGIN createTransactionDTOTest()");
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TimeSpanServiceImpl serviceTimespan = new TimeSpanServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+
+ // PREPARATION TEST
+ // Default period 01/01/2010 -> 31/12/2010
+ TimeSpan timespan = createPeriod(servicePeriod);
+ Journal journal = createJournal(serviceJournal, "Journal transaction",
+ "jt", "description");
+ String transactionId = createTransaction(serviceTransaction,
+ "Facture 6", "description transaction", timespan, journal);
+ // FIN PREPARATION TEST
+
+ TransactionDTO transactionDTO = new TransactionDTO();
+ Date dateTransaction = new Date();
+ transactionDTO.setEntryDate(dateTransaction);
+ transactionDTO.setVoucherRef("Commande");
+ transactionDTO.setDescription("No comment");
+ // Il n'y a pas de timeSpan et journal attachés à la transaction
+ // ce qui créé une erreur lors de la création
+ String result = serviceTransaction.createTransaction(transactionDTO);
+ Assert.assertEquals(ServiceHelper.TRANSACTION_NOT_JOURNAL, result);
+ // On fournit à transactionDTO un timeSpan valide
+ // debut 1 janvier 2010
+ Date dateSearch = timespan.getBeginTimeSpan();
+ TimeSpanDTO timeSpanDTO = serviceTimespan
+ .searchTimeSpanDTOByDate(dateSearch);
+ transactionDTO.setTimeSpanDTO(timeSpanDTO);
+ // On fournit à transactionDTO un journal NON valide (non présent dans la BDD)
+ JournalDTO journalDTO = new JournalDTO();
+ journalDTO.setLabel("existe pas");
+ transactionDTO.setJournalDTO(journalDTO);
+ // Ajout de la transaction avec erreur avec le journalDTO
+ result = serviceTransaction.createTransaction(transactionDTO);
+ Assert.assertEquals(ServiceHelper.TRANSACTION_NOT_JOURNAL, result);
+
+ // Ajout d'un journalDTO valide
+ journalDTO = serviceJournal
+ .searchJournalDTOWithLabel("Journal transaction");
+ transactionDTO.setJournalDTO(journalDTO);
+ result = serviceTransaction.createTransaction(transactionDTO);
+
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+
+ //Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+ // Vérifie le nombre de transactions (égal à deux)
+ TimeSpan timeSpan = serviceTimespan.searchTimeSpanByDate(dateSearch);
+ List<TransactionDTO> listTransactionDTO = serviceTransaction
+ .searchListTransactionDTOWithTimeSpan(timeSpan);
+ Assert.assertEquals(2, listTransactionDTO.size());
+
+ // pour effacer par la suite les transactions à la fin des tests
+ // Vérifie si la 1ière transaction est celle deja inscrite
+ transactionDTO = listTransactionDTO.get(0);
+ String transactionId2;
+ if (transactionDTO.getId().equals(transactionId)) {
+ transactionId2 = listTransactionDTO.get(1).getId();
+ } else // ??????
+ {
+ transactionId2 = transactionDTO.getId();
+ }
+
+ // NETTOYAGE TEST
+ removeTransaction(serviceTransaction, transactionId);
+ removeTransaction(serviceTransaction, transactionId2);
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // FIN NETTOYAGE TEST */
+ }
+
+ /**
+ * Permet de tester l'ajout d'entrées sur une transaction.
+ */
+ @Test
+ public void addEntryTest() {
+ /*log.info("BEGIN addEntryTest()");
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+ AccountServiceImpl serviceAccount = new AccountServiceImpl();
+
+ // PREPARATION TEST
+ // Default period 01/01/2010 -> 31/12/2010
+ TimeSpan timespan = createPeriod(servicePeriod);
+ Journal journal = createJournal(serviceJournal, "Journal transaction",
+ "jt", "description");
+ String transactionId = createTransaction(serviceTransaction,
+ "Facture 6", "description transaction", timespan, journal);
+ // FIN PREPARATION TEST
+
+ // On recherche la transaction dans la base de données.
+ Transaction transaction = serviceTransaction
+ .searchTransactionWithTopiaId(transactionId);
+ // On créé le compte 8 et recherche cet account dans la base de données
+ Account account = createAccount(serviceAccount, "8", "Compte essai",
+ "0", "actif");
+ createAccount(serviceAccount, "81", "Compte essai 81", "8", "actif");
+ // Ajout entrée : 300 euros en crédit
+ String result = serviceTransaction.addEntry("entree1", "300", false,
+ "lettering", "detail", transaction, account);
+
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+
+ //Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+ // Ajout entrée : 300 euros en débit
+ result = serviceTransaction.addEntry("entree2", "300", true,
+ "lettering", "detail", transaction, account);
+
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+
+ //Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+
+ // NETTOYAGE TEST
+ // Les entrees sont supprimees avec la transaction (composition)
+ removeTransaction(serviceTransaction, transactionId);
+ serviceAccount.removeAccount("8");
+ serviceAccount.removeAccount("81");
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // N NETTOYAGE TEST */
+ }
+
+ /**
+ * Recherche les entrées suivant la transaction.
+ */
+ @Test
+ public void searchEntryTest() {
+ /*log.info("BEGIN searchEntryTest()");
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+ AccountServiceImpl serviceAccount = new AccountServiceImpl();
+ EntryServiceImpl serviceEntry = new EntryServiceImpl();
+
+ // PREPARATION TEST
+ // Default period 01/01/2010 -> 31/12/2010
+ TimeSpan timespan = createPeriod(servicePeriod);
+ Journal journal = createJournal(serviceJournal, "Journal transaction",
+ "jt", "description");
+ String transactionId = createTransaction(serviceTransaction,
+ "Facture 6", "description transaction", timespan, journal);
+ Transaction transaction = serviceTransaction
+ .searchTransactionWithTopiaId(transactionId);
+ Account account = createAccount(serviceAccount, "8", "Compte essai",
+ "0", "actif");
+ createAccount(serviceAccount, "81", "Compte essai 81", "8", "actif");
+ serviceTransaction.addEntry("entree1", "300", false, "lettering",
+ "detail", transaction, account);
+ serviceTransaction.addEntry("entree2", "300", true, "lettering",
+ "detail", transaction, account);
+ // FIN PREPARATION TEST
+
+ List<EntryDTO> listEntryDTO = serviceEntry
+ .searchEntryDTOWithTransaction(transaction);
+ // On doit trouver deux entrées.
+ Assert.assertEquals(2, listEntryDTO.size());
+
+ // Vérifie pour le DTO si tout est complet
+
+ // Prend le premier entry
+ AccountDTO accountDTO = listEntryDTO.get(0).getAccountDTO();
+ // Trouve le compte 8
+ Assert.assertEquals("8", accountDTO.getAccountNumber());
+ // Trouve le compte 81
+ accountDTO = accountDTO.getAccountChildDTO().get(0);
+ Assert.assertEquals("81", accountDTO.getAccountNumber());
+
+ // NETTOYAGE TEST
+ removeTransaction(serviceTransaction, transactionId);
+ serviceAccount.removeAccount("8");
+ serviceAccount.removeAccount("81");
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // FIN NETTOYAGE TEST */
+ }
+
+ /**
+ * Permet de tester la modification d'une entrée comptable.
+ */
+ @Test
+ public void modifyEntry() {
+ /*log.info("BEGIN modifyEntry()");
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+ AccountServiceImpl serviceAccount = new AccountServiceImpl();
+ EntryServiceImpl serviceEntry = new EntryServiceImpl();
+
+ // PREPARATION TEST
+ // Default period 01/01/2010 -> 31/12/2010
+ TimeSpan timespan = createPeriod(servicePeriod);
+ Journal journal = createJournal(serviceJournal, "Journal transaction",
+ "jt", "description");
+ String transactionId = createTransaction(serviceTransaction,
+ "Facture 6", "description transaction", timespan, journal);
+ Transaction transaction = serviceTransaction
+ .searchTransactionWithTopiaId(transactionId);
+ Account account = createAccount(serviceAccount, "8", "Compte essai",
+ "0", "actif");
+ serviceTransaction.addEntry("entree1", "300", false, "lettering",
+ "detail", transaction, account);
+ serviceTransaction.addEntry("entree2", "300", true, "lettering",
+ "detail", transaction, account);
+ // FIN PREPARATION TEST
+
+ // Recherche les deux entry en format DTO
+ List<EntryDTO> listEntryDTO = serviceEntry
+ .searchEntryDTOWithTransaction(transaction);
+ Assert.assertEquals(2, listEntryDTO.size());
+ Assert.assertTrue(listEntryDTO.size() > 0);
+ // Premier DTO
+ EntryDTO entryDTO = listEntryDTO.get(0);
+ entryDTO.setAmount("800");
+ String result = serviceTransaction.modifyEntry(entryDTO);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);
+ // Second DTO
+ entryDTO = listEntryDTO.get(1);
+ entryDTO.setAmount("800");
+
+ // Modification de l'entrée dans la bdd.
+ result = serviceTransaction.modifyEntry(entryDTO);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);
+ // Vérifie que les deux DTO ont bien été modifiés.
+ listEntryDTO = serviceEntry.searchEntryDTOWithTransaction(transaction);
+ entryDTO = listEntryDTO.get(0);
+ Assert.assertEquals("800,00", entryDTO.getAmount());
+
+ // NETTOYAGE TEST
+ removeTransaction(serviceTransaction, transactionId);
+ serviceAccount.removeAccount("8");
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // FIN NETTOYAGE TEST */
+ }
+
+ /**
+ * Test la suppression d'une entry.
+ */
+ @Test
+ public void removeEntryTest() {
+ /*log.info("BEGIN removeEntryTest()");
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+ AccountServiceImpl serviceAccount = new AccountServiceImpl();
+ EntryServiceImpl serviceEntry = new EntryServiceImpl();
+
+ // PREPARATION TEST
+ // Default period 01/01/2010 -> 31/12/2010
+ TimeSpan timespan = createPeriod(servicePeriod);
+ Journal journal = createJournal(serviceJournal, "Journal transaction",
+ "jt", "description");
+ String transactionId = createTransaction(serviceTransaction,
+ "Facture 6", "description transaction", timespan, journal);
+ Transaction transaction = serviceTransaction
+ .searchTransactionWithTopiaId(transactionId);
+ Account account = createAccount(serviceAccount, "8", "Compte essai",
+ "0", "actif");
+ serviceTransaction.addEntry("entree1", "300", false, "lettering",
+ "detail", transaction, account);
+ serviceTransaction.addEntry("entree2", "300", true, "lettering",
+ "detail", transaction, account);
+ // FIN PREPARATION TEST
+
+ List<EntryDTO> listEntryDTO = serviceEntry
+ .searchEntryDTOWithTransaction(transaction);
+ // Prend le premier DTO
+ EntryDTO entryDTO = listEntryDTO.get(0);
+ // Supprime cette entrée
+ String result = serviceTransaction.removeEntry(entryDTO.getId());
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);
+ // Recherche dans la base de données les entrys
+ listEntryDTO = serviceEntry.searchEntryDTOWithTransaction(transaction);
+ // Trouve un seul entry DTO
+ Assert.assertEquals(1, listEntryDTO.size());
+
+ // NETTOYAGE TEST
+ removeTransaction(serviceTransaction, transactionId);
+ serviceAccount.removeAccount("8");
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // FIN NETTOYAGE TEST */
+ }
+
+ /**
+ * Test la suppression d'une transaction et ses entrées.
+ */
+ @Test
+ public void removeTransactionTest() {
+ /*log.info("BEGIN removeEntryTest()");
+ PeriodServiceImpl servicePeriod = new PeriodServiceImpl();
+ TransactionServiceImpl serviceTransaction = new TransactionServiceImpl();
+ JournalServiceImpl serviceJournal = new JournalServiceImpl();
+ AccountServiceImpl serviceAccount = new AccountServiceImpl();
+ EntryServiceImpl serviceEntry = new EntryServiceImpl();
+
+ // PREPARATION TEST
+ // Default period 01/01/2010 -> 31/12/2010
+ TimeSpan timespan = createPeriod(servicePeriod);
+ Journal journal = createJournal(serviceJournal, "Journal transaction",
+ "jt", "description");
+ String transactionId = createTransaction(serviceTransaction,
+ "Facture 6", "description transaction", timespan, journal);
+ Transaction transaction = serviceTransaction
+ .searchTransactionWithTopiaId(transactionId);
+ Account account = createAccount(serviceAccount, "8", "Compte essai",
+ "0", "actif");
+ serviceTransaction.addEntry("entree1", "300", false, "lettering",
+ "detail", transaction, account);
+ // FIN PREPARATION TEST
+
+ // Supprime cette transaction
+ String result = serviceTransaction.removeTransaction(transactionId);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);
+ // Recherche dans la base de données les entrys
+ transaction = serviceTransaction
+ .searchTransactionWithTopiaId(transactionId);
+ List<EntryDTO> listEntryDTO = serviceEntry
+ .searchEntryDTOWithTransaction(transaction);
+ Assert.assertEquals(0, listEntryDTO.size());
+
+ // NETTOYAGE TEST
+ serviceAccount.removeAccount("8");
+ removeJournals(serviceJournal);
+ removePeriod(servicePeriod);
+ // FIN NETTOYAGE TEST */
+ }
+
+ /*
+ private TimeSpan createPeriod(PeriodServiceImpl servicePeriod) {
+ /*TimeSpanServiceImpl serviceTimespan = new TimeSpanServiceImpl();
+ // debut 1 janvier 2010
+ Date beginTimeSpan = new Date(110, 0, 1);
+ // fin 31 décembre 2010
+ Date endTimeSpan = new Date(110, 11, 31);
+ // Création période avec son découpage sur 12 mois
+ String result = servicePeriod.createPeriod(beginTimeSpan, endTimeSpan,
+ false);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);
+ // Recherche du timespan 1 janv au 31 janv 2010
+ //Date dateSearch = new Date(110,0,1);
+ TimeSpan timespan = serviceTimespan.searchTimeSpanByDate(beginTimeSpan);
+ return timespan;
+ }
+
+ private void removePeriod(PeriodServiceImpl servicePeriod) {
+ // Supprime Period & TimeSpan
+ Date d = new Date(110, 0, 1);
+ PeriodDTO periodDTO = servicePeriod.searchPeriodDTOWithDate(d);
+ servicePeriod.removePeriod(periodDTO);
+ }
+
+ private Journal createJournal(JournalServiceImpl serviceJournal,
+ String label, String prefix, String description) {
+ // Création Journal
+ String result = serviceJournal
+ .createJournal(label, prefix, description);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);
+ // Recherche du journal pour l'ajouter dans la transaction
+ Journal journal = serviceJournal.searchJournalWithLabel(label);
+ Assert.assertNotNull(journal);
+ return journal;
+ }
+
+ private void removeJournals(JournalServiceImpl serviceJournal) {
+ // Supprime Journal
+ List<JournalDTO> listJournal = serviceJournal.getAllJournal();
+ for (JournalDTO journalDTO : listJournal) {
+ serviceJournal.removeJournal(journalDTO);
+ }
+ }
+
+ private String createTransaction(TransactionServiceImpl serviceTransaction,
+ String voucherRef, String description, TimeSpan timespan,
+ Journal journal) {
+ // Création d'une transaction
+ String transactionId = serviceTransaction
+ .createTransaction(timespan.getBeginTimeSpan(), voucherRef,
+ description, timespan, journal);
+
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+
+ //Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+ Assert.assertFalse(transactionId.equals(ServiceHelper.RESPOND_ERROR));
+ log.debug("RESULT createTransaction : " + transactionId);
+ return transactionId;
+ }
+
+ private void removeTransaction(TransactionServiceImpl serviceTransaction,
+ String transactionId) {
+ String result = serviceTransaction.removeTransaction(transactionId);
+ Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);
+ }
+
+ private Account createAccount(AccountServiceImpl serviceAccount,
+ String accountNumber, String label, String masterAccountNumber,
+ String type) {
+ serviceAccount.createAccount(accountNumber, label, masterAccountNumber,
+ type);
+ Account account = serviceAccount.searchAccount(accountNumber);
+ Assert.assertEquals(accountNumber, account.getAccountNumber());
+ return account;
+ }*/
+}
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/TransactionServiceImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/UserServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/UserServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/UserServiceImplTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,51 @@
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests pour la gestion des timespans
+ * @author Rémi Chapelet
+ */
+public class UserServiceImplTest {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(UserServiceImplTest.class);
+
+ private UserServiceImpl instance;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ @Before
+ public void setUp() {
+ instance = new UserServiceImpl();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+
+ }
+
+ public UserServiceImplTest() {
+ }
+
+ /**
+ * Permet de tester l'ajout d'un utilisateur dans la base de données
+ */
+ @Test
+ public void addUserTest() {
+ /*String result = instance.addUser("test-add-user");
+ if (log.isDebugEnabled()) {
+ log.debug("Ajout utilisateur (name is test-add-user) : result " + result);
+ }
+ Assert.assertEquals("success", instance.findUser("test-add-user"));*/
+ }
+
+}
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/UserServiceImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/java/org/chorem/lima/business/utils/NumberUtilTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/utils/NumberUtilTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/utils/NumberUtilTest.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,78 @@
+package org.chorem.lima.business.utils;
+
+
+import java.util.List;
+
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.utils.NumberUtil;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests pour la gestion des comptes sous forme DTO.
+ * Attention, il est testé seulement les objets DTO, et par conséquent, il n'a
+ * aucun enregistrement dans la base de données.
+ *
+ * @author Rémi Chapelet
+ */
+public class NumberUtilTest {
+
+ /** log. */
+ private static final org.apache.commons.logging.Log log = LogFactory.getLog(NumberUtilTest.class);
+
+
+
+ public NumberUtilTest() {
+ }
+
+
+ /**
+ * TODO
+ * AUCUN tests, juste des affichages. Cette classe doit être modifiée par
+ * la suite pour s'assurer du bon rendu pour formater les nombres.
+ */
+ @Test
+ public void numberFormatTest ()
+ {
+ NumberUtil num = new NumberUtil();
+ String theDouble = "100,5000";
+ String resultat = num.format(theDouble);
+
+ if (log.isInfoEnabled()) {
+ log.info("Resultat "+theDouble+" Donne "+resultat);
+ }
+
+ theDouble = "100,552";
+ resultat = num.format(theDouble);
+ if (log.isInfoEnabled()) {
+ log.info("Resultat "+theDouble+" Donne "+resultat);
+ }
+ theDouble = "100,553";
+ resultat = num.format(theDouble);
+ if (log.isInfoEnabled()) {
+ log.info("Resultat "+theDouble+" Donne "+resultat);
+ }
+ theDouble = "100,554";
+ resultat = num.format(theDouble);
+ if (log.isInfoEnabled()) {
+ log.info("Resultat "+theDouble+" Donne "+resultat);
+ }
+ theDouble = "100,555";
+ resultat = num.format(theDouble);
+ if (log.isInfoEnabled()) {
+ log.info("Resultat "+theDouble+" Donne "+resultat);
+ }
+ theDouble = "101,545";
+ resultat = num.format(theDouble);
+ if (log.isInfoEnabled()) {
+ log.info("Resultat "+theDouble+" Donne "+resultat);
+ }
+ theDouble = "102,565";
+ resultat = num.format(theDouble);
+ if (log.isInfoEnabled()) {
+ log.info("Resultat "+theDouble+" Donne "+resultat);
+ }
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/utils/NumberUtilTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/test/resources/lima_test.properties
===================================================================
--- trunk/lima-business/src/test/resources/lima_test.properties (rev 0)
+++ trunk/lima-business/src/test/resources/lima_test.properties 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,17 @@
+# Proprietes par defaut pour une base de donnees de type H2
+hibernate.hbm2ddl.auto=update
+hibernate.show_sql=false
+
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.username=sa
+hibernate.connection.password=
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.connection.url=jdbc:h2:file:target/lima/limadb
+
+# Permet de preciser les classes a utiliser
+#topia.persistence.classes=org.chorem.callao.entity.AccountImpl, \
+#org.chorem.callao.entity.ClientImpl, \
+#org.chorem.callao.entity.EntryImpl, org.chorem.callao.entity.PeriodImpl, \
+#org.chorem.callao.entity.JournalImpl, org.chorem.callao.entity.ProjectImpl, \
+#org.chorem.callao.entity.TimeSpanImpl, org.chorem.callao.entity.TransactionImpl, \
+#org.chorem.callao.entity.UsersImpl, org.chorem.callao.entity.LogImpl
Added: trunk/lima-callao/LICENSE.txt
===================================================================
--- trunk/lima-callao/LICENSE.txt (rev 0)
+++ trunk/lima-callao/LICENSE.txt 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Added: trunk/lima-callao/README.txt
===================================================================
--- trunk/lima-callao/README.txt (rev 0)
+++ trunk/lima-callao/README.txt 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1 @@
+TODO
\ No newline at end of file
Added: trunk/lima-callao/changelog.txt
===================================================================
--- trunk/lima-callao/changelog.txt (rev 0)
+++ trunk/lima-callao/changelog.txt 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,2 @@
+0.1 ??? 200902??
+ * 20090128 [chemit] - initial release
\ No newline at end of file
Added: trunk/lima-callao/pom.xml
===================================================================
--- trunk/lima-callao/pom.xml (rev 0)
+++ trunk/lima-callao/pom.xml 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,77 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.chorem</groupId>
+ <artifactId>lima</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.chorem.lima</groupId>
+ <artifactId>lima-callao</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Lima callao</name>
+ <description>Module persistence de Lima (Callao)</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <build>
+ <plugins>
+ <!-- Plugin Topia -->
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>maven-eugene-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <configuration>
+ <inputs>zargo</inputs>
+ <templates>org.nuiton.topia.generator.TopiaMetaGenerator, org.nuiton.topia.generator.DTOGenerator</templates>
+ <defaultPackage>org.chorem.lima.entity</defaultPackage>
+ <fullPackagePath>org.chorem.lima</fullPackagePath>
+ </configuration>
+ <goals>
+ <goal>smart-generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties (rev 0)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,4 @@
+# Precise l'entete de l'ensemble des fichiers generes
+model.tagvalue.copyright=/* *##%\n Copyright (C) 2009-2010 Lima Callao\n *##%*/
+#model.tagvalue.dbSchema=Callao
+model.tagvalue.String=text
\ No newline at end of file
Added: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Property changes on: trunk/lima-callao/src/main/xmi/accounting.zargo
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-callao/src/main/xmi/accountingdto.zargo
===================================================================
(Binary files differ)
Property changes on: trunk/lima-callao/src/main/xmi/accountingdto.zargo
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: trunk/lima-swing/dev.sh
===================================================================
--- trunk/lima-main/dev.sh 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/dev.sh 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,136 +0,0 @@
-#!/bin/sh
-
-
-###############################################################################
-####### parse arguments #######################################################
-###############################################################################
-
-#TODO Generate via commadline:generateGo
-#TEMP=`getopt -o kcjuodn:: --long clean,compile,jar,upline,debug,nosuspend,output:: \
-# -n 'dev.sh' -- "$@"`
-#if [ $? != 0 ] ; then
-# echo "bag argument"
-# exit 1
-#fi
-#eval set -- "$TEMP"
-
-CLEAN=""
-COMPILE=""
-DEV="classes"
-OFF_LINE="-o "
-MOUTPUT="target/maven.log"
-while true; do
- case "$1" in
- -k|--clean)
- CLEAN="clean"
- shift;;
- -c|--compile)
- COMPILE="compile"
- shift;;
- -j|--jar)
- DEV="jar"
- shift;;
- -u|--upline)
- OFF_LINE=""
- shift;;
- -o|--output)
- MOUTPUT="$1"
- shift;;
- -d|--debug)
- echo "Debug mode"
- #DEBUG="-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=38000,server=y"
- DEBUG="-server -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
- shift ;;
- -n|--nosuspend)
- echo "Debug no suspend mode"
- DEBUG="$DEBUG,suspend=n"
- shift ;;
- \-\-) shift ; break ;;
- *) break;
- esac
-done
-
-###############################################################################
-####### init variables ########################################################
-###############################################################################
-
-#JAVA="/opt/repository/jdk1.6.0/bin/java -splash:src/resources/images/splash2.jpg"
-#JAVA="java -Djava.library.path=lib -splash:src/resources/images/splash2.jpg"
-
-JAVA=java
-
-dir=$(dirname $0)
-cd $dir
-
-# Warning, pom.xml must have xmlns info on his root node!
-VER=$(xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:parent/p:version" pom.xml)
-
-RELEASE="lima-main-$VER"
-MAIN_CLASS="org.chorem.lima.Main"
-MX=512M
-
-rep=`dirname $0`
-rep=`cd $rep && pwd`
-
-cd $rep
-
-###############################################################################
-####### build required maven goals ############################################
-###############################################################################
-MVN_ACTION=
-if [ "$CLEAN" = "clean" ]; then
- MVN_ACTION="clean compile"
- if [ "$DEV" = "jar" ]; then
- MVN_ACTION="$MVN_ACTION package"
- fi
-else
- #if [ ! -d $rep/target/dependency ]; then
- # MVN_ACTION="$MVN_ACTION dependency:copy-dependencies"
- #fi
- if [ ! -d $rep/target/classes -o "$COMPILE" = "compile" ]; then
- MVN_ACTION="$MVN_ACTION compile "
- else
- if [ "$DEV" = "jar" -a ! -f $rep/target/$RELEASE.jar ]; then
- MVN_ACTION="$MVN_ACTION package"
- fi
- fi
-fi
-
-###############################################################################
-####### launch maven if required ##############################################
-###############################################################################
-if [ ! "$MVN_ACTION" = "" ]; then
- action="mvn -e $MVN_ACTION $OFF_LINE > $MOUTPUT"
- echo "$action"
- mkdir target 2>/dev/null
- eval "$action"
- if [ $? != 0 ] ; then
- echo "error with maven :"
- cat $MOUTPUT
- exit 1
- fi
- echo "mvn done."
-fi
-
-###############################################################################
-####### build classpath (by default use classes, not jar (one less goal:)) ####
-###############################################################################
-CL=$rep/target/classes
-if [ "$DEV" = "jar" ]; then
- CL=$rep/target/$RELEASE.jar
-else
-echo "use CL $CL"
-# add dependencies to class path
-for f in $rep/target/dependency/*.jar; do
- CL=$CL:$f
-done
-fi
-
-###############################################################################
-####### launch appli ##########################################################
-###############################################################################
-if [ "$DEV" = "jar" ]; then
- $JAVA $DEBUG -Xmx$MX -Xms$MX -jar $CL $JVM_OPT $@
-else
- $JAVA $DEBUG -Xmx$MX -Xms$MX -classpath $CL $JVM_OPT $MAIN_CLASS $@
-fi
Deleted: trunk/lima-swing/go.bat
===================================================================
--- trunk/lima-main/go.bat 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/go.bat 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,6 +0,0 @@
-if not "%1" == "debug" goto start
-Set DEBUG="-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=38000,server=y,suspend=n"
-shift
-
-:start
-java -XX:MaxPermSize=256m -Xmx128m -Xms64m %DEBUG% -jar simexplorer-is-swing-0.1-SNAPSHOT.jar %1 %2 %3 %4 %5 %6 %7 %8 %9 > error.txt 2>&1
Deleted: trunk/lima-swing/go.sh
===================================================================
--- trunk/lima-main/go.sh 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/go.sh 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,44 +0,0 @@
-#!/bin/sh
-
-DEBUG_PORT=5005
-VERSION=$(xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:parent/p:version" pom.xml)
-JAVA=java
-RELEASE="lima-main-$VERSION"
-MAIN_CLASS="org.chorem.lima.Main"
-MX=128M
-
-###############################################################################
-####### parse arguments #######################################################
-###############################################################################
-
-while true; do
- case "$1" in
- -d|--debug)
- echo "Debug mode"
- DEBUG="-server -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$DEBUG_PORT"
- shift ;;
- -n|--nosuspend)
- echo "Debug no suspend mode"
- DEBUG="$DEBUG,suspend=n"
- shift ;;
- \-\-) shift ; break ;;
- *) break;
- esac
-done
-
-###############################################################################
-####### init dir ##############################################################
-###############################################################################
-
-dir=$(dirname $0)
-cd $dir
-
-#rep=`dirname $0`
-#rep=`cd $rep && pwd`
-
-#cd $rep
-
-###############################################################################
-####### launch appli ##########################################################
-###############################################################################
-$JAVA $DEBUG -Xmx$MX -Xms$MX -jar target/$RELEASE.jar $@
Modified: trunk/lima-swing/pom.xml
===================================================================
--- trunk/lima-main/pom.xml 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/pom.xml 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- ************************************************************* -->
@@ -9,43 +9,21 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>lima</artifactId>
- <version>0.3.2-SNAPSHOT</version>
+ <version>0.4.0-SNAPSHOT</version>
</parent>
<groupId>org.chorem.lima</groupId>
- <artifactId>lima-main</artifactId>
+ <artifactId>lima-swing</artifactId>
<dependencies>
-
- <!-- sibling dependencies -->
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>lima-service</artifactId>
+ <artifactId>lima-business</artifactId>
<version>${project.version}</version>
+ <scope>compile</scope>
</dependency>
-
+
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>lima-service-mock</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>lima-service-neogia</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>lima-service-callao</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
<groupId>org.nuiton.jaxx</groupId>
<artifactId>jaxx-runtime</artifactId>
<exclusions>
@@ -55,7 +33,6 @@
</exclusion>
</exclusions>
</dependency>
-
<dependency>
<groupId>org.nuiton.jaxx</groupId>
<artifactId>jaxx-widgets</artifactId>
@@ -78,7 +55,7 @@
</dependency>
<dependency>
- <groupId>jdom</groupId>
+ <groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
</dependency>
@@ -88,17 +65,17 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>Lima Main</name>
- <description>Lima main</description>
+ <name>Lima Swing</name>
+ <description>Lima main interface in Swing</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
<!-- ************************************************************* -->
<properties>
- <!-- jaxx configuration -->
+ <!-- jaxx configuration
<jaxx.addProjectClassPath>true</jaxx.addProjectClassPath>
- <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath>
+ <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath>-->
<!--Main class in JAR -->
<maven.jar.main.class>org.chorem.lima.Main</maven.jar.main.class>
@@ -109,19 +86,11 @@
<packaging>jar</packaging>
<build>
- <filters>
+ <!-- <filters>
<filter>src/main/filters/pom.properties</filter>
- </filters>
-
+ </filters> -->
<resources>
<resource>
- <directory>src/main/filters</directory>
- <filtering>true</filtering>
- <includes>
- <include>lima.properties</include>
- </includes>
- </resource>
- <resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
@@ -134,32 +103,10 @@
<include>icons/**</include>
</includes>
</resource>
-
- <resource>
- <directory>${maven.gen.dir}/resources</directory>
- </resource>
</resources>
<plugins>
-
<plugin>
- <groupId>org.nuiton</groupId>
- <artifactId>maven-license-plugin</artifactId>
- <configuration>
- <copyToMETA_INF>true</copyToMETA_INF>
- </configuration>
- <executions>
- <execution>
- <id>attach-licenses</id>
- <goals>
- <goal>add-license</goal>
- <goal>add-third-party</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
<groupId>org.nuiton.jaxx</groupId>
<artifactId>maven-jaxx-plugin</artifactId>
<executions>
@@ -210,7 +157,30 @@
</execution>
</executions>
</plugin>
-
+ <plugin>
+ <groupId>org.bluestemsoftware.open.maven.plugin</groupId>
+ <artifactId>launch4j-plugin</artifactId>
+ <version>1.5.0.0</version>
+ <executions>
+ <execution>
+ <id>launch4j</id>
+ <phase>package</phase>
+ <goals>
+ <goal>launch4j</goal>
+ </goals>
+ <configuration>
+ <dontWrapJar>true</dontWrapJar>
+ <headerType>gui</headerType>
+ <outfile>target/lima.exe</outfile>
+ <jar>lima.jar</jar>
+ <errTitle>${project.name}</errTitle>
+ <jre>
+ <minVersion>1.6.0</minVersion>
+ </jre>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>
@@ -255,15 +225,6 @@
</jnlpExtensions>
</configuration>
</plugin>
-
- <plugin>
- <groupId>org.nuiton</groupId>
- <artifactId>maven-license-plugin</artifactId>
- <configuration>
- <copyToMETA_INF>true</copyToMETA_INF>
- </configuration>
- </plugin>
-
</plugins>
</pluginManagement>
</build>
@@ -293,6 +254,22 @@
</activation>
<build>
<plugins>
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <configuration>
+ <copyToMETA_INF>true</copyToMETA_INF>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-licenses</id>
+ <goals>
+ <goal>add-license</goal>
+ <goal>add-third-party</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
<!-- key store secrets availables -->
<plugin>
<groupId>org.nuiton</groupId>
Deleted: trunk/lima-swing/src/main/filters/lima.properties
===================================================================
--- trunk/lima-main/src/main/filters/lima.properties 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/filters/lima.properties 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,11 +0,0 @@
-application.name=${project.name}
-application.version=${project.version}
-
-# le lien suivant pointe sur le module qui n'a pas de site associ�
-#application.site.url=${project.url}
-application.site.url=http://maven-site.chorem.org/lima/
-
-#licence.name=${project.licenses[0].license.name}
-#licence.url=${project.licenses.0.url}
-application.organisation.name=${project.organization.name}
-application.organisation.url=${project.organization.url}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/DataManager.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/LimaAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/LimaContext.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,173 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-/**
- * ##% Copyright (C) 2008 Code Lutin, Tony Chemit
- * 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 2
- * 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, write to the Free Software Foundation, Inc., 59 Temple Place
- * - Suite 330, Boston, MA 02111-1307, USA.
- * ##%
- */
-package org.chorem.lima;
-
-import jaxx.runtime.Util;
-import jaxx.runtime.context.JAXXContextEntryDef;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.service.ServiceFactory;
-import org.chorem.lima.ui.MainView;
-import org.chorem.lima.ui.MainViewHandler;
-import org.chorem.lima.ui.MainViewImpl;
-import org.nuiton.i18n.I18n;
-
-import java.util.Locale;
-
-/**
- * @author chemit
- */
-public class LimaContext extends jaxx.runtime.context.DefaultApplicationContext {
-
- /**
- * to use log facility, just put in your code: log.info(\"...\");
- */
- static private Log log = LogFactory.getLog(LimaContext.class);
- /**
- * l'intance partagée accessible après un appel à la méthode
- * {@link #init()}
- */
- protected static LimaContext instance;
- public static JAXXContextEntryDef<MainView> MAIN_UI_ENTRY_DEF = Util.newContextEntryDef("mainUI", MainView.class);
-
- /**
- * @return <code>true</code> si le context a été initialisé via la méthode
- * {@link #init()}, <ocde>false</code> autrement.
- */
- public static boolean isInit() {
- return instance != null;
- }
-
- /**
- * Permet l'initialisation du contexte applicatif et positionne
- * l'instance partagée.
- * <p/>
- * Note : Cette méthode ne peut être appelée qu'une seule fois.
- *
- * @return l'instance partagée
- * @throws IllegalStateException si un contexte applicatif a déja été positionné.
- */
- public static synchronized LimaContext init() throws IllegalStateException {
- if (isInit()) {
- throw new IllegalStateException("there is already a application context registred.");
- }
- instance = new LimaContext();
- instance.setContextValue(new LimaConfig());
- instance.setContextValue(new MainViewHandler());
-
- return instance;
- }
-
- /**
- * Récupération du contexte applicatif.
- *
- * @return l'instance partagé du contexte.
- * @throws IllegalStateException si le contexte n'a pas été initialisé via
- * la méthode {@link #init()}
- */
- public static LimaContext get() throws IllegalStateException {
- if (!isInit()) {
- throw new IllegalStateException("no application context registred.");
- }
- return instance;
- }
-
- /**
- * neogia factory
- */
- protected ServiceFactory neogiaFactory;
-
- /**
- * Data manager*
- */
- protected DataManager dataManager;
-
- public LimaConfig getConfig() {
- return getContextValue(LimaConfig.class);
- }
-
- public void initI18n() {
-
- Locale locale = getConfig().getLocale();
- I18n.init(locale);
- /** Default Locale for DatePicker **/
- Locale.setDefault(locale);
- DTOHelper.setLocale(locale);
- }
-
- public ServiceFactory getNeogiaFactory() {
- if (neogiaFactory == null) {
- neogiaFactory = ServiceFactory.getServiceFactory();
- }
- return neogiaFactory;
- }
-
- public MainViewImpl getMainUI() {
- return (MainViewImpl) MAIN_UI_ENTRY_DEF.getContextValue(this);
- }
-
- public DataManager getDataManager() {
- if (dataManager == null) {
- dataManager = new DataManager();
- }
- return dataManager;
- }
-
- /**
- * close the application's context.
- *
- * @throws java.lang.Exception if any pb while closing
- */
- public void close() throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("closing context " + this);
- }
-
- // fermeture du context principal
- MainView mainUI = getMainUI();
- if (mainUI != null && mainUI.isVisible()) {
- mainUI.setVisible(false);
- mainUI.dispose();
- }
-
- if (log.isDebugEnabled()) {
- log.debug("context closed " + this);
- }
- //System.exit(0);
- }
-
- public static LimaContext getContext() {
- return get();
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java (from rev 2794, trunk/lima-main/src/main/java/org/chorem/lima/LimaContext.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,160 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima;
+
+import jaxx.runtime.Util;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.service.ServiceFactory;
+import org.chorem.lima.ui.MainView;
+import org.chorem.lima.ui.MainViewHandler;
+import org.chorem.lima.ui.MainViewImpl;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * @author chemit
+ */
+public class LimaContext extends jaxx.runtime.context.DefaultApplicationContext {
+
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
+ static private Log log = LogFactory.getLog(LimaContext.class);
+ /**
+ * l'intance partagée accessible après un appel à la méthode
+ * {@link #init()}
+ */
+ protected static LimaContext instance;
+ public static JAXXContextEntryDef<MainView> MAIN_UI_ENTRY_DEF = Util.newContextEntryDef("mainUI", MainView.class);
+
+ /**
+ * @return <code>true</code> si le context a été initialisé via la méthode
+ * {@link #init()}, <ocde>false</code> autrement.
+ */
+ public static boolean isInit() {
+ return instance != null;
+ }
+
+ /**
+ * Permet l'initialisation du contexte applicatif et positionne
+ * l'instance partagée.
+ * <p/>
+ * Note : Cette méthode ne peut être appelée qu'une seule fois.
+ *
+ * @return l'instance partagée
+ * @throws IllegalStateException si un contexte applicatif a déja été positionné.
+ */
+ public static synchronized LimaContext init() throws IllegalStateException {
+ if (isInit()) {
+ throw new IllegalStateException("there is already a application context registred.");
+ }
+ instance = new LimaContext();
+ instance.setContextValue(new LimaConfig());
+ instance.setContextValue(new MainViewHandler());
+
+ return instance;
+ }
+
+ /**
+ * Récupération du contexte applicatif.
+ *
+ * @return l'instance partagé du contexte.
+ * @throws IllegalStateException si le contexte n'a pas été initialisé via
+ * la méthode {@link #init()}
+ */
+ public static LimaContext get() throws IllegalStateException {
+ if (!isInit()) {
+ throw new IllegalStateException("no application context registred.");
+ }
+ return instance;
+ }
+
+ /**
+ * neogia factory
+ */
+ protected ServiceFactory neogiaFactory;
+
+ /**
+ * Data manager*
+ */
+ protected DataManager dataManager;
+
+ public LimaConfig getConfig() {
+ return getContextValue(LimaConfig.class);
+ }
+
+ public void initI18n() {
+
+ Locale locale = getConfig().getLocale();
+ I18n.init(locale);
+ /** Default Locale for DatePicker **/
+ Locale.setDefault(locale);
+ DTOHelper.setLocale(locale);
+ }
+
+ public ServiceFactory getNeogiaFactory() {
+ if (neogiaFactory == null) {
+ neogiaFactory = ServiceFactory.getServiceFactory();
+ }
+ return neogiaFactory;
+ }
+
+ public MainViewImpl getMainUI() {
+ return (MainViewImpl) MAIN_UI_ENTRY_DEF.getContextValue(this);
+ }
+
+ public DataManager getDataManager() {
+ if (dataManager == null) {
+ dataManager = new DataManager();
+ }
+ return dataManager;
+ }
+
+ /**
+ * close the application's context.
+ *
+ * @throws java.lang.Exception if any pb while closing
+ */
+ public void close() throws Exception {
+ if (log.isDebugEnabled()) {
+ log.debug("closing context " + this);
+ }
+
+ // fermeture du context principal
+ MainView mainUI = getMainUI();
+ if (mainUI != null && mainUI.isVisible()) {
+ mainUI.setVisible(false);
+ mainUI.dispose();
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("context closed " + this);
+ }
+ //System.exit(0);
+ }
+
+ public static LimaContext getContext() {
+ return get();
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/Main.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/Main.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/Main.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -43,6 +43,7 @@
import org.apache.commons.beanutils.converters.DateConverter;
import org.chorem.lima.tree.model.AccountTreeTableModel;
import org.nuiton.i18n.I18n;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.util.ConverterUtil;
import org.nuiton.util.StringUtil;
@@ -102,7 +103,7 @@
long t0 = System.nanoTime();
- I18n.setUniqueBundleName("lima-main-i18n");
+ I18n.setInitializer(new DefaultI18nInitializer("lima-main-i18n"));
I18n.init(Locale.FRANCE);
@@ -156,7 +157,7 @@
return context;
}
- public static void launch(final LimaContext context) throws Exception {
+ public static void launch(LimaContext context) throws Exception {
MainViewHandler uiHandler = context.getContextValue(MainViewHandler.class);
@@ -167,69 +168,17 @@
log.info(_("lima.init.ui.done"));
}
- final LimaSplash splash = new LimaSplash();
- splash.initSplash(context.getConfig().getVersion());
-
- /**
- * Lancement de la barre de chargement
- * L'application va charger en mémoire les données
- */
- Thread t = new Thread() {
- @Override
- public void run() {
-
- // ProgressBarImpl b = new ProgressBarImpl(ui, ui);
- // Chargement des journaux
- //b.getProgressBar().setString("5% : " + _("lima.progressBar.load.etape1"));
- //b.getProgressBar().setValue(5);
- splash.updateProgression(0.05, _("lima.progressBar.load.etape1"));
- DataManager dataManager = context.getDataManager();
- dataManager.getJournalModel();
-
- // Chargement des comptes
- //b.getProgressBar().setString("30% : " + _("lima.progressBar.load.etape2"));
- //b.getProgressBar().setValue(30);
- splash.updateProgression(0.30, _("lima.progressBar.load.etape2"));
- AccountTreeTableModel accountModel = dataManager.getAccountModel();
- loadDefaultAccount(accountModel.getData());
-
- // Chargement des status
- //b.getProgressBar().setString("50% : " + _("lima.progressBar.load.etape3"));
- //b.getProgressBar().setValue(50);
- splash.updateProgression(0.50, _("lima.progressBar.load.etape3"));
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- dataManager.getStatus();
-
- // Chargement des periodes
- //b.getProgressBar().setString("60% : " + _("lima.progressBar.load.etape4"));
- //b.getProgressBar().setValue(60);
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- splash.updateProgression(0.60, _("lima.progressBar.load.etape4"));
- dataManager.getPeriodes();
-
- // Chargement des transactions
- //b.getProgressBar().setString("70% : " + _("lima.progressBar.load.etape5"));
- //b.getProgressBar().setValue(70);
- splash.updateProgression(0.70, _("lima.progressBar.load.etape5"));
- dataManager.getTransactionModel(splash);
- //b.dispose();
-
- //splash.closeSplash();
-
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("Loading lima data...");
}
- };
- t.start();
- t.join();
+ loadData(context);
+ }
+ catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Error durring data loading", eee);
+ }
+ }
// show ui
SwingUtilities.invokeLater(new Runnable() {
@@ -240,6 +189,41 @@
});
}
+ /**
+ * Load datas and update progression into splash screen.
+ *
+ * @param context application context
+ */
+ protected static void loadData(LimaContext context) {
+ LimaSplash splash = new LimaSplash();
+ splash.initSplash(context.getConfig().getVersion());
+
+ // Chargement des journaux
+ splash.updateProgression(0.05, _("lima.progressBar.load.etape1"));
+ DataManager dataManager = context.getDataManager();
+ dataManager.getJournalModel();
+
+ // Chargement des comptes
+ splash.updateProgression(0.30, _("lima.progressBar.load.etape2"));
+ AccountTreeTableModel accountModel = dataManager.getAccountModel();
+ loadDefaultAccount(accountModel.getData());
+
+ // Chargement des status
+ splash.updateProgression(0.50, _("lima.progressBar.load.etape3"));
+ dataManager.getStatus();
+
+ // Chargement des periodes
+ splash.updateProgression(0.60, _("lima.progressBar.load.etape4"));
+ dataManager.getPeriodes();
+
+ // Chargement des transactions
+ splash.updateProgression(0.70, _("lima.progressBar.load.etape5"));
+ dataManager.getTransactionModel(splash);
+
+ // TODO needed or closed by UI ?
+ // splash.closeSplash();
+ }
+
public static class ShutdownHook extends Thread {
public ShutdownHook() {
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/Main.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/balance/Balance.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/balance/Balance.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/balance/Balance.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,139 +0,0 @@
-/**
- * *##% Lima-Callao Balance
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.balance;
-
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.dto.BalanceDTO;
-import org.chorem.lima.dto.EntryDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.TransactionDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.service.util.ServiceHelper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Hashtable;
-
-/**
- * @author Rémi Chapelet
- */
-public class Balance {
-
- private static final Log log = LogFactory.getLog(Balance.class);
- //private static Category category = new Category ();
-
-
- public Balance () {
- }
-
-
- /**
- * Permet de créer la balance suivant la période donnée. Si la période
- * correspond à l'exercice, la méthode détermine pour les 12 périodes
- * mensuelles dans ce cas. Elle renvoie une liste de BalanceDTO.
- * Chaque objet balanceDTO correspond à un compte identifié par son numéro
- * de compte.
- * @param period
- * @return
- */
- public ArrayList<BalanceDTO> createBalance (PeriodDTO period)
- {
- // Récupère toutes les transactions comptables
- List<TransactionDTO> listAllTransaction = LimaContext.getContext().getDataManager().getTransactionModel().getData();
- // Récupère toutes les transactions de la période
- List<TransactionDTO> listTransaction = ServiceHelper.findTransactionByPeriod(period, listAllTransaction);
- // Création tableau associatif
- Hashtable<String,BalanceDTO> balanceTab = new Hashtable<String,BalanceDTO>();
-
- // Pour chaque transaction comptable
- if ( listTransaction != null )
- {
- for (TransactionDTO transaction : listTransaction)
- {
- // Recherche les entrées de la transaction
- List<EntryDTO> listEntries = transaction.getEntries();
- // Pour chaque entrée
- for (EntryDTO entry : listEntries)
- {
- // Récupère son numéro de compte
- AccountDTO account = entry.getAccount();
- // Mise en place de la catégorie pour cette entrée comptable
- // Vérifie si le compte a été identifié
- /**
- * Le compte existe déja dans la liste des balanceDTO
- */
- if ( balanceTab.containsKey(account.getIdNumber()) )
- {
- // Récupère le compte dans la liste et le montant
- BalanceDTO balanceDTO = balanceTab.get(account.getIdNumber());
- // Si l'entrée comptable est au débit
- if ( entry.getDebit() )
- {
- // Ajoute au total du debit
- String Total = DTOHelper.AddNumbersString(balanceDTO.getDebit(),entry.getAmount());
- balanceDTO.setDebit(Total);
- } else {
- // Ajoute au total du credit
- String Total = DTOHelper.AddNumbersString(balanceDTO.getCredit(),entry.getAmount());
- balanceDTO.setCredit(Total);
- }
- } else {
- /**
- * Le compte n'existe pas
- */
- // Création d'une balanceDTO sur le numéro de compte
- BalanceDTO balanceDTO = new BalanceDTO ();
- balanceDTO.setName(account.getDescription());
- balanceDTO.setPosition("");
- // Si on souhaite rechercher son type suivant le n° de compte
- //balanceDTO.setType(category.findCategory(account.getIdNumber()));
- balanceDTO.setType(account.getType());
- balanceDTO.setAccount(account);
- if ( entry.getDebit() )
- {
- balanceDTO.setCredit("0");
- balanceDTO.setDebit(entry.getAmount());
- } else {
- balanceDTO.setCredit(entry.getAmount());
- balanceDTO.setDebit("0");
- }
- // Ajout de la balance à la liste
- balanceTab.put(account.getIdNumber(), balanceDTO);
- }
- }
- }
- }
-
- /** Pour afficher la balance dans le terminal
- Enumeration e = balanceTab.keys();
- while( e. hasMoreElements() )
- {
- BalanceDTO balance = balanceTab.get(e.nextElement());
- log.debug(balance.getName()+" : "+balance.getDebit()+" et "+balance.getCredit()+" ("+balance.getType()+")");
- }
- */
- return new ArrayList(balanceTab.values());
- }
-
-
-}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/balance/BalanceHelper.java (from rev 2790, trunk/lima-main/src/main/java/org/chorem/lima/balance/Balance.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/balance/BalanceHelper.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/balance/BalanceHelper.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,130 @@
+/**
+ * *##% Lima-Callao Balance
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.balance;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.business.data.Balance;
+import org.chorem.lima.business.dto.AccountDTO;
+import org.chorem.lima.business.dto.EntryDTO;
+import org.chorem.lima.business.dto.TransactionDTO;
+import org.chorem.lima.business.utils.ServiceHelper;
+import org.chorem.lima.entity.Period;
+
+/**
+ * @author Rémi Chapelet
+ */
+public class BalanceHelper {
+
+ private static final Log log = LogFactory.getLog(BalanceHelper.class);
+
+ public BalanceHelper() {
+ }
+
+ /**
+ * Permet de créer la balance suivant la période donnée. Si la période
+ * correspond à l'exercice, la méthode détermine pour les 12 périodes
+ * mensuelles dans ce cas. Elle renvoie une liste de BalanceDTO.
+ * Chaque objet balanceDTO correspond à un compte identifié par son numéro
+ * de compte.
+ * @param period
+ * @return la balance
+ */
+ public List<Balance> createBalance(Period period) {
+ // Récupère toutes les transactions comptables
+ List<TransactionDTO> listAllTransaction = LimaContext.getContext().getDataManager().getTransactionModel().getData();
+ // Récupère toutes les transactions de la période
+ List<TransactionDTO> listTransaction = ServiceHelper.findTransactionByPeriod(period, listAllTransaction);
+ // Création tableau associatif
+ Map<String, Balance> balanceTab = new Hashtable<String, Balance>();
+
+ // Pour chaque transaction comptable
+ if (listTransaction != null) {
+ for (TransactionDTO transaction : listTransaction) {
+ // Recherche les entrées de la transaction
+ List<EntryDTO> listEntries = transaction.getEntries();
+ // Pour chaque entrée
+ for (EntryDTO entry : listEntries) {
+ // Récupère son numéro de compte
+ AccountDTO account = entry.getAccount();
+ // Mise en place de la catégorie pour cette entrée comptable
+ // Vérifie si le compte a été identifié
+
+ // Le compte existe déja dans la liste des balanceDTO
+ if (balanceTab.containsKey(account.getAccountNumber())) {
+ // Récupère le compte dans la liste et le montant
+ Balance balance = balanceTab.get(account.getAccountNumber());
+ // Si l'entrée comptable est au débit
+ if (entry.getDebit()) {
+ // Ajoute au total du debit
+ String Total = DTOHelper.AddNumbersString(balanceDTO.getDebit(), entry.getAmount());
+ balanceDTO.setDebit(Total);
+ } else {
+ // Ajoute au total du credit
+ String Total = DTOHelper.AddNumbersString(balanceDTO.getCredit(), entry.getAmount());
+ balanceDTO.setCredit(Total);
+ }
+ } else {
+
+ // Le compte n'existe pas
+
+ // Création d'une balanceDTO sur le numéro de compte
+ BalanceDTO balanceDTO = new BalanceDTO();
+ balanceDTO.setName(account.getDescription());
+ balanceDTO.setPosition("");
+ // Si on souhaite rechercher son type suivant le n° de compte
+ //balanceDTO.setType(category.findCategory(account.getIdNumber()));
+ balanceDTO.setType(account.getType());
+ balanceDTO.setAccount(account);
+ if (entry.getDebit()) {
+ balanceDTO.setCredit("0");
+ balanceDTO.setDebit(entry.getAmount());
+ } else {
+ balanceDTO.setCredit(entry.getAmount());
+ balanceDTO.setDebit("0");
+ }
+ // Ajout de la balance à la liste
+ balanceTab.put(account.getIdNumber(), balanceDTO);
+ }
+ }
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ Set<String> balanceIds = balanceTab.keySet();
+ for (String balanceId : balanceIds) {
+ BalanceDTO balance = balanceTab.get(balanceId);
+ log.debug(balance.getName() + " : " + balance.getDebit()
+ + " et " + balance.getCredit() + " ("
+ + balance.getType() + ")");
+ }
+ }
+
+ return new ArrayList<BalanceDTO>(balanceTab.values());
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/balance/BalanceHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/balance/Category.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/balance/Category.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/balance/Category.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -19,52 +19,60 @@
package org.chorem.lima.balance;
-
-
/**
* @author Rémi Chapelet
*/
public class Category {
-
- public static String findCategory (String numberAccount)
- {
+ /**
+ * Permet de retourver la category (actif/passif) d'un compte.
+ *
+ * @param numberAccount
+ * @return la category {@code Actif} ou {@code Passif}.
+ */
+ public static String findCategory(String numberAccount) {
String result = "";
// Si le numéro de compte donné en paramètre n'est pas null
- if ( numberAccount != null && numberAccount.length()>0 )
- {
+ if (numberAccount != null && numberAccount.length() > 0) {
// Compare sur le premier chiffre
- switch ( Integer.parseInt(numberAccount.substring(0, 1)) ) {
- case 1:
+ switch (Integer.parseInt(numberAccount.substring(0, 1))) {
+ case 1:
+ result = "Passif";
+ break;
+ case 2:
+ if (accountNumberCategory("28", numberAccount)) {
result = "Passif";
- break;
- case 2:
- if ( accountNumberCategory("28",numberAccount) )
- {result = "Passif";}else{result = "Actif";}
- break;
- case 3:
+ } else {
result = "Actif";
- break;
- case 4:
- if ( accountNumberCategory("41",numberAccount)
- || accountNumberCategory("486",numberAccount)
- || accountNumberCategory("4091",numberAccount)
- || accountNumberCategory("481",numberAccount)
- || accountNumberCategory("476",numberAccount)
- || accountNumberCategory("4456",numberAccount) )
- {result = "Actif";}else{result = "Passif";}
- break;
- case 5:
+ }
+ break;
+ case 3:
+ result = "Actif";
+ break;
+ case 4:
+ // FIXME replace hard coded numbers
+ if (accountNumberCategory("41", numberAccount)
+ || accountNumberCategory("486", numberAccount)
+ || accountNumberCategory("4091", numberAccount)
+ || accountNumberCategory("481", numberAccount)
+ || accountNumberCategory("476", numberAccount)
+ || accountNumberCategory("4456", numberAccount)) {
+ result = "Actif";
+ } else {
result = "Passif";
- break;
- case 6:
- result = "Charge";
- break;
- case 7:
- break;
- case 8:
- result = "Produit";
- break;
+ }
+ break;
+ case 5:
+ result = "Passif";
+ break;
+ case 6:
+ result = "Charge";
+ break;
+ case 7:
+ break;
+ case 8:
+ result = "Produit";
+ break;
}
}
return result;
@@ -72,17 +80,19 @@
/**
* Permet de comparer si un compte appartient à une catégorie pour le bilan.
+ *
* Exemple :
* _ number = 2 et numberAccount = 211 ; alors true.
* _ number = 2 et numberAccount = 142 ; alors false.
- * @param number
- * @param numberAccount
- * @return
+ *
+ * @param number category number
+ * @param numberAccount account number
+ * @return {@code true} if {@code numberAccount} starts with {@code numberAccount}
*/
- public static boolean accountNumberCategory (String number,String numberAccount)
- {
+ public static boolean accountNumberCategory(String number,
+ String numberAccount) {
// Methode 1
- /**
+ /*
int result = 1;
int size = number.length();
if ( size <= numberAccount.length())
@@ -95,5 +105,4 @@
return start;
}
-
}
\ No newline at end of file
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/balance/Category.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/bilan/Bilan.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/bilan/Bilan.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/bilan/Bilan.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -22,7 +22,6 @@
import org.chorem.lima.balance.Category;
import org.chorem.lima.dto.BilanDTO;
import org.chorem.lima.dto.BalanceDTO;
-import org.chorem.lima.dto.util.DTOHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -176,7 +175,12 @@
*/
while ( bilanSearch!=null )
{
- bilanSearch.setDepreciation(DTOHelper.AddNumbersString(bilanSearch.getDepreciation(), depreciation));
+ // FIXME work with double directly ???
+ //bilanSearch.setDepreciation(DTOHelper.AddNumbersString(bilanSearch.getDepreciation(), depreciation));
+ double d1 = Double.parseDouble(bilanSearch.getDepreciation());
+ double d2 = Double.parseDouble(depreciation);
+ bilanSearch.setDepreciation(String.valueOf(d1 + d2));
+
bilanSearch = bilanSearch.getBilanMaster();
}
}
@@ -211,9 +215,13 @@
bilanMaster = bilan;
}
- public void addTotal (String number)
- {
- this.setTotal(DTOHelper.AddNumbersString(this.getTotal(), number));
+ public void addTotal (String number) {
+
+ // FIXME work with double directly ???
+ //this.setTotal(DTOHelper.AddNumbersString(this.getTotal(), number));
+ double d1 = Double.parseDouble(this.getTotal());
+ double d2 = Double.parseDouble(number);
+ this.setTotal(String.valueOf(d1 + d2));
}
public void addTotalMasterBilan (Bilan bilan,String total)
@@ -222,7 +230,12 @@
Bilan bilanSearch = bilan.getBilanMaster();
while ( bilanSearch!=null )
{
- bilanSearch.setTotal(DTOHelper.AddNumbersString(bilanSearch.getTotal(), total));
+ // FIXME work with double directly ???
+ //bilanSearch.setTotal(DTOHelper.AddNumbersString(bilanSearch.getTotal(), total));
+ double d1 = Double.parseDouble(bilanSearch.getTotal());
+ double d2 = Double.parseDouble(total);
+ bilanSearch.setTotal(String.valueOf(d1 + d2));
+
bilanSearch = bilanSearch.getBilanMaster();
}
}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/bilan/Bilan.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/combobox/JWideComboBox.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,111 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.combobox;
-
-import javax.swing.*;
-import javax.swing.plaf.basic.BasicComboPopup;
-import javax.swing.plaf.basic.ComboPopup;
-import javax.swing.plaf.metal.MetalComboBoxUI;
-import java.awt.*;
-import java.util.Vector;
-
-
-/**
- * @author ore
- */
-public class JWideComboBox extends JComboBox {
-
- /**
- *
- */
- public JWideComboBox() {
- setUI(new ScrollMetalComboUI());
- }
-
- /**
- * @param items
- */
- public JWideComboBox(final Object items[]) {
- super(items);
- }
-
- /**
- * @param items
- */
- public JWideComboBox(Vector items) {
- super(items);
- }
-
- /**
- * @param aModel
- */
- public JWideComboBox(ComboBoxModel aModel) {
- super(aModel);
- }
-
- private boolean layingOut = false;
-
- /**
- *
- */
- @Override
- public void doLayout() {
- try {
- layingOut = true;
- super.doLayout();
- } finally {
- layingOut = false;
- }
- }
-
- /**
- * @return
- */
- @Override
- public Dimension getSize() {
- Dimension dim = super.getSize();
- if (!layingOut) {
- int max = Math.max(dim.width, getPreferredSize().width);
- dim.width = max > 600 ? 600 : max;
- }
- return dim;
- }
-}
-
-class ScrollMetalComboUI extends MetalComboBoxUI {
-
- @Override
- protected ComboPopup createPopup() {
- return new ScrollBasicComboPopup(comboBox);
- }
-}
-
-class ScrollBasicComboPopup extends BasicComboPopup {
-
- public ScrollBasicComboPopup(JComboBox combo) {
- super(combo);
- }
-
- @Override
- protected JScrollPane createScroller() {
- return new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java (from rev 2798, trunk/lima-main/src/main/java/org/chorem/lima/combobox/JWideComboBox.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,114 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.combobox;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicComboPopup;
+import javax.swing.plaf.basic.ComboPopup;
+import javax.swing.plaf.metal.MetalComboBoxUI;
+import java.awt.*;
+import java.util.Vector;
+
+/**
+ * Cette combo box surcharge quelques methodes de l'UI par defaut
+ * pour que le composant popup soit plus grand que la combobox
+ * elle même.
+ *
+ * @author ore
+ */
+public class JWideComboBox extends JComboBox {
+
+ private boolean layingOut = false;
+
+ /**
+ *
+ */
+ public JWideComboBox() {
+ setUI(new ScrollMetalComboUI());
+ }
+
+ /**
+ * @param items
+ */
+ public JWideComboBox(final Object items[]) {
+ super(items);
+ }
+
+ /**
+ * @param items
+ */
+ public JWideComboBox(Vector items) {
+ super(items);
+ }
+
+ /**
+ * @param aModel
+ */
+ public JWideComboBox(ComboBoxModel aModel) {
+ super(aModel);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void doLayout() {
+ try {
+ layingOut = true;
+ super.doLayout();
+ } finally {
+ layingOut = false;
+ }
+ }
+
+ /**
+ * @return
+ */
+ @Override
+ public Dimension getSize() {
+ Dimension dim = super.getSize();
+ if (!layingOut) {
+ int max = Math.max(dim.width, getPreferredSize().width);
+ dim.width = max > 600 ? 600 : max;
+ }
+ return dim;
+ }
+}
+
+class ScrollMetalComboUI extends MetalComboBoxUI {
+
+ @Override
+ protected ComboPopup createPopup() {
+ return new ScrollBasicComboPopup(comboBox);
+ }
+}
+
+class ScrollBasicComboPopup extends BasicComboPopup {
+
+ public ScrollBasicComboPopup(JComboBox combo) {
+ super(combo);
+ }
+
+ @Override
+ protected JScrollPane createScroller() {
+ return new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/AccountComboBoxModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/JournalComboBoxModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/PeriodComboBoxModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/AccountComboBoxRenderer.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/combobox/renderer/AccountComboBoxRenderer.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/AccountComboBoxRenderer.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -19,17 +19,22 @@
package org.chorem.lima.combobox.renderer;
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JList;
+
+import org.apache.commons.lang.StringUtils;
import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import javax.swing.*;
-import java.awt.*;
-
/**
* @author ore
*/
public class AccountComboBoxRenderer extends DefaultListCellRenderer {
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 6317107424723186387L;
+
private static AccountComboBoxRenderer renderer;
@Override
@@ -43,7 +48,7 @@
}
setFont(list.getFont());
- setText((value == null) ? DTOHelper.EMPTY_STRING : ((AccountDTO) value).getIdNumber() +
+ setText((value == null) ? StringUtils.EMPTY : ((AccountDTO) value).getIdNumber() +
" : " +
((AccountDTO) value).getDescription());
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/AccountComboBoxRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/JournalComboBoxRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/PeriodClosureComboBoxRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/PeriodComboBoxRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/comparator/AccountComparator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/comparator/JournalComparator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/comparator/PeriodComparator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/comparator/StatusComparator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/AccountEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/BalanceEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/BilanActifEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/BilanPassifEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/ClosureEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/FilterEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/JournalEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/ResultChargeEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/ResultProduitEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/enumeration/TransactionEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/export/CSVExport.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/export/XMLExport.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/AbstractTransactionFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/AccountFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/AmountFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/CreditFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/DateFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/DebitFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/DescriptionFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/Filter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/JournalFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/PeriodFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/filter/VoucherFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/imports/CSVImport.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/imports/CSVImportEBP.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/imports/XMLImport.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/item/Item.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/item/PeriodItem.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/listener/ClicRight.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/listener/TransactionHeaderListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/listener/TransactionKeyListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/BilanActifJXTable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/BilanPassifJXTable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/ResultChargesJXTable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/ResultProduitsJXTable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/TransactionJXTable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/AccountTableCellEditor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/NumberTableCellEditor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/PeriodTableCellEditor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/TextTableCellEditor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/BalanceTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/BilanActifTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/BilanPassifTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/ClosureTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/JournalTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/ResultChargesTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/ResultProduitsTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionDataTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFilteredTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFlattenTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableColumnModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/AccountTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/AmountTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/BalanceTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/BilanActifTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/BilanPassifTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/DateTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/JournalTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/PeriodTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/ResultTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/StatusTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/TextTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/TransactionAllCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/table/renderer/TransactionHeaderRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/tree/model/AccountTreeTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,7 +1,6 @@
<JFrame width="300" height="150" locationRelativeTo="{null}" defaultCloseOperation="dispose_on_close">
-
<style source="css/lima.css" />
- <Table insets='5,5,5,5'>
+ <Table fill="both">
<row>
<cell>
<JLabel text="lima.closure.period.begin"/>
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -22,7 +22,7 @@
import org.chorem.lima.LimaContext;
import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.balance.Balance;
+import org.chorem.lima.balance.BalanceHelper;
import org.chorem.lima.dto.BalanceDTO;
import org.chorem.lima.dto.PeriodDTO;
import org.chorem.lima.dto.util.DTOHelper;
@@ -49,7 +49,7 @@
private JComboBox comboBoxPeriod = new JComboBox();
private JXTable table;
private JXTable tableRes;
- private Balance balance = new Balance();
+ private BalanceHelper balance = new BalanceHelper();
private BalanceTableModel modelBalance;
private DefaultTableModel model;
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/ui/BilanViewImpl.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -25,7 +25,7 @@
import org.chorem.lima.bilan.Bilan;
import org.chorem.lima.dto.PeriodDTO;
import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.balance.Balance;
+import org.chorem.lima.balance.BalanceHelper;
import org.chorem.lima.balance.Category;
import org.chorem.lima.table.BilanActifJXTable;
import org.chorem.lima.table.BilanPassifJXTable;
@@ -55,7 +55,7 @@
Hashtable<String, Bilan> actifTab = new Hashtable<String, Bilan>();
Hashtable<String, Bilan> passifTab = new Hashtable<String, Bilan>();
Hashtable<String, List<BalanceDTO>> provisionMap;
- private Balance balance = new Balance();
+ private BalanceHelper balance = new BalanceHelper();
private ProgressBarImpl progressBar;
/**
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,402 +0,0 @@
-/**
- * *##% Lima-Callao ClosureViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.swing.JComboBox;
-import javax.swing.ListSelectionModel;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.model.PeriodComboBoxModel;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.StatusDTO;
-import org.chorem.lima.dto.TransactionDTO;
-import org.chorem.lima.dto.util.TriPeriodAsc;
-import org.chorem.lima.dto.util.TriPeriodDesc;
-import org.chorem.lima.table.model.ClosureTableModel;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.Filter;
-import org.jdesktop.swingx.decorator.FilterPipeline;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-import org.jdesktop.swingx.decorator.PatternFilter;
-
-
-/**
- * Permet l'affichage du tableau avec les périodes mensuelles.
- *
- * @author Rémi Chapelet
- */
-public class ClosureViewImpl extends ClosureView {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -8759564865633991757L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(ClosureViewImpl.class);
-
- private final JXTable table;
- private JComboBox comboBoxPeriod = new JComboBox();
- private final ClosureTimeSpanForm form;
- private final AddPeriod addPeriodForm;
- private static boolean blockPeriod;
- private JComboBox comboBoxBeginPeriod = new JComboBox();
- private JComboBox comboBoxEndPeriod = new JComboBox();
- private JComboBox comboBeginYearPeriod = new JComboBox();
- private JComboBox comboBeginMonthPeriod = new JComboBox();
- private JComboBox comboEndYearPeriod = new JComboBox();
- private JComboBox comboEndMonthPeriod = new JComboBox();
-
-
- /**
- * Constructor
- */
- public ClosureViewImpl() {
-
- // Initialisation du choix pour les périodes
- initComboBoxPeriod();
-
- /* Set Period model */
- // Création du model pour le tableau
- table = new JXTable(LimaContext.getContext().getDataManager().getClosureModel());
- table.setRowHeight(24);
- // Permet d'alterner les couleurs des lignes pour le tableau
- table.setHighlighters(HighlighterFactory.createAlternateStriping());
- // Definition de la selection possible sur les lignes
- table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- table.setColumnControlVisible(true);
-
- /*
- * Ajout d'un listener lorsque l'utilisateur change de période.
- */
- comboBoxPeriod.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- // Récupère la période master
- PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
- Filter[] filterArray = {new PatternFilter("(.*" + (periodMaster.getBegin().getYear() + 1900) + ".*)|(.*Final.*)", 0, 0)};
- FilterPipeline filters = new FilterPipeline(filterArray);
- table.setFilters(filters);
- }
- });
- // Récupère la période master (celle de l'exercice)
- /*
- PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
- // Définition du tri avec une expression régulière
- Filter[] filterArray = { new PatternFilter("(.*"+(periodMaster.getBegin().getYear()+1900)+".*)|(.*Final.*)", 0, 0) };
- FilterPipeline filters = new FilterPipeline(filterArray);
- // Applique le tri
- table.setFilters(filters);
- */
- // Ajout du tableau dans l'UI
- getClosureScrollPane().setViewportView(table);
-
- /*
- * Initialisation du formulaire pour bloquer ou débloquer une période.
- */
- form = LimaContext.getContext().getMainUI().getClosureTimeSpanForm();
- form.getOkButton().addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- updatePeriod();
- }
- });
-
- /**
- * Initialisation du formulaire pour ajouter un exercice
- */
- addPeriodForm = LimaContext.getContext().getMainUI().getAddPeriod();
-
- Calendar cal = Calendar.getInstance();
-
- //Init YEAR Periode Combobox
- // take care about previous year #120
- cal.add(Calendar.YEAR, -1);
- for (int i = 0; i <= 6; i++) {
- int newYear = cal.get(Calendar.YEAR);
- comboBeginYearPeriod.addItem(newYear);
- comboEndYearPeriod.addItem(newYear);
-
- // set current year selected
- if (i == 0) {
- comboBeginYearPeriod.setSelectedItem(newYear);
- comboEndYearPeriod.setSelectedItem(newYear);
- }
-
- cal.add(Calendar.YEAR, 1);
- }
-
-
- //Add BeginYear ComboBox to addPeriodForm
- addPeriodForm.getBeginYearPeriodPanel().add(comboBeginYearPeriod);
- addPeriodForm.getBeginYearPeriodPanel().validate();
-
- //Add EndYear ComboBox to addPeriodForm
- addPeriodForm.getEndYearPeriodPanel().add(comboEndYearPeriod);
- addPeriodForm.getEndYearPeriodPanel().validate();
-
- //Init MONTH Periode Combobox
- cal.set(Calendar.MONTH, Calendar.JANUARY);
- for (int j = 0; j <= 11; j++) {
- comboBeginMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
- comboEndMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
- cal.add(Calendar.MONTH, 1);
- }
-
- //Add BeginMonth ComboBox to addPeriodForm
- addPeriodForm.getBeginMonthPeriodPanel().add(comboBeginMonthPeriod);
- addPeriodForm.getBeginMonthPeriodPanel().validate();
-
- //Add EndMonth ComboBox to addPeriodForm
- addPeriodForm.getEndMonthPeriodPanel().add(comboEndMonthPeriod);
- addPeriodForm.getEndMonthPeriodPanel().validate();
-
- addPeriodForm.setVisible(true);
- addPeriodForm.getOkButton().addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- addPeriod();
- addPeriodForm.dispose();
- }
- });
-
- }
-
-
- /**
- * Cette méthode permet de charger les périodes (annuelles) pour choisir
- * les périodes mensuelles à afficher dans le tableau.
- */
- public void initComboBoxPeriod() {
- /**
- * Charge pour le JComboBox le choix des périodes (exercices) à afficher.
- */
- // Récupère les périodes
- ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
- PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
- // Création Combobox debut période
- comboBoxPeriod.setModel(periodModel);
- comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Ajout des combobox
- periodPanel.add(comboBoxPeriod);
- periodPanel.validate();
- }
-
-
- /**
- * Cette méthode permet d'initialiser le formulaire pour bloquer une ou
- * plusieurs périodes.
- */
- @Override
- public void initBlockForm() {
- blockPeriod = true;
- form.setTitle(_("lima.ui.block.timespan"));
- initComboBoxForm();
- form.setVisible(true);
- }
-
-
- /**
- * Initialise le formulaire pour débloquer des périodes mensuelles.
- */
- @Override
- public void initUnblockForm() {
- blockPeriod = false;
- form.setTitle(_("lima.ui.unblock.timespan"));
- initComboBoxForm();
- form.setVisible(true);
- }
-
-
- /**
- * Initialise les combobox pour le formulaire de période. Il ajoute ainsi
- * les deux combobox nécessaires pour début et fin de période.
- */
- public void initComboBoxForm() {
- /**
- * Charge pour les JComboBox le choix des périodes mensuelles à bloquer.
- */
- // Récupère les périodes
- ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
- PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
- // Création Combobox debut période
- comboBoxBeginPeriod.setModel(periodModel);
- comboBoxBeginPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Création Combobox fin période
- comboBoxEndPeriod.setModel(periodModel);
- comboBoxEndPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Ajout des combobox
- form.beginPeriod.add(comboBoxBeginPeriod);
- form.endPeriod.add(comboBoxEndPeriod);
-
- /**
- * Positionne, si les lignes sont sélectionnées, les comboBox sur
- * les bonnes périodes (période min et période max).
- */
- // Si une ou plusieurs lignes sont sélectionnées
- if (table.getSelectedRow() != -1) {
- // Récupère les périodes sélectionnées
- List<PeriodDTO> listPeriod = getSelectedPeriod();
- // Parcours du vecteur
- comboBoxBeginPeriod.setSelectedItem(listPeriod.get(0));
- comboBoxEndPeriod.setSelectedItem(listPeriod.get((listPeriod.size() - 1)));
- }
- }
-
-
- /**
- * Permet d'ajouter un nouvel exercice.
- */
- protected void addPeriod() {
- if (log.isDebugEnabled()) {
- log.debug("addPeriod : ");
- //Get form data
- }
- PeriodDTO periodCurrent = LimaContext.getContext().getDataManager().getCurrentPeriod();
- List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
-
- Calendar cal_beg = Calendar.getInstance();
- if (periodCurrent != null) {
- cal_beg.setTime(periodCurrent.getBegin());
- cal_beg.add(Calendar.YEAR , comboBeginYearPeriod.getSelectedIndex());
- }
- else {
- cal_beg.add(Calendar.YEAR , comboBeginYearPeriod.getSelectedIndex());
- }
- cal_beg.set(Calendar.DAY_OF_MONTH, 1);
- cal_beg.set(Calendar.MONTH, comboBeginMonthPeriod.getSelectedIndex());
-
- Date begin = cal_beg.getTime();
-
- Calendar cal_end = Calendar.getInstance();
- cal_end.add(Calendar.YEAR, comboEndYearPeriod.getSelectedIndex());
- cal_end.set(Calendar.MONTH , comboEndMonthPeriod.getSelectedIndex());
- int maximum = cal_end.getActualMaximum(Calendar.DAY_OF_MONTH);
- cal_end.set(Calendar.DAY_OF_MONTH, maximum);
-
- Date end = cal_end.getTime();
- log.debug("Date de debut: "+begin+" Date de fin: "+end);
-
- String periodName = comboBeginYearPeriod.getSelectedIndex() != comboEndYearPeriod.getSelectedIndex() ? Integer.toString(cal_beg.get(Calendar.YEAR))+"-"+Integer.toString(cal_end.get(Calendar.YEAR)) : Integer.toString(cal_beg.get(Calendar.YEAR));
- PeriodDTO period = new PeriodDTO("", periodName, begin, end, null, null, status.get(3));
-
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- closureModel.addPeriod(period, status);
- }
-
- /**
- * Permet de mettre à jour une période. Si l'utilisateur souhaite bloquer
- * une ou plusieurs périodes, ou bien débloquer.
- * On récupère l'intervalle des périodes donné par le formulaire. On prend
- * les périodes aux extrémités.
- * Si on bloque les périodes, on va trier par ordre croissant sinon par
- * ordre décroissant. En effet, pour débloquer une période, il est important
- * que les périodes qui suivent soient bloquées ; par conséquent on doit
- * commencer par les dernières.
- */
- protected void updatePeriod() {
- // Liste des status
- List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
- // Liste des transactions
- List<TransactionDTO> transactions = LimaContext.getContext().getDataManager().getTransactionModel().getData();
- // Chargement du model
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- /**
- * Récupère l'intervalle des périodes sélectionnées
- */
- PeriodDTO periodBegin = (PeriodDTO) comboBoxBeginPeriod.getSelectedItem();
- PeriodDTO periodEnd = (PeriodDTO) comboBoxEndPeriod.getSelectedItem();
- // Exercice
- PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
- // Si block période, on trie la liste en croissant ou bien décroissant
- List<PeriodDTO> listPeriod = periodMaster.getChildren();
- if (blockPeriod) {
- Collections.sort(listPeriod, new TriPeriodAsc());
- } else {
- Collections.sort(listPeriod, new TriPeriodDesc());
- }
- // Pour toutes les périodes mensuelles
- for (PeriodDTO period : listPeriod) {
- if (((period.getBegin().after(periodBegin.getBegin()))
- && (period.getBegin().before(periodEnd.getBegin())))
- || (period.equals(periodBegin))
- || (period.equals(periodEnd))) {
- if (log.isDebugEnabled()) {
- log.debug("updatePeriod : " + period.getIdName() + " : "
- + blockPeriod);
- }
- /**
- * Détection des messages d'erreur
- */
- String message = closureModel.updatePeriod(period, blockPeriod, status, transactions);
- ErrorMessage.showMessage(message);
- }
- }
- // On trie par ordre croissant si c'était en décroissant, sinon l'affichage
- // dans les vues est bouleversé. (les périodes seront affichées dans l'ordre
- // décroissant).
- if (!blockPeriod) {
- Collections.sort(listPeriod, new TriPeriodAsc());
- }
- form.setVisible(false);
- form.dispose();
- }
-
- /**
- * Cette méthode permet de retourner une liste des périodes sélectionnées.
- *
- * @return liste des périodes sélectionnées
- */
- protected List<PeriodDTO> getSelectedPeriod() {
- // récupère les lignes sélectionnées
- int viewIndex[] = table.getSelectedRows();
- // chargement du model (tableau des périodes)
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- LinkedList<PeriodDTO> listPeriod = new LinkedList<PeriodDTO>();
- // Pour chaque ligne sélectionnée
- for (int i : viewIndex) {
- int modelIndex = table.convertRowIndexToModel(i);
- listPeriod.add(closureModel.getRow(modelIndex));
- }
- return listPeriod;
- }
-
-
- public void initAddPeriod() {
- addPeriodForm.setTitle(_("lima.menubar.closure.addPeriod"));
- addPeriodForm.setVisible(true);
- }
-
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java (from rev 2799, trunk/lima-main/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,406 @@
+/**
+ * *##% Lima-Callao ClosureViewImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.swing.JComboBox;
+import javax.swing.ListSelectionModel;
+import javax.swing.RowFilter;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.model.PeriodComboBoxModel;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.StatusDTO;
+import org.chorem.lima.dto.TransactionDTO;
+import org.chorem.lima.dto.util.TriPeriodAsc;
+import org.chorem.lima.dto.util.TriPeriodDesc;
+import org.chorem.lima.table.model.ClosureTableModel;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.HighlighterFactory;
+
+
+/**
+ * Permet l'affichage du tableau avec les périodes mensuelles.
+ *
+ * @author Rémi Chapelet
+ */
+public class ClosureViewImpl extends ClosureView {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8759564865633991757L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(ClosureViewImpl.class);
+
+ private final JXTable table;
+ private JComboBox comboBoxPeriod = new JComboBox();
+ private final ClosureTimeSpanForm form;
+ private final AddPeriod addPeriodForm;
+ private static boolean blockPeriod;
+ private JComboBox comboBoxBeginPeriod = new JComboBox();
+ private JComboBox comboBoxEndPeriod = new JComboBox();
+ private JComboBox comboBeginYearPeriod = new JComboBox();
+ private JComboBox comboBeginMonthPeriod = new JComboBox();
+ private JComboBox comboEndYearPeriod = new JComboBox();
+ private JComboBox comboEndMonthPeriod = new JComboBox();
+
+
+ /**
+ * Constructor
+ */
+ public ClosureViewImpl() {
+
+ // Initialisation du choix pour les périodes
+ initComboBoxPeriod();
+
+ /* Set Period model */
+ // Création du model pour le tableau
+ table = new JXTable(LimaContext.getContext().getDataManager().getClosureModel());
+ table.setRowHeight(24);
+ // Permet d'alterner les couleurs des lignes pour le tableau
+ table.setHighlighters(HighlighterFactory.createAlternateStriping());
+ // Definition de la selection possible sur les lignes
+ table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ table.setColumnControlVisible(true);
+
+ /*
+ * Ajout d'un listener lorsque l'utilisateur change de période.
+ */
+ comboBoxPeriod.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ // Récupère la période master
+ PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
+ //Filter[] filterArray = {new PatternFilter("(.*" + (periodMaster.getBegin().getYear() + 1900) + ".*)|(.*Final.*)", 0, 0)};
+ //FilterPipeline filters = new FilterPipeline(filterArray);
+
+ RowFilter<Object, Object> filter = null;
+ if (periodMaster != null) {
+ // 0 = check only in first column
+ // filter :
+ // period name containing selected periode
+ // Final = ??? TODO
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(periodMaster.getBegin());
+ filter = RowFilter.regexFilter("(.*" + calendar.get(Calendar.YEAR) + ".*)|(.*Final.*)", 0);
+ if (log.isDebugEnabled()) {
+ log.debug("Apply filter on " + calendar.get(Calendar.YEAR));
+ }
+ }
+ table.setRowFilter(filter);
+ }
+ });
+
+ // Ajout du tableau dans l'UI
+ getClosureScrollPane().setViewportView(table);
+
+ /*
+ * Initialisation du formulaire pour bloquer ou débloquer une période.
+ */
+ form = LimaContext.getContext().getMainUI().getClosureTimeSpanForm();
+ form.getOkButton().addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ updatePeriod();
+ }
+ });
+
+ /**
+ * Initialisation du formulaire pour ajouter un exercice
+ */
+ addPeriodForm = LimaContext.getContext().getMainUI().getAddPeriod();
+
+ Calendar cal = Calendar.getInstance();
+
+ //Init YEAR Periode Combobox
+ // take care about previous year #120
+ int todayYear = cal.get(Calendar.YEAR);
+ for (int currentYear = todayYear - 1; currentYear <= todayYear + 5; currentYear ++) {
+ comboBeginYearPeriod.addItem(currentYear);
+ comboEndYearPeriod.addItem(currentYear);
+ }
+ comboBeginYearPeriod.setSelectedItem(todayYear);
+ comboEndYearPeriod.setSelectedItem(todayYear);
+
+
+ //Add BeginYear ComboBox to addPeriodForm
+ addPeriodForm.getBeginYearPeriodPanel().add(comboBeginYearPeriod);
+ addPeriodForm.getBeginYearPeriodPanel().validate();
+
+ //Add EndYear ComboBox to addPeriodForm
+ addPeriodForm.getEndYearPeriodPanel().add(comboEndYearPeriod);
+ addPeriodForm.getEndYearPeriodPanel().validate();
+
+ //Init MONTH Periode Combobox
+ cal.set(Calendar.MONTH, Calendar.JANUARY);
+ for (int j = 0; j <= 11; j++) {
+ comboBeginMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
+ comboEndMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
+ cal.add(Calendar.MONTH, 1);
+ }
+
+ //Add BeginMonth ComboBox to addPeriodForm
+ addPeriodForm.getBeginMonthPeriodPanel().add(comboBeginMonthPeriod);
+ addPeriodForm.getBeginMonthPeriodPanel().validate();
+
+ //Add EndMonth ComboBox to addPeriodForm
+ addPeriodForm.getEndMonthPeriodPanel().add(comboEndMonthPeriod);
+ addPeriodForm.getEndMonthPeriodPanel().validate();
+
+ addPeriodForm.getOkButton().addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ addPeriod();
+ addPeriodForm.dispose();
+ }
+ });
+
+ }
+
+
+ /**
+ * Cette méthode permet de charger les périodes (annuelles) pour choisir
+ * les périodes mensuelles à afficher dans le tableau.
+ */
+ public void initComboBoxPeriod() {
+ /**
+ * Charge pour le JComboBox le choix des périodes (exercices) à afficher.
+ */
+ // Récupère les périodes
+ ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
+ PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
+ // Création Combobox debut période
+ comboBoxPeriod.setModel(periodModel);
+ comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ // Ajout des combobox
+ periodPanel.add(comboBoxPeriod);
+ periodPanel.validate();
+ }
+
+
+ /**
+ * Cette méthode permet d'initialiser le formulaire pour bloquer une ou
+ * plusieurs périodes.
+ */
+ @Override
+ public void initBlockForm() {
+ blockPeriod = true;
+ form.setTitle(_("lima.ui.block.timespan"));
+ initComboBoxForm();
+ form.setVisible(true);
+ }
+
+
+ /**
+ * Initialise le formulaire pour débloquer des périodes mensuelles.
+ */
+ @Override
+ public void initUnblockForm() {
+ blockPeriod = false;
+ form.setTitle(_("lima.ui.unblock.timespan"));
+ initComboBoxForm();
+ form.setVisible(true);
+ }
+
+
+ /**
+ * Initialise les combobox pour le formulaire de période. Il ajoute ainsi
+ * les deux combobox nécessaires pour début et fin de période.
+ */
+ public void initComboBoxForm() {
+ /**
+ * Charge pour les JComboBox le choix des périodes mensuelles à bloquer.
+ */
+ // Récupère les périodes
+ ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
+ PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
+ // Création Combobox debut période
+ comboBoxBeginPeriod.setModel(periodModel);
+ comboBoxBeginPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ // Création Combobox fin période
+ comboBoxEndPeriod.setModel(periodModel);
+ comboBoxEndPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ // Ajout des combobox
+ form.beginPeriod.add(comboBoxBeginPeriod);
+ form.endPeriod.add(comboBoxEndPeriod);
+
+ /**
+ * Positionne, si les lignes sont sélectionnées, les comboBox sur
+ * les bonnes périodes (période min et période max).
+ */
+ // Si une ou plusieurs lignes sont sélectionnées
+ if (table.getSelectedRow() != -1) {
+ // Récupère les périodes sélectionnées
+ List<PeriodDTO> listPeriod = getSelectedPeriod();
+ // Parcours du vecteur
+ comboBoxBeginPeriod.setSelectedItem(listPeriod.get(0));
+ comboBoxEndPeriod.setSelectedItem(listPeriod.get((listPeriod.size() - 1)));
+ }
+ }
+
+
+ /**
+ * Permet d'ajouter un nouvel exercice.
+ */
+ protected void addPeriod() {
+ if (log.isDebugEnabled()) {
+ log.debug("addPeriod : ");
+ //Get form data
+ }
+ PeriodDTO periodCurrent = LimaContext.getContext().getDataManager().getCurrentPeriod();
+ List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
+
+ // get begin date
+ Calendar beginCalendar = Calendar.getInstance();
+ if (periodCurrent != null) {
+ beginCalendar.setTime(periodCurrent.getBegin());
+ }
+ beginCalendar.set(Calendar.YEAR, (Integer)comboBeginYearPeriod.getSelectedItem());
+ beginCalendar.set(Calendar.DAY_OF_MONTH, 1);
+ // month is equals to list index
+ beginCalendar.set(Calendar.MONTH, comboBeginMonthPeriod.getSelectedIndex());
+ Date beginDate = beginCalendar.getTime();
+
+ // get end date
+ Calendar endCalendar = Calendar.getInstance();
+ endCalendar.set(Calendar.YEAR, (Integer)comboEndYearPeriod.getSelectedItem());
+ endCalendar.set(Calendar.MONTH , comboEndMonthPeriod.getSelectedIndex());
+ int maximum = endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+ endCalendar.set(Calendar.DAY_OF_MONTH, maximum);
+ Date endDate = endCalendar.getTime();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Add new periode from " + beginDate + " to " + endDate);
+ }
+
+ String periodName = null;
+ if (comboBeginYearPeriod.getSelectedIndex() != comboEndYearPeriod.getSelectedIndex()) {
+ periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)) + "-" + Integer.toString(endCalendar.get(Calendar.YEAR));
+ }
+ else {
+ periodName = Integer.toString(beginCalendar.get(Calendar.YEAR));
+ }
+
+ // TODO what is status.get(3) ???
+ PeriodDTO period = new PeriodDTO("", periodName, beginDate, endDate, null, null, status.get(3));
+
+ ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
+ closureModel.addPeriod(period, status);
+ }
+
+ /**
+ * Permet de mettre à jour une période. Si l'utilisateur souhaite bloquer
+ * une ou plusieurs périodes, ou bien débloquer.
+ * On récupère l'intervalle des périodes donné par le formulaire. On prend
+ * les périodes aux extrémités.
+ * Si on bloque les périodes, on va trier par ordre croissant sinon par
+ * ordre décroissant. En effet, pour débloquer une période, il est important
+ * que les périodes qui suivent soient bloquées ; par conséquent on doit
+ * commencer par les dernières.
+ */
+ protected void updatePeriod() {
+ // Liste des status
+ List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
+ // Liste des transactions
+ List<TransactionDTO> transactions = LimaContext.getContext().getDataManager().getTransactionModel().getData();
+ // Chargement du model
+ ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
+ /**
+ * Récupère l'intervalle des périodes sélectionnées
+ */
+ PeriodDTO periodBegin = (PeriodDTO) comboBoxBeginPeriod.getSelectedItem();
+ PeriodDTO periodEnd = (PeriodDTO) comboBoxEndPeriod.getSelectedItem();
+ // Exercice
+ PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
+ // Si block période, on trie la liste en croissant ou bien décroissant
+ List<PeriodDTO> listPeriod = periodMaster.getChildren();
+ if (blockPeriod) {
+ Collections.sort(listPeriod, new TriPeriodAsc());
+ } else {
+ Collections.sort(listPeriod, new TriPeriodDesc());
+ }
+ // Pour toutes les périodes mensuelles
+ for (PeriodDTO period : listPeriod) {
+ if (((period.getBegin().after(periodBegin.getBegin()))
+ && (period.getBegin().before(periodEnd.getBegin())))
+ || (period.equals(periodBegin))
+ || (period.equals(periodEnd))) {
+ if (log.isDebugEnabled()) {
+ log.debug("updatePeriod : " + period.getIdName() + " : "
+ + blockPeriod);
+ }
+ /**
+ * Détection des messages d'erreur
+ */
+ String message = closureModel.updatePeriod(period, blockPeriod, status, transactions);
+ ErrorMessage.showMessage(message);
+ }
+ }
+ // On trie par ordre croissant si c'était en décroissant, sinon l'affichage
+ // dans les vues est bouleversé. (les périodes seront affichées dans l'ordre
+ // décroissant).
+ if (!blockPeriod) {
+ Collections.sort(listPeriod, new TriPeriodAsc());
+ }
+ form.setVisible(false);
+ form.dispose();
+ }
+
+ /**
+ * Cette méthode permet de retourner une liste des périodes sélectionnées.
+ *
+ * @return liste des périodes sélectionnées
+ */
+ protected List<PeriodDTO> getSelectedPeriod() {
+ // récupère les lignes sélectionnées
+ int viewIndex[] = table.getSelectedRows();
+ // chargement du model (tableau des périodes)
+ ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
+ LinkedList<PeriodDTO> listPeriod = new LinkedList<PeriodDTO>();
+ // Pour chaque ligne sélectionnée
+ for (int i : viewIndex) {
+ int modelIndex = table.convertRowIndexToModel(i);
+ listPeriod.add(closureModel.getRow(modelIndex));
+ }
+ return listPeriod;
+ }
+
+
+ public void initAddPeriod() {
+ addPeriodForm.setTitle(_("lima.menubar.closure.addPeriod"));
+ addPeriodForm.setVisible(true);
+ }
+
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ErrorMessage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/FileChooseView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalForm.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-03-16 15:41:26 UTC (rev 2802)
@@ -152,24 +152,9 @@
<JTabbedPane id="contentTabbedPane" constraints="BorderLayout.CENTER"/>
- <jaxx.runtime.swing.StatusMessagePanel id='statusBar'
+ <!-- class not found <jaxx.runtime.swing.StatusMessagePanel id='statusBar'
_help='"ui.main.statusBar"'
- constraints="BorderLayout.SOUTH"/>
+ constraints="BorderLayout.SOUTH"/> -->
</JPanel>
- <!--<Table insets='0,0,0,0'>-->
- <!--<!– le panel principal à surcharger selon le context –>-->
- <!--<row fill="both" weightx="1" weighty="1">-->
- <!--<cell>-->
- <!--<JTabbedPane id="contentTabbedPane"/>-->
- <!--</cell>-->
- <!--</row>-->
- <!--<!– la barre de status –>-->
- <!--<row>-->
- <!--<cell fill="both">-->
- <!--<org.nuiton.widget.StatusBar id='statusBar'/>-->
- <!--</cell>-->
- <!--</row>-->
- <!--</Table>-->
-
</JFrame>
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
___________________________________________________________________
Modified: svn:keywords
- "Author Date Id Revision HeadURL
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ProgressBar.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ProgressBarImpl.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/ui/ProgressBarImpl.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ProgressBarImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,112 +0,0 @@
-/**
- * *##% Lima-main ProgressBarImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.Window;
-import java.io.IOException;
-import java.net.URL;
-
-import javax.swing.JOptionPane;
-
-import jaxx.runtime.JAXXContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.LimaSplash;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.imports.XMLImport;
-
-/**
- * Barre de progression
- *
- * @author Rémi Chapelet
- * @deprecated since 0.3.2 (replaced by {@link LimaSplash})
- */
-public class ProgressBarImpl extends ProgressBar {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(ProgressBarImpl.class);
-
- public ProgressBarImpl(JAXXContext parentContext, Window parent) {
- super(parentContext,parent);
- progressBar.setVisible(true);
- if (log.isDebugEnabled()) {
- log.debug("Lancement barre de progression...");
- }
- //progressBarFrame.setEnabled(true);
- //progressBarFrame.setAlwaysOnTop(true);
- //progressBarFrame.setVisible(true);
- //progressBarFrame.setModal(true);
- //progressBarFrame.setLocationRelativeTo(null);
- //progressBar.setStringPainted(true);
- }
-
-// public ProgressBarImpl() {
-// //progressBar.setVisible(true);
-// if (log.isDebugEnabled()) {
-// log.debug("Lancement barre de progression...");
-// }
-// progressBarFrame.setEnabled(true);
-// progressBarFrame.setAlwaysOnTop(true);
-// progressBarFrame.setVisible(true);
-// //progressBarFrame.setLocationRelativeTo(null);
-// progressBar.setStringPainted(true);
-//
-// }
-
- public void loadDefaultAccount(AccountDTO accountRoot) {
- if (log.isDebugEnabled()) {
- log.debug("Account root : " + accountRoot);
- }
- if (accountRoot.getChildren().isEmpty()) {
- if (log.isDebugEnabled()) {
- log.debug("No existing accounts");
- }
-
- String[] response = {_("lima.response.yes"), _("lima.response.no")};
- int n = JOptionPane.showOptionDialog(this,
- _("lima.question.load.accounts"),
- _("lima.question"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null, //do not use a custom Icon
- response, //the titles of buttons
- response[1]); //default button title
- if (n == JOptionPane.YES_OPTION) {
- XMLImport imports = new XMLImport();
- URL urlFile = ProgressBarImpl.class.getResource("/import/default_pcg.xml");
- try {
- imports.importAccount(urlFile.openStream());
- } catch (IOException eee) {
- log.error("Erreur chargement du fichier 'default_pcg.xml'", eee);
- }
- } else {
- LimaContext.getContext().getDataManager().resetAccountModel();
- }
- }
- }
-
-
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ProgressBarImpl.java (from rev 2796, trunk/lima-main/src/main/java/org/chorem/lima/ui/ProgressBarImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ProgressBarImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ProgressBarImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,68 @@
+/**
+ * *##% Lima-main ProgressBarImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui;
+
+import java.awt.Window;
+
+import jaxx.runtime.JAXXContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Barre de progression
+ *
+ * @author Rémi Chapelet
+ */
+public class ProgressBarImpl extends ProgressBar {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(ProgressBarImpl.class);
+
+ public ProgressBarImpl(JAXXContext parentContext, Window parent) {
+ super(parentContext,parent);
+ progressBar.setVisible(true);
+ if (log.isDebugEnabled()) {
+ log.debug("Lancement barre de progression...");
+ }
+ //progressBarFrame.setEnabled(true);
+ //progressBarFrame.setAlwaysOnTop(true);
+ //progressBarFrame.setVisible(true);
+ //progressBarFrame.setModal(true);
+ //progressBarFrame.setLocationRelativeTo(null);
+ //progressBar.setStringPainted(true);
+ }
+
+// public ProgressBarImpl() {
+// //progressBar.setVisible(true);
+// if (log.isDebugEnabled()) {
+// log.debug("Lancement barre de progression...");
+// }
+// progressBarFrame.setEnabled(true);
+// progressBarFrame.setAlwaysOnTop(true);
+// progressBarFrame.setVisible(true);
+// //progressBarFrame.setLocationRelativeTo(null);
+// progressBar.setStringPainted(true);
+//
+// }
+
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ProgressBarImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/ui/ResultViewImpl.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -21,7 +21,7 @@
import org.chorem.lima.LimaContext;
import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.balance.Balance;
+import org.chorem.lima.balance.BalanceHelper;
import org.chorem.lima.balance.Category;
import org.chorem.lima.dto.BalanceDTO;
import org.chorem.lima.dto.PeriodDTO;
@@ -64,7 +64,7 @@
private static final Log log = LogFactory.getLog(ResultViewImpl.class);
private JComboBox comboBoxPeriod = new JComboBox();
- private Balance balance = new Balance();
+ private BalanceHelper balance = new BalanceHelper();
private JXTable tableChargeRes;
private JXTable tableProduitRes;
private String resultat;
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToStringConverter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/util/JournalToStringConverter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/util/PeriodToStringConverter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java
===================================================================
--- trunk/lima-main/src/main/java/org/chorem/lima/util/Util.java 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java 2010-03-16 15:41:26 UTC (rev 2802)
@@ -35,6 +35,8 @@
/**
* @author ore
* @author Rémi Chapelet
+ *
+ * @deprecated since 0.4.0 with no replacement
*/
public class Util {
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/lima-swing/src/main/resources/i18n/lima-main-en_GB.properties
===================================================================
--- trunk/lima-main/src/main/resources/i18n/lima-main-en_GB.properties 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/resources/i18n/lima-main-en_GB.properties 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,232 +0,0 @@
-lima.about.message=
-lima.account=Account
-lima.account.type=Account type
-lima.actif=Asset
-lima.action.commandline.disable.main.ui=Do not launch main ui
-lima.action.commandline.help=Show help in console
-lima.action.fullscreen=Full screen
-lima.action.fullscreen.tip=Open ui in full screen
-lima.action.normalscreen=Normal screen
-lima.action.normalscreen.tip=Open ui in normal screen
-lima.add=Add
-lima.add.entry=Add an entry
-lima.add.lettering=Add a letter
-lima.add.transaction=Add a transaction
-lima.all=All
-lima.all.criteria=All criteria are met
-lima.amount=Amount
-lima.any.criteria=Any criteria are met
-lima.balance=Balance
-lima.balance.account.libelle=Title
-lima.balance.account.number=N\u00B0 account
-lima.balance.move.credit=Credit
-lima.balance.move.debit=Debit
-lima.balance.solde.credit=Balance credit
-lima.balance.solde.debit=Balance debit
-lima.balance.total=Total
-lima.bilan=Bilan
-lima.bilan.actif=Actif
-lima.bilan.brut=Brut
-lima.bilan.depreciation=Depreciation
-lima.bilan.net=Net
-lima.bilan.passif=Passif
-lima.bilan.total=Total
-lima.block=block
-lima.cancel=Cancel
-lima.charge=Expense
-lima.closure.period.begin=Period
-lima.closure.timespan.warning=Warning\: when the period is blocked, it is possible to add, edit and delete entries on the accounting period.
-lima.config.category.directories=
-lima.config.category.directories.description=
-lima.config.category.other=
-lima.config.category.other.description=
-lima.config.configFileName.description=
-lima.config.locale.description=
-lima.config.ui.fullscreen=
-lima.credit=Credit
-lima.daily=Daily
-lima.date=Date
-lima.date.april=April
-lima.date.august=August
-lima.date.december=December
-lima.date.february=February
-lima.date.january=January
-lima.date.july=July
-lima.date.june=June
-lima.date.march=March
-lima.date.may=May
-lima.date.november=November
-lima.date.october=October
-lima.date.september=September
-lima.debit=Debit
-lima.description=Description
-lima.edit=Edit
-lima.edit.transaction=Edit transaction
-lima.entries=Entries
-lima.error=Error
-lima.error.account.double=It exists an account with a same number
-lima.error.account.not.exist=This account doesn't exist
-lima.error.account.not.master=This account has not an account master
-lima.error.account.with.entries=This account has some entries
-lima.error.entry.not.exist=
-lima.error.entry.not.remove=
-lima.error.journal.double=A journal exist with this name
-lima.error.journal.not.exist=This journal doesn't exist
-lima.error.journal.with.transactions=This journal has some transactions
-lima.error.period.all.timespan=
-lima.error.period.create.timespan=
-lima.error.period.next.not.blocked=
-lima.error.period.not.exist=
-lima.error.period.prec.not.blocked=It exists periods not blocked
-lima.error.period.timespan.block=
-lima.error.period.timespan.not.blocked=
-lima.error.transaction.exist.not.balanced=It exists transactions not balanced
-lima.error.transaction.not.create=This transaction has not been created
-lima.error.transaction.not.exist=This transaction doesn't exist
-lima.error.transaction.not.journal=This transaction has not a journal
-lima.error.transaction.not.period=This transaction has not a period
-lima.error.transaction.not.remove=This transaction has not been removed
-lima.error.transaction.period.not.blocked=The period is blocked
-lima.exception.number.format=Numeric format only accepted
-lima.export=Export
-lima.export.CSV=CSV Export
-lima.export.PDF=PDF Export
-lima.export.account=Export PCG
-lima.export.all=Export all datas (XML)
-lima.export.all.csv=Exporter all datas (CSV)
-lima.filter.after=After
-lima.filter.before=Before
-lima.filter.contains=Contains
-lima.filter.equals.to=Equals to
-lima.filter.greater.than=Greater than
-lima.filter.less.than=Less than
-lima.filter.not.contains=Not contains
-lima.filter.starts.with=Starts with
-lima.find.transaction=Find transaction
-lima.grand.livre=General Ledger
-lima.home=Home - TODO
-lima.import=Import
-lima.import.account=Import PCG
-lima.import.all=Import all datas
-lima.import.all.csv=Import all datas (CSV)
-lima.import.all.csv.ebp=Import all datas (EBP)
-lima.import.error=Your datas had't not been loaded
-lima.import.journal=Import journal
-lima.import.success=Your datas had been loaded
-lima.init.closed=Lima closed at %1$s
-lima.init.context.done=Context was initialized in %1$s
-lima.init.ui.done=UI initialized
-lima.journal=Journal
-lima.lettered=Lettered
-lima.lettering=Lettering
-lima.loading=Loading
-lima.menu.file=File
-lima.menu.help=Help
-lima.menu.help.about=About
-lima.menu.help.help=Help
-lima.menu.help.i18n=Language
-lima.menu.help.i18n.fr=French
-lima.menu.help.i18n.uk=English
-lima.menu.help.site=WebSite
-lima.menubar.closure=Closure
-lima.menubar.closure.addPeriod=Add a period
-lima.menubar.closure.listperiod=See all periods
-lima.menubar.closure.period=close a period (annual)
-lima.menubar.closure.timespan=close a period (monthly)
-lima.message.config.loaded=Config was loaded
-lima.message.error.empty.line=Please choose an account
-lima.model.account=Account
-lima.model.balance=Balance
-lima.model.credit=Credit
-lima.model.date=Date
-lima.model.debit=Debit
-lima.model.description=Description
-lima.model.etat=Etat
-lima.model.journal=Journal
-lima.model.lettering=Lettering
-lima.model.name=Name
-lima.model.period=Period
-lima.model.prefix=Prefix
-lima.model.status=Status
-lima.model.voucher=Voucher
-lima.name=Name
-lima.non.valids.transactions=No valids transactions
-lima.not.lettered=Not lettered
-lima.number=Number
-lima.ok=OK
-lima.passif=Liability
-lima.period=Period
-lima.period.close=Close
-lima.period.open=Open
-lima.preferences=Preferences
-lima.prefix=Prefix
-lima.print=Print
-lima.produit=Revenue
-lima.progressBar.export.etape1=Create the file
-lima.progressBar.export.etape2=Create informations
-lima.progressBar.export.etape3=Create periods
-lima.progressBar.export.etape4=Create journals
-lima.progressBar.export.etape5=Create accounts
-lima.progressBar.export.etape6=Create transactions
-lima.progressBar.export.etape7=Save the file
-lima.progressBar.export.title=Save
-lima.progressBar.load.etape1=Loading journals
-lima.progressBar.load.etape2=Loading accounts
-lima.progressBar.load.etape3=Loading status
-lima.progressBar.load.etape4=Loading periods
-lima.progressBar.load.etape5=Loading transactions
-lima.question=Question
-lima.question.load.accounts=There is no existing accounts in Lima. Do you want to load default accounts ?
-lima.question.remove.account=Do you want to remove this account ?
-lima.question.remove.entry=Do you want to remove this entry ?
-lima.question.remove.journal=Do you want to remove this journal ?
-lima.question.remove.transaction=Do you want to remove this transaction ?
-lima.quit=Quit
-lima.remove=Remove
-lima.remove.lettering=Remove a letter
-lima.remove.transaction=Remove a transaction
-lima.reports=Reports
-lima.response.no=No
-lima.response.yes=Yes
-lima.result=Result
-lima.result.charge=CHARGES
-lima.result.loss=Perte
-lima.result.produit=PRODUITS
-lima.result.profit=B\u00E9n\u00E9fice
-lima.result.total.charge=TOTAL CHARGES
-lima.result.total.produit=TOTAL PRODUITS
-lima.search=Search
-lima.search.items.where=Search items where
-lima.search.title.criteria.box=Criteria
-lima.since=Since
-lima.status.tr.balanced=Balanced
-lima.status.tr.finalized=Finalized
-lima.status.tr.wip=Work in progress
-lima.success=Success
-lima.tab.account=Account
-lima.tab.balance=Balance
-lima.tab.bilan=Results
-lima.tab.closure=Closure
-lima.tab.home=Home
-lima.tab.journal=Journal
-lima.tab.lettering=Lettering
-lima.tab.reports=Reports
-lima.tab.result=Result
-lima.tab.search.result=Search result
-lima.tab.transaction=Transaction
-lima.title=Lutin Invoice Monitoring and Accounting
-lima.title.about=About Lima...
-lima.to=To
-lima.ui.add.account=Add account
-lima.ui.add.journal=Add journal
-lima.ui.block.timespan=Block period
-lima.ui.unblock.timespan=Unblock period
-lima.ui.update.account=Update account
-lima.ui.update.journal=Update journal
-lima.unblock=Unblock
-lima.update=Update
-lima.view=View
-lima.view.flatten=Flatten view
-lima.voucher=Voucher
-lima.warning.nimbus.landf=Could not find Numbus Look&Feel
-lima.warning.no.ui=No ui display detected
Deleted: trunk/lima-swing/src/main/resources/i18n/lima-main-fr_FR.properties
===================================================================
--- trunk/lima-main/src/main/resources/i18n/lima-main-fr_FR.properties 2010-02-26 16:37:18 UTC (rev 2790)
+++ trunk/lima-swing/src/main/resources/i18n/lima-main-fr_FR.properties 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,232 +0,0 @@
-lima.about.message=
-lima.account=Compte
-lima.account.type=Type de compte
-lima.actif=Actif
-lima.action.commandline.disable.main.ui=Ne pas lancer l'ui
-lima.action.commandline.help=Afficher l'aide en console
-lima.action.fullscreen=Plein Ecran
-lima.action.fullscreen.tip=Passer en mode plein \u00E9cran
-lima.action.normalscreen=Ecran normal
-lima.action.normalscreen.tip=Revenir en \u00E9cran normal
-lima.add=Ajout
-lima.add.entry=Ajouter une entr\u00E9e
-lima.add.lettering=Ajouter une lettre
-lima.add.transaction=Ajouter une transaction
-lima.all=Tous
-lima.all.criteria=Tous les crit\u00E8res correspondent
-lima.amount=Montant
-lima.any.criteria=Au moins un critcre correspond
-lima.balance=Balance
-lima.balance.account.libelle=Libell\u00E9
-lima.balance.account.number=N\u00B0 de compte
-lima.balance.move.credit=Mouvement au cr\u00E9dit
-lima.balance.move.debit=Mouvement au d\u00E9bit
-lima.balance.solde.credit=Solde cr\u00E9dit
-lima.balance.solde.debit=Solde d\u00E9bit
-lima.balance.total=Total
-lima.bilan=Bilan
-lima.bilan.actif=Actif
-lima.bilan.brut=Brut
-lima.bilan.depreciation=Amort. et Prov.
-lima.bilan.net=Net
-lima.bilan.passif=Passif
-lima.bilan.total=Total
-lima.block=Bloquer
-lima.cancel=Annuler
-lima.charge=Charge
-lima.closure.period.begin=P\u00E9riode du
-lima.closure.timespan.warning=Attention \: lorsque la p\u00E9riode est bloqu\u00E9e, il n'est plus possible d'ajouter, modifier et supprimer les entr\u00E9es comptables sur cette p\u00E9riode.
-lima.config.category.directories=R\u00E9pertoires
-lima.config.category.directories.description=R\u00E9pertoires utilis\u00E9s par Lima
-lima.config.category.other=Autre
-lima.config.category.other.description=Autre propri\u00E9t\u00E9s de configuration
-lima.config.configFileName.description=
-lima.config.locale.description=Locale utilis\u00E9e par l'application
-lima.config.ui.fullscreen=Drapeau pour utiliser le mode plein \u00E9cran
-lima.credit=Credit
-lima.daily=Quotidien
-lima.date=Date
-lima.date.april=Avril
-lima.date.august=Ao\u00FBt
-lima.date.december=D\u00E9cembre
-lima.date.february=F\u00E9vrier
-lima.date.january=Janvier
-lima.date.july=Juillet
-lima.date.june=Juin
-lima.date.march=Mars
-lima.date.may=Mai
-lima.date.november=Novembre
-lima.date.october=Octobre
-lima.date.september=Septembre
-lima.debit=Debit
-lima.description=Description
-lima.edit=Editer
-lima.edit.transaction=Editer une transaction
-lima.entries=Lignes d'\u00E9criture
-lima.error=Erreur
-lima.error.account.double=Il existe un compte avec ce m\u00EAme num\u00E9ro de compte
-lima.error.account.not.exist=Ce num\u00E9ro de compte n'existe pas
-lima.error.account.not.master=Ce compte ne poss\u00E8de pas de compte principal
-lima.error.account.with.entries=Ce compte poss\u00E8de des entr\u00E9es comptables
-lima.error.entry.not.exist=
-lima.error.entry.not.remove=
-lima.error.journal.double=Un journal poss\u00E8de d\u00E9j\u00E0 ce nom
-lima.error.journal.not.exist=Ce journal n'existe pas
-lima.error.journal.with.transactions=Ce journal poss\u00E8de des transactions comptables
-lima.error.period.all.timespan=
-lima.error.period.create.timespan=
-lima.error.period.next.not.blocked=
-lima.error.period.not.exist=
-lima.error.period.prec.not.blocked=Il existe des p\u00E9riodes pr\u00E9c\u00E9dentes non bloqu\u00E9es
-lima.error.period.timespan.block=
-lima.error.period.timespan.not.blocked=
-lima.error.transaction.exist.not.balanced=Il existe des transactions non \u00E9quilibr\u00E9es
-lima.error.transaction.not.create=La transaction n'a pu \u00EAtre cr\u00E9\u00E9e
-lima.error.transaction.not.exist=La transaction n'existe pas
-lima.error.transaction.not.journal=La transaction doit \u00EAtre associ\u00E9e \u00E0 un journal
-lima.error.transaction.not.period=La transaction doit \u00EAtre associ\u00E9e \u00E0 une p\u00E9riode
-lima.error.transaction.not.remove=La transaction n'a pu \u00EAtre supprim\u00E9e.
-lima.error.transaction.period.not.blocked=La p\u00E9riode de la transaction est bloqu\u00E9e.
-lima.exception.number.format=Uniquement un format num\u00E9rique est accept\u00E9
-lima.export=Export
-lima.export.CSV=CSV
-lima.export.PDF=PDF
-lima.export.account=Exporter le PCG
-lima.export.all=Exporter toutes les donn\u00E9es (XML)
-lima.export.all.csv=Exporter toutes les donn\u00E9es (CSV)
-lima.filter.after=Apr\u00E8s
-lima.filter.before=Avant
-lima.filter.contains=Contient
-lima.filter.equals.to=Egal \u00E0
-lima.filter.greater.than=Sup\u00E9rieur \u00E0
-lima.filter.less.than=Inf\u00E9rieur \u00E0
-lima.filter.not.contains=Ne contient pas
-lima.filter.starts.with=Commence par
-lima.find.transaction=Rechercher transaction
-lima.grand.livre=Grand-Livre
-lima.home=Page d'accueil - TODO
-lima.import=Import
-lima.import.account=Importer le PCG
-lima.import.all=Importer une nouvelle base (XML)
-lima.import.all.csv=Importer une nouvelle base (CSV)
-lima.import.all.csv.ebp=Importer des donn\u00E9es de EBP
-lima.import.error=Vos donn\u00E9es n'ont pu \u00EAtre charg\u00E9es
-lima.import.journal=Importer le journal
-lima.import.success=Vos donn\u00E9es ont bien \u00E9t\u00E9 charg\u00E9es
-lima.init.closed=Lima ferm\u00E9 \u00E0 %1$s
-lima.init.context.done=Initialisation du context termin\u00E9 en %1$s
-lima.init.ui.done=Initialisation des interface graphiques termin\u00E9e
-lima.journal=Journal
-lima.lettered=Lettr\u00E9
-lima.lettering=Lettrage
-lima.loading=Chargement
-lima.menu.file=Fichier
-lima.menu.help=Aide
-lima.menu.help.about=A Propos
-lima.menu.help.help=Afficher l'aide
-lima.menu.help.i18n=Langue
-lima.menu.help.i18n.fr=Fran\u00E7ais
-lima.menu.help.i18n.uk=Anglais
-lima.menu.help.site=Acc\u00E9der au site de Lima
-lima.menubar.closure=Cl\u00F4ture
-lima.menubar.closure.addPeriod=Ajouter une p\u00E9riode
-lima.menubar.closure.listperiod=Voir toutes les cl\u00F4tures
-lima.menubar.closure.period=Cl\u00F4turer l'exercice
-lima.menubar.closure.timespan=Cl\u00F4turer une p\u00E9riode
-lima.message.config.loaded=
-lima.message.error.empty.line=Veuillez choisir un compte
-lima.model.account=Compte
-lima.model.balance=Balance
-lima.model.credit=Cr\u00E9dit
-lima.model.date=Date
-lima.model.debit=D\u00E9bit
-lima.model.description=Description
-lima.model.etat=Etat
-lima.model.journal=Journal
-lima.model.lettering=Lettrage
-lima.model.name=Nom
-lima.model.period=P\u00E9riode
-lima.model.prefix=Pr\u00E9fixe
-lima.model.status=Statut
-lima.model.voucher=Document
-lima.name=Nom
-lima.non.valids.transactions=Ecritures non valides
-lima.not.lettered=Non lettr\u00E9
-lima.number=Num\u00E9ro
-lima.ok=OK
-lima.passif=Passif
-lima.period=P\u00E9riode
-lima.period.close=Ferm\u00E9
-lima.period.open=Ouvert
-lima.preferences=Pr\u00E9f\u00E9rences
-lima.prefix=Prefixe
-lima.print=Imprimer
-lima.produit=Produit
-lima.progressBar.export.etape1=Cr\u00E9ation base du fichier
-lima.progressBar.export.etape2=Cr\u00E9ation informations
-lima.progressBar.export.etape3=Cr\u00E9ation des p\u00E9riodes
-lima.progressBar.export.etape4=Cr\u00E9ation des journaux
-lima.progressBar.export.etape5=Cr\u00E9ation des comptes
-lima.progressBar.export.etape6=Cr\u00E9ation des transactions
-lima.progressBar.export.etape7=Enregistrement du fichier
-lima.progressBar.export.title=Sauvegarde
-lima.progressBar.load.etape1=Chargement des journaux
-lima.progressBar.load.etape2=Chargement des comptes
-lima.progressBar.load.etape3=Chargement des status
-lima.progressBar.load.etape4=Chargement des p\u00E9riodes
-lima.progressBar.load.etape5=Chargement des transactions
-lima.question=Question
-lima.question.load.accounts=Il n'y a aucun plan comptable existant dans Lima. Voulez-vous en charger un par d\u00E9faut ?
-lima.question.remove.account=Voulez-vous supprimer ce compte?
-lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
-lima.question.remove.journal=Voulez-vous supprimer ce journal?
-lima.question.remove.transaction=Voulez-vous supprimer cette transaction?
-lima.quit=Quitter
-lima.remove=Supprimer
-lima.remove.lettering=Supprimer la lettre
-lima.remove.transaction=Supprimer une transaction
-lima.reports=Rapports
-lima.response.no=Non
-lima.response.yes=Oui
-lima.result=Compte de r\u00E9sultat
-lima.result.charge=CHARGES
-lima.result.loss=Perte
-lima.result.produit=PRODUITS
-lima.result.profit=B\u00E9n\u00E9fice
-lima.result.total.charge=TOTAL CHARGES
-lima.result.total.produit=TOTAL PRODUITS
-lima.search=Rechercher
-lima.search.items.where=Trouver les \u00E9critures o\u00F9
-lima.search.title.criteria.box=Crit\u00E8res
-lima.since=Depuis
-lima.status.tr.balanced=Equilibr\u00E9e
-lima.status.tr.finalized=Valid\u00E9e
-lima.status.tr.wip=En cours
-lima.success=Succ\u00E8s
-lima.tab.account=Compte
-lima.tab.balance=Balance
-lima.tab.bilan=Bilan
-lima.tab.closure=Cl\u00F4ture
-lima.tab.home=Accueil
-lima.tab.journal=Journal
-lima.tab.lettering=Lettrage
-lima.tab.reports=Rapports
-lima.tab.result=Compte de r\u00E9sultat
-lima.tab.search.result=Recherche
-lima.tab.transaction=Ecriture
-lima.title=Lutin Invoice Monitoring and Accounting
-lima.title.about=A propos de Lima...
-lima.to=A
-lima.ui.add.account=Ajouter un compte
-lima.ui.add.journal=Ajouter un journal
-lima.ui.block.timespan=Bloquer une p\u00E9riode mensuelle
-lima.ui.unblock.timespan=D\u00E9bloquer une p\u00E9riode mensuelle
-lima.ui.update.account=Mettre \u00E0 jour le compte
-lima.ui.update.journal=Mettre \u00E0 jour le journal
-lima.unblock=D\u00E9bloquer
-lima.update=Mettre \u00E0 jour
-lima.view=Vue
-lima.view.flatten=Vue aplatie
-lima.voucher=Document
-lima.warning.nimbus.landf=Le look and feel nymbus n'a pas \u00E9t\u00E9 trouv\u00E9
-lima.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9.
Copied: trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties (from rev 2790, trunk/lima-main/src/main/resources/i18n/lima-main-en_GB.properties)
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties (rev 0)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,232 @@
+lima.about.message=
+lima.account=Account
+lima.account.type=Account type
+lima.actif=Asset
+lima.action.commandline.disable.main.ui=Do not launch main ui
+lima.action.commandline.help=Show help in console
+lima.action.fullscreen=Full screen
+lima.action.fullscreen.tip=Open ui in full screen
+lima.action.normalscreen=Normal screen
+lima.action.normalscreen.tip=Open ui in normal screen
+lima.add=Add
+lima.add.entry=Add an entry
+lima.add.lettering=Add a letter
+lima.add.transaction=Add a transaction
+lima.all=All
+lima.all.criteria=All criteria are met
+lima.amount=Amount
+lima.any.criteria=Any criteria are met
+lima.balance=Balance
+lima.balance.account.libelle=Title
+lima.balance.account.number=N\u00B0 account
+lima.balance.move.credit=Credit
+lima.balance.move.debit=Debit
+lima.balance.solde.credit=Balance credit
+lima.balance.solde.debit=Balance debit
+lima.balance.total=Total
+lima.bilan=Bilan
+lima.bilan.actif=Actif
+lima.bilan.brut=Brut
+lima.bilan.depreciation=Depreciation
+lima.bilan.net=Net
+lima.bilan.passif=Passif
+lima.bilan.total=Total
+lima.block=block
+lima.cancel=Cancel
+lima.charge=Expense
+lima.closure.period.begin=Period from
+lima.closure.timespan.warning=Warning\: when the period is blocked, it is possible to add, edit and delete entries on the accounting period.
+lima.config.category.directories=
+lima.config.category.directories.description=
+lima.config.category.other=
+lima.config.category.other.description=
+lima.config.configFileName.description=
+lima.config.locale.description=
+lima.config.ui.fullscreen=
+lima.credit=Credit
+lima.daily=Daily
+lima.date=Date
+lima.date.april=April
+lima.date.august=August
+lima.date.december=December
+lima.date.february=February
+lima.date.january=January
+lima.date.july=July
+lima.date.june=June
+lima.date.march=March
+lima.date.may=May
+lima.date.november=November
+lima.date.october=October
+lima.date.september=September
+lima.debit=Debit
+lima.description=Description
+lima.edit=Edit
+lima.edit.transaction=Edit transaction
+lima.entries=Entries
+lima.error=Error
+lima.error.account.double=It exists an account with a same number
+lima.error.account.not.exist=This account doesn't exist
+lima.error.account.not.master=This account has not an account master
+lima.error.account.with.entries=This account has some entries
+lima.error.entry.not.exist=
+lima.error.entry.not.remove=
+lima.error.journal.double=A journal exist with this name
+lima.error.journal.not.exist=This journal doesn't exist
+lima.error.journal.with.transactions=This journal has some transactions
+lima.error.period.all.timespan=
+lima.error.period.create.timespan=
+lima.error.period.next.not.blocked=
+lima.error.period.not.exist=
+lima.error.period.prec.not.blocked=It exists periods not blocked
+lima.error.period.timespan.block=
+lima.error.period.timespan.not.blocked=
+lima.error.transaction.exist.not.balanced=It exists transactions not balanced
+lima.error.transaction.not.create=This transaction has not been created
+lima.error.transaction.not.exist=This transaction doesn't exist
+lima.error.transaction.not.journal=This transaction has not a journal
+lima.error.transaction.not.period=This transaction has not a period
+lima.error.transaction.not.remove=This transaction has not been removed
+lima.error.transaction.period.not.blocked=The period is blocked
+lima.exception.number.format=Numeric format only accepted
+lima.export=Export
+lima.export.CSV=CSV Export
+lima.export.PDF=PDF Export
+lima.export.account=Export PCG
+lima.export.all=Export all datas (XML)
+lima.export.all.csv=Exporter all datas (CSV)
+lima.filter.after=After
+lima.filter.before=Before
+lima.filter.contains=Contains
+lima.filter.equals.to=Equals to
+lima.filter.greater.than=Greater than
+lima.filter.less.than=Less than
+lima.filter.not.contains=Not contains
+lima.filter.starts.with=Starts with
+lima.find.transaction=Find transaction
+lima.grand.livre=General Ledger
+lima.home=Home - TODO
+lima.import=Import
+lima.import.account=Import PCG
+lima.import.all=Import all datas
+lima.import.all.csv=Import all datas (CSV)
+lima.import.all.csv.ebp=Import all datas (EBP)
+lima.import.error=Your datas had't not been loaded
+lima.import.journal=Import journal
+lima.import.success=Your datas had been loaded
+lima.init.closed=Lima closed at %1$s
+lima.init.context.done=Context was initialized in %1$s
+lima.init.ui.done=UI initialized
+lima.journal=Journal
+lima.lettered=Lettered
+lima.lettering=Lettering
+lima.loading=Loading
+lima.menu.file=File
+lima.menu.help=Help
+lima.menu.help.about=About
+lima.menu.help.help=Help
+lima.menu.help.i18n=Language
+lima.menu.help.i18n.fr=French
+lima.menu.help.i18n.uk=English
+lima.menu.help.site=WebSite
+lima.menubar.closure=Closure
+lima.menubar.closure.addPeriod=Add a period
+lima.menubar.closure.listperiod=See all periods
+lima.menubar.closure.period=close a period (annual)
+lima.menubar.closure.timespan=close a period (monthly)
+lima.message.config.loaded=Config was loaded
+lima.message.error.empty.line=Please choose an account
+lima.model.account=Account
+lima.model.balance=Balance
+lima.model.credit=Credit
+lima.model.date=Date
+lima.model.debit=Debit
+lima.model.description=Description
+lima.model.etat=Etat
+lima.model.journal=Journal
+lima.model.lettering=Lettering
+lima.model.name=Name
+lima.model.period=Period
+lima.model.prefix=Prefix
+lima.model.status=Status
+lima.model.voucher=Voucher
+lima.name=Name
+lima.non.valids.transactions=No valids transactions
+lima.not.lettered=Not lettered
+lima.number=Number
+lima.ok=OK
+lima.passif=Liability
+lima.period=Period
+lima.period.close=Close
+lima.period.open=Open
+lima.preferences=Preferences
+lima.prefix=Prefix
+lima.print=Print
+lima.produit=Revenue
+lima.progressBar.export.etape1=Create the file
+lima.progressBar.export.etape2=Create informations
+lima.progressBar.export.etape3=Create periods
+lima.progressBar.export.etape4=Create journals
+lima.progressBar.export.etape5=Create accounts
+lima.progressBar.export.etape6=Create transactions
+lima.progressBar.export.etape7=Save the file
+lima.progressBar.export.title=Save
+lima.progressBar.load.etape1=Loading journals
+lima.progressBar.load.etape2=Loading accounts
+lima.progressBar.load.etape3=Loading status
+lima.progressBar.load.etape4=Loading periods
+lima.progressBar.load.etape5=Loading transactions
+lima.question=Question
+lima.question.load.accounts=There is no existing accounts in Lima. Do you want to load default accounts ?
+lima.question.remove.account=Do you want to remove this account ?
+lima.question.remove.entry=Do you want to remove this entry ?
+lima.question.remove.journal=Do you want to remove this journal ?
+lima.question.remove.transaction=Do you want to remove this transaction ?
+lima.quit=Quit
+lima.remove=Remove
+lima.remove.lettering=Remove a letter
+lima.remove.transaction=Remove a transaction
+lima.reports=Reports
+lima.response.no=No
+lima.response.yes=Yes
+lima.result=Result
+lima.result.charge=CHARGES
+lima.result.loss=Perte
+lima.result.produit=PRODUITS
+lima.result.profit=B\u00E9n\u00E9fice
+lima.result.total.charge=TOTAL CHARGES
+lima.result.total.produit=TOTAL PRODUITS
+lima.search=Search
+lima.search.items.where=Search items where
+lima.search.title.criteria.box=Criteria
+lima.since=Since
+lima.status.tr.balanced=Balanced
+lima.status.tr.finalized=Finalized
+lima.status.tr.wip=Work in progress
+lima.success=Success
+lima.tab.account=Account
+lima.tab.balance=Balance
+lima.tab.bilan=Results
+lima.tab.closure=Closure
+lima.tab.home=Home
+lima.tab.journal=Journal
+lima.tab.lettering=Lettering
+lima.tab.reports=Reports
+lima.tab.result=Result
+lima.tab.search.result=Search result
+lima.tab.transaction=Transaction
+lima.title=Lutin Invoice Monitoring and Accounting
+lima.title.about=About Lima...
+lima.to=To
+lima.ui.add.account=Add account
+lima.ui.add.journal=Add journal
+lima.ui.block.timespan=Block period
+lima.ui.unblock.timespan=Unblock period
+lima.ui.update.account=Update account
+lima.ui.update.journal=Update journal
+lima.unblock=Unblock
+lima.update=Update
+lima.view=View
+lima.view.flatten=Flatten view
+lima.voucher=Voucher
+lima.warning.nimbus.landf=Could not find Numbus Look&Feel
+lima.warning.no.ui=No ui display detected
Copied: trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties (from rev 2790, trunk/lima-main/src/main/resources/i18n/lima-main-fr_FR.properties)
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties (rev 0)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,232 @@
+lima.about.message=
+lima.account=Compte
+lima.account.type=Type de compte
+lima.actif=Actif
+lima.action.commandline.disable.main.ui=Ne pas lancer l'ui
+lima.action.commandline.help=Afficher l'aide en console
+lima.action.fullscreen=Plein Ecran
+lima.action.fullscreen.tip=Passer en mode plein \u00E9cran
+lima.action.normalscreen=Ecran normal
+lima.action.normalscreen.tip=Revenir en \u00E9cran normal
+lima.add=Ajout
+lima.add.entry=Ajouter une entr\u00E9e
+lima.add.lettering=Ajouter une lettre
+lima.add.transaction=Ajouter une transaction
+lima.all=Tous
+lima.all.criteria=Tous les crit\u00E8res correspondent
+lima.amount=Montant
+lima.any.criteria=Au moins un critcre correspond
+lima.balance=Balance
+lima.balance.account.libelle=Libell\u00E9
+lima.balance.account.number=N\u00B0 de compte
+lima.balance.move.credit=Mouvement au cr\u00E9dit
+lima.balance.move.debit=Mouvement au d\u00E9bit
+lima.balance.solde.credit=Solde cr\u00E9dit
+lima.balance.solde.debit=Solde d\u00E9bit
+lima.balance.total=Total
+lima.bilan=Bilan
+lima.bilan.actif=Actif
+lima.bilan.brut=Brut
+lima.bilan.depreciation=Amort. et Prov.
+lima.bilan.net=Net
+lima.bilan.passif=Passif
+lima.bilan.total=Total
+lima.block=Bloquer
+lima.cancel=Annuler
+lima.charge=Charge
+lima.closure.period.begin=P\u00E9riode de
+lima.closure.timespan.warning=Attention \: lorsque la p\u00E9riode est bloqu\u00E9e, il n'est plus possible d'ajouter, modifier et supprimer les entr\u00E9es comptables sur cette p\u00E9riode.
+lima.config.category.directories=R\u00E9pertoires
+lima.config.category.directories.description=R\u00E9pertoires utilis\u00E9s par Lima
+lima.config.category.other=Autre
+lima.config.category.other.description=Autre propri\u00E9t\u00E9s de configuration
+lima.config.configFileName.description=
+lima.config.locale.description=Locale utilis\u00E9e par l'application
+lima.config.ui.fullscreen=Drapeau pour utiliser le mode plein \u00E9cran
+lima.credit=Credit
+lima.daily=Quotidien
+lima.date=Date
+lima.date.april=Avril
+lima.date.august=Ao\u00FBt
+lima.date.december=D\u00E9cembre
+lima.date.february=F\u00E9vrier
+lima.date.january=Janvier
+lima.date.july=Juillet
+lima.date.june=Juin
+lima.date.march=Mars
+lima.date.may=Mai
+lima.date.november=Novembre
+lima.date.october=Octobre
+lima.date.september=Septembre
+lima.debit=Debit
+lima.description=Description
+lima.edit=Editer
+lima.edit.transaction=Editer une transaction
+lima.entries=Lignes d'\u00E9criture
+lima.error=Erreur
+lima.error.account.double=Il existe un compte avec ce m\u00EAme num\u00E9ro de compte
+lima.error.account.not.exist=Ce num\u00E9ro de compte n'existe pas
+lima.error.account.not.master=Ce compte ne poss\u00E8de pas de compte principal
+lima.error.account.with.entries=Ce compte poss\u00E8de des entr\u00E9es comptables
+lima.error.entry.not.exist=
+lima.error.entry.not.remove=
+lima.error.journal.double=Un journal poss\u00E8de d\u00E9j\u00E0 ce nom
+lima.error.journal.not.exist=Ce journal n'existe pas
+lima.error.journal.with.transactions=Ce journal poss\u00E8de des transactions comptables
+lima.error.period.all.timespan=
+lima.error.period.create.timespan=
+lima.error.period.next.not.blocked=
+lima.error.period.not.exist=
+lima.error.period.prec.not.blocked=Il existe des p\u00E9riodes pr\u00E9c\u00E9dentes non bloqu\u00E9es
+lima.error.period.timespan.block=
+lima.error.period.timespan.not.blocked=
+lima.error.transaction.exist.not.balanced=Il existe des transactions non \u00E9quilibr\u00E9es
+lima.error.transaction.not.create=La transaction n'a pu \u00EAtre cr\u00E9\u00E9e
+lima.error.transaction.not.exist=La transaction n'existe pas
+lima.error.transaction.not.journal=La transaction doit \u00EAtre associ\u00E9e \u00E0 un journal
+lima.error.transaction.not.period=La transaction doit \u00EAtre associ\u00E9e \u00E0 une p\u00E9riode
+lima.error.transaction.not.remove=La transaction n'a pu \u00EAtre supprim\u00E9e.
+lima.error.transaction.period.not.blocked=La p\u00E9riode de la transaction est bloqu\u00E9e.
+lima.exception.number.format=Uniquement un format num\u00E9rique est accept\u00E9
+lima.export=Export
+lima.export.CSV=CSV
+lima.export.PDF=PDF
+lima.export.account=Exporter le PCG
+lima.export.all=Exporter toutes les donn\u00E9es (XML)
+lima.export.all.csv=Exporter toutes les donn\u00E9es (CSV)
+lima.filter.after=Apr\u00E8s
+lima.filter.before=Avant
+lima.filter.contains=Contient
+lima.filter.equals.to=Egal \u00E0
+lima.filter.greater.than=Sup\u00E9rieur \u00E0
+lima.filter.less.than=Inf\u00E9rieur \u00E0
+lima.filter.not.contains=Ne contient pas
+lima.filter.starts.with=Commence par
+lima.find.transaction=Rechercher transaction
+lima.grand.livre=Grand-Livre
+lima.home=Page d'accueil - TODO
+lima.import=Import
+lima.import.account=Importer le PCG
+lima.import.all=Importer une nouvelle base (XML)
+lima.import.all.csv=Importer une nouvelle base (CSV)
+lima.import.all.csv.ebp=Importer des donn\u00E9es de EBP
+lima.import.error=Vos donn\u00E9es n'ont pu \u00EAtre charg\u00E9es
+lima.import.journal=Importer le journal
+lima.import.success=Vos donn\u00E9es ont bien \u00E9t\u00E9 charg\u00E9es
+lima.init.closed=Lima ferm\u00E9 \u00E0 %1$s
+lima.init.context.done=Initialisation du context termin\u00E9 en %1$s
+lima.init.ui.done=Initialisation des interface graphiques termin\u00E9e
+lima.journal=Journal
+lima.lettered=Lettr\u00E9
+lima.lettering=Lettrage
+lima.loading=Chargement
+lima.menu.file=Fichier
+lima.menu.help=Aide
+lima.menu.help.about=A Propos
+lima.menu.help.help=Afficher l'aide
+lima.menu.help.i18n=Langue
+lima.menu.help.i18n.fr=Fran\u00E7ais
+lima.menu.help.i18n.uk=Anglais
+lima.menu.help.site=Acc\u00E9der au site de Lima
+lima.menubar.closure=Cl\u00F4ture
+lima.menubar.closure.addPeriod=Ajouter une p\u00E9riode
+lima.menubar.closure.listperiod=Voir toutes les cl\u00F4tures
+lima.menubar.closure.period=Cl\u00F4turer l'exercice
+lima.menubar.closure.timespan=Cl\u00F4turer une p\u00E9riode
+lima.message.config.loaded=
+lima.message.error.empty.line=Veuillez choisir un compte
+lima.model.account=Compte
+lima.model.balance=Balance
+lima.model.credit=Cr\u00E9dit
+lima.model.date=Date
+lima.model.debit=D\u00E9bit
+lima.model.description=Description
+lima.model.etat=Etat
+lima.model.journal=Journal
+lima.model.lettering=Lettrage
+lima.model.name=Nom
+lima.model.period=P\u00E9riode
+lima.model.prefix=Pr\u00E9fixe
+lima.model.status=Statut
+lima.model.voucher=Document
+lima.name=Nom
+lima.non.valids.transactions=Ecritures non valides
+lima.not.lettered=Non lettr\u00E9
+lima.number=Num\u00E9ro
+lima.ok=OK
+lima.passif=Passif
+lima.period=P\u00E9riode
+lima.period.close=Ferm\u00E9
+lima.period.open=Ouvert
+lima.preferences=Pr\u00E9f\u00E9rences
+lima.prefix=Prefixe
+lima.print=Imprimer
+lima.produit=Produit
+lima.progressBar.export.etape1=Cr\u00E9ation base du fichier
+lima.progressBar.export.etape2=Cr\u00E9ation informations
+lima.progressBar.export.etape3=Cr\u00E9ation des p\u00E9riodes
+lima.progressBar.export.etape4=Cr\u00E9ation des journaux
+lima.progressBar.export.etape5=Cr\u00E9ation des comptes
+lima.progressBar.export.etape6=Cr\u00E9ation des transactions
+lima.progressBar.export.etape7=Enregistrement du fichier
+lima.progressBar.export.title=Sauvegarde
+lima.progressBar.load.etape1=Chargement des journaux
+lima.progressBar.load.etape2=Chargement des comptes
+lima.progressBar.load.etape3=Chargement des status
+lima.progressBar.load.etape4=Chargement des p\u00E9riodes
+lima.progressBar.load.etape5=Chargement des transactions
+lima.question=Question
+lima.question.load.accounts=Il n'y a aucun plan comptable existant dans Lima. Voulez-vous en charger un par d\u00E9faut ?
+lima.question.remove.account=Voulez-vous supprimer ce compte?
+lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
+lima.question.remove.journal=Voulez-vous supprimer ce journal?
+lima.question.remove.transaction=Voulez-vous supprimer cette transaction?
+lima.quit=Quitter
+lima.remove=Supprimer
+lima.remove.lettering=Supprimer la lettre
+lima.remove.transaction=Supprimer une transaction
+lima.reports=Rapports
+lima.response.no=Non
+lima.response.yes=Oui
+lima.result=Compte de r\u00E9sultat
+lima.result.charge=CHARGES
+lima.result.loss=Perte
+lima.result.produit=PRODUITS
+lima.result.profit=B\u00E9n\u00E9fice
+lima.result.total.charge=TOTAL CHARGES
+lima.result.total.produit=TOTAL PRODUITS
+lima.search=Rechercher
+lima.search.items.where=Trouver les \u00E9critures o\u00F9
+lima.search.title.criteria.box=Crit\u00E8res
+lima.since=Depuis
+lima.status.tr.balanced=Equilibr\u00E9e
+lima.status.tr.finalized=Valid\u00E9e
+lima.status.tr.wip=En cours
+lima.success=Succ\u00E8s
+lima.tab.account=Compte
+lima.tab.balance=Balance
+lima.tab.bilan=Bilan
+lima.tab.closure=Cl\u00F4ture
+lima.tab.home=Accueil
+lima.tab.journal=Journal
+lima.tab.lettering=Lettrage
+lima.tab.reports=Rapports
+lima.tab.result=Compte de r\u00E9sultat
+lima.tab.search.result=Recherche
+lima.tab.transaction=Ecriture
+lima.title=Lutin Invoice Monitoring and Accounting
+lima.title.about=A propos de Lima...
+lima.to=A
+lima.ui.add.account=Ajouter un compte
+lima.ui.add.journal=Ajouter un journal
+lima.ui.block.timespan=Bloquer une p\u00E9riode mensuelle
+lima.ui.unblock.timespan=D\u00E9bloquer une p\u00E9riode mensuelle
+lima.ui.update.account=Mettre \u00E0 jour le compte
+lima.ui.update.journal=Mettre \u00E0 jour le journal
+lima.unblock=D\u00E9bloquer
+lima.update=Mettre \u00E0 jour
+lima.view=Vue
+lima.view.flatten=Vue aplatie
+lima.voucher=Document
+lima.warning.nimbus.landf=Le look and feel nymbus n'a pas \u00E9t\u00E9 trouv\u00E9
+lima.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9.
Copied: trunk/lima-swing/src/main/resources/lima.properties (from rev 2790, trunk/lima-main/src/main/filters/lima.properties)
===================================================================
--- trunk/lima-swing/src/main/resources/lima.properties (rev 0)
+++ trunk/lima-swing/src/main/resources/lima.properties 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,11 @@
+application.name=${project.name}
+application.version=${project.version}
+
+# le lien suivant pointe sur le module qui n'a pas de site associ�
+#application.site.url=${project.url}
+application.site.url=http://maven-site.chorem.org/lima/
+
+#licence.name=${project.licenses[0].license.name}
+#licence.url=${project.licenses.0.url}
+application.organisation.name=${project.organization.name}
+application.organisation.url=${project.organization.url}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-12 20:15:47 UTC (rev 2801)
+++ trunk/pom.xml 2010-03-16 15:41:26 UTC (rev 2802)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -15,40 +15,51 @@
<groupId>org.chorem</groupId>
<artifactId>lima</artifactId>
- <version>0.3.2-SNAPSHOT</version>
+ <version>0.4.0-SNAPSHOT</version>
<modules>
- <module>lima-dto</module>
- <module>lima-service</module>
- <module>lima-service-mock</module>
- <module>lima-service-neogia</module>
- <module>lima-service-callao</module>
- <module>lima-main</module>
+ <module>lima-callao</module>
+ <module>lima-business</module>
+ <module>lima-swing</module>
</modules>
<dependencyManagement>
<dependencies>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <scope>compile</scope>
+ </dependency>
<dependency>
- <groupId>org.chorem.callao</groupId>
- <artifactId>callao-service</artifactId>
- <version>${callao.version}</version>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.11</version>
+ <scope>runtime</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.11</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.3</version>
- <scope>compile</scope>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.5</version>
<scope>compile</scope>
</dependency>
-
+
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
@@ -59,7 +70,7 @@
<groupId>org.nuiton.eugene</groupId>
<artifactId>eugene</artifactId>
<version>${eugene.version}</version>
- <scope>compile</scope>
+ <scope>runtime</scope>
</dependency>
<!-- librairie Jaxx -->
@@ -69,6 +80,7 @@
<version>${jaxx.version}</version>
<scope>compile</scope>
</dependency>
+
<dependency>
<groupId>org.nuiton.jaxx</groupId>
<artifactId>jaxx-widgets</artifactId>
@@ -83,8 +95,14 @@
<version>${topia.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.2.131</version>
+ <scope>runtime</scope>
+ </dependency>
- <!-- librairie axis 2 -->
+ <!-- librairie axis 2
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
@@ -94,40 +112,50 @@
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-xmlbeans</artifactId>
<version>${axis.version}</version>
- </dependency>
+ </dependency>-->
<!-- autres libraires -->
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swingx</artifactId>
- <version>${swingx.version}</version>
+ <version>1.6</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
+ <scope>compile</scope>
</dependency>
<dependency>
- <groupId>jdom</groupId>
+ <groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
- <version>1.0</version>
+ <version>1.1</version>
<scope>compile</scope>
</dependency>
-
- <!--dependency>
- <groupId>com.sun</groupId>
- <artifactId>jlfgr</artifactId>
- <version>1.0</version>
- </dependency-->
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
- <version>1.8</version>
+ <version>2.1</version>
+ <scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>javax.time</groupId>
+ <artifactId>jsr-310-ri</artifactId>
+ <version>20100212</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</dependencyManagement>
@@ -152,7 +180,19 @@
<!-- Developpers, contributors... -->
<developers>
<developer>
- <id>remi</id>
+ <id>echatellier</id>
+ <name>Chatellier Eric</name>
+ <email>chatellier(a)codelutin.com</email>
+ <organization>Code Lutin</organization>
+ <organizationUrl>http://www.codelutin.com</organizationUrl>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ </developers>
+ <contributors>
+ <contributor>
<name>Rémi Chapelet</name>
<email>chapelet(a)codelutin.com</email>
<organization>Code Lutin</organization>
@@ -161,9 +201,8 @@
<roles>
<role>Développeur</role>
</roles>
- </developer>
- <developer>
- <id>eduardo</id>
+ </contributor>
+ <contributor>
<name>eduardo</name>
<email>ore(a)codelutin.com</email>
<organization>Code Lutin</organization>
@@ -172,8 +211,8 @@
<roles>
<role>Développeur</role>
</roles>
- </developer>
- </developers>
+ </contributor>
+ </contributors>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
@@ -185,23 +224,15 @@
<projectId>lima</projectId>
<!-- customized libs version -->
- <callao.version>0.1.3-SNAPSHOT</callao.version>
<nuiton-utils.version>1.2</nuiton-utils.version>
-
- <eugene.version>1.0.0</eugene.version>
- <topia.version>2.2.0</topia.version>
-
- <!-- config for eugene 2.0.0 -->
- <!--<eugene.version>2.0.0-beta-2-SNAPSHOT</eugene.version>-->
- <!--<topia.version>2.3.0-beta-2-SNAPSHOT</topia.version>-->
-
- <jaxx.version>2.0.0-beta-1</jaxx.version>
+ <eugene.version>2.0</eugene.version>
+ <topia.version>2.3</topia.version>
+ <jaxx.version>2.0</jaxx.version>
<i18n.version>1.1</i18n.version>
<!--axis.version>1.4.1</axis.version-->
- <!-- 1.4 and 1.4.1 breaks jnlp with corrupt jar -->
- <axis.version>1.3</axis.version>
- <swingx.version>1.6</swingx.version>
+ <!-- 1.4 and 1.4.1 breaks jnlp with corrupt jar
+ <axis.version>1.3</axis.version>-->
<!-- license to use -->
<license.licenseName>gpl_v3</license.licenseName>
@@ -252,7 +283,6 @@
<!-- ************************************************************* -->
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
-
<scm>
<connection>scm:svn:http://svn.chorem.org/svn/lima/trunk</connection>
<developerConnection>scm:svn:http://svn.chorem.org/svn/lima/trunk</developerConnection>
@@ -260,9 +290,7 @@
</scm>
<repositories>
-
<!-- depot des releases nuiton -->
-
<repository>
<id>nuiton.release</id>
<name>NuitonReleaseRepository</name>
@@ -275,10 +303,7 @@
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
-
-
<!-- depot des snapshots nuiton -->
-
<repository>
<id>nuiton.snapshot</id>
<name>NuitonSnapshotRepository</name>
@@ -291,15 +316,16 @@
<enabled>false</enabled>
</releases>
</repository>
-
+ <!-- jboss -->
+ <repository>
+ <id>jboss.repo</id>
+ <url>http://repository.jboss.org/maven2</url>
+ </repository>
</repositories>
<pluginRepositories>
-
<!-- depot des releases nuiton -->
-
<pluginRepository>
-
<id>nuiton.release</id>
<name>NuitonReleaseRepository</name>
<url>http://maven.nuiton.org/release</url>
@@ -311,9 +337,7 @@
<checksumPolicy>warn</checksumPolicy>
</releases>
</pluginRepository>
-
<!-- depot des snapshots nuiton -->
-
<pluginRepository>
<id>nuiton.snapshot</id>
<name>NuitonSnapshotRepository</name>
@@ -326,7 +350,5 @@
<enabled>false</enabled>
</releases>
</pluginRepository>
-
</pluginRepositories>
-
</project>
Copied: trunk/src/site/resources/images/codelutin.png (from rev 2790, trunk/src/site/resources/logo/codelutin.png)
===================================================================
(Binary files differ)
Added: trunk/src/site/rst/devel/modificationarchitecture.rst
===================================================================
--- trunk/src/site/rst/devel/modificationarchitecture.rst (rev 0)
+++ trunk/src/site/rst/devel/modificationarchitecture.rst 2010-03-16 15:41:26 UTC (rev 2802)
@@ -0,0 +1,65 @@
+Modification de l'architecture de LIMA/CALLAO
+=============================================
+
+Voici le résumé de la modification de l'architecture de LIMA/CALLAO.
+
+Points majeurs :
+ - Intégration de callao dans lima en tant que moteur par défaut
+ - Conservation de la possibilité de changer de moteur ou d'interface
+ - Suppression des DTO (utilisation des interfaces des entités metier
+générées)
+
+
+Nouvelle architecture
+---------------------
+
+Trois couches (voir schéma) :
+ - UI
+ - Métier (indépendant de ToPIA)
+ - Persistance (généré sur ToPIA)
+
+UI
+~~
+Dans un premier temps, une interface de type Swing.
+Mais une autre interface pourra être utilisé par la suite.
+
+Pas de DTO manipulé dans l'UI, utilisation des interfaces des beans métier
+(sans utiliser de spécificités de TopiaEntity).
+
+L'interface graphique contiendrait les fonctionnalités suivantes :
+ - import/export des données
+
+Métier
+~~~~~~
+Se manipule via les interfaces des DAO.
+L'implémentation des DAO étant sur ToPIA.
+
+Problèmes lié au transaction. L'utilisation du TopiaContext n'est
+pas envisageable et rendrait trop dépendant de Topia.
+
+Solution 1 : JTA
+ Utilisation de JTA et enregistrement de Topia comme
+ transaction JTA. Permet de faire des vrai transaction sans utilisation
+ directe du topia contexte.
+
+Solution 2 : EJB
+ Implémentation via les EJB qui permet en plus
+ des fournir directement des webservices.
+ Utilisation d'OpenEJB pour pouvoir tourner en mode embarqué (sans
+ serveur d'application)
+
+Pas d'intrusion des spécificités EJB sur les DAO. Utilisation d'un
+code annexe pour wrapper sur les DAO.
+
+Le métier contiendrait également les fonctionnalités métier suivantes:
+ - les règles métier / cohérence de comptabilité (???)
+ - génération des bilan
+ - génération des impressions
+
+Persistance
+~~~~~~~~~~~
+Pour callao : génération entièrement sur ToPIA.
+
+Pour ofbiz, SAP : nouvelle implémentation sur les interfaces des DAO.
+Les modules pour ofbiz (etc...) dépendront donc de la persistance
+générées.
1
0