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
Author: echatellier
Date: 2010-03-31 16:21:37 +0200 (Wed, 31 Mar 2010)
New Revision: 2821
Log:
Suppression des doubles visibilit?\195?\169s
Modified:
trunk/lima-callao/src/main/xmi/accounting.zargo
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
1
0
r2820 - trunk/lima-business/src/main/java/org/chorem/lima/business
by echatellier@users.chorem.org 30 Mar '10
by echatellier@users.chorem.org 30 Mar '10
30 Mar '10
Author: echatellier
Date: 2010-03-30 18:20:40 +0200 (Tue, 30 Mar 2010)
New Revision: 2820
Log:
Balance, Bilan beans are now generated
Removed:
trunk/lima-business/src/main/java/org/chorem/lima/business/data/
1
0
r2819 - in trunk/src/site: resources resources/callao resources/callao/class resources/callao/uc rst rst/callao
by echatellier@users.chorem.org 30 Mar '10
by echatellier@users.chorem.org 30 Mar '10
30 Mar '10
Author: echatellier
Date: 2010-03-30 16:15:15 +0200 (Tue, 30 Mar 2010)
New Revision: 2819
Log:
Add old site documentation from callao.
Added:
trunk/src/site/resources/callao/
trunk/src/site/resources/callao/class/
trunk/src/site/resources/callao/class/class-diag.png
trunk/src/site/resources/callao/uc/
trunk/src/site/resources/callao/uc/uc-base.png
trunk/src/site/resources/callao/uc/uc-cloture.png
trunk/src/site/resources/callao/uc/uc-comptes.png
trunk/src/site/resources/callao/uc/uc-etats.png
trunk/src/site/resources/callao/uc/uc-exercice.png
trunk/src/site/resources/callao/uc/uc-fichiers.png
trunk/src/site/resources/callao/uc/uc-journal.png
trunk/src/site/rst/callao/
trunk/src/site/rst/callao/callao.rst
trunk/src/site/rst/callao/classes.rst
trunk/src/site/rst/callao/contact.rst
trunk/src/site/rst/callao/developpement.rst
trunk/src/site/rst/callao/howto.rst
trunk/src/site/rst/callao/index.rst
trunk/src/site/rst/callao/lexique.rst
trunk/src/site/rst/callao/news.rst
trunk/src/site/rst/callao/roadmap.rst
trunk/src/site/rst/callao/todo.rst
trunk/src/site/rst/callao/usecases.rst
Added: trunk/src/site/resources/callao/class/class-diag.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/callao/class/class-diag.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/resources/callao/uc/uc-base.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/callao/uc/uc-base.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/resources/callao/uc/uc-cloture.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/callao/uc/uc-cloture.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/resources/callao/uc/uc-comptes.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/callao/uc/uc-comptes.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/resources/callao/uc/uc-etats.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/callao/uc/uc-etats.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/resources/callao/uc/uc-exercice.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/callao/uc/uc-exercice.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/resources/callao/uc/uc-fichiers.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/callao/uc/uc-fichiers.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/resources/callao/uc/uc-journal.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/callao/uc/uc-journal.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/rst/callao/callao.rst
===================================================================
--- trunk/src/site/rst/callao/callao.rst (rev 0)
+++ trunk/src/site/rst/callao/callao.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,68 @@
+======================
+Présentation de CALLAO
+======================
+(Computing Active Layer for Lutin's Accounting Organization)
+
+``1. Présentation``
+-------------------
+
+La comptabilité est une tâche longue, répétitive, et induisant un nombre
+important de contrôles et de calculs.
+
+C'est un excellent exemple de ce que l'automatisation grâce à l'informatique
+peut apporter en terme de gain de temps. Longtemps réservée aux grosses
+entreprises, l'explosion de l'informatique personnelle (puis portable) à
+largement démocratisé la comptabilité par informatique mais toujours par le biais
+de solutions malheureusement propriétaires et/ou peu portables.
+
+L'essor récent du logiciel libre permet l'émergence de solutions encore plus
+accessibles, débarrassées des traditionnels verrous emprisonnant l'information
+comptable, et donc son propriétaire, dans un contexte étriqué d'utilisation.
+Ces logiciels nécessitant l'achat de licences spécifiques en cas d'emplois sur
+plusieurs postes, et interdisant le partage ou la migration entre applications
+"concurrentes".
+
+``2. Naissance``
+----------------
+
+Issu du projet Chorem_,
+CALLAO_ est un moteur de comptabilité `libre de droits`_ respectant les conventions
+ainsi que les normes comptables imposées aux entreprises par la législation
+française.
+
+Bien que créé pour fonctionner avec l'interface graphique LIMA_, CALLAO_ a été
+conçu pour pouvoir être utilisé par différentes interfaces graphiques. Il est
+donc possible de créer une interface Web de comptabilité reposant sur le moteur
+CALLAO_
+
+``3. Architecture``
+-------------------
+
+Les utilisateurs de l'interface utilisateur LIMA_ effectuaient jusqu'alors cette gestion
+des données gràce au moteur de comptabilité d'OFBiz-Neogia. CALLAO_ doit pouvoir se
+substituer à ce moteur mais sans nécessité une refonte de LIMA_ afin de laisser aux
+utilisateurs de ce dernier le choix du moteur de comptabilité qu'ils
+utilisent ou de faciliter les migrations d'un moteur à l'autre [#]_.
+
+Ainsi notre couche de DTO se substituera à toute la partie exterieure à
+l'interface de LIMA_ comme suit :
+
+.. image:: resources/schemas/schema-architecture.png
+
+
+
+On peut voir que le DTO utilise le modèle définit par le design pattern du même
+nom pour décrire le moteur CALLAO de l’application comptable finale.
+L’architecture est elle même composée de deux couches : une de persistance pour
+la gestion des données, et une autre métier pour la gestion des flux entre la
+persistance et les interfaces d’entrées/sorties véhiculées par des objets
+JavaBeans.
+
+
+----
+
+.. _`libre de droits`: licence.html
+.. [#] A cet effet des fonctions d'import et d'export seront mises en place.
+.. _ChoreM: http://chorem.org/
+.. _LIMA: http://maven-site.chorem.org/lima/
+.. _CALLAO: callao.html
Added: trunk/src/site/rst/callao/classes.rst
===================================================================
--- trunk/src/site/rst/callao/classes.rst (rev 0)
+++ trunk/src/site/rst/callao/classes.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,364 @@
+====================
+Diagramme de classes
+====================
+
+.. image:: class/class-diag.png
+
+``Entry``
+=========
+``Description :``
+-----------------
+Une Entry est une écriture comptable, qui traduit le passage d'une somme au débit
+ou au crédit d'un compte.
+
+``Attributs :``
+---------------
+
+- description : Description textuelle de l'opération.
+
+- amount : Montant de l'opération, stocké sous forme de string.
+
+- debit : Booléen indiquant s'il s'agit d'une opération de type débit ou crédit.
+
+- lettering : Chaîne de caractères employée pour le lettrage
+
+- detail : Chaîne de caractères servant au stockage d'informations caractérisant
+l'écriture en question au format CSV.
+
+- Transaction : Une Entry fait forcément partie d'une Transaction (soit d'une
+Transaction existante, soit une nouvelle Transaction est créée lors de la
+création
+
+
+``Liens :``
+-----------
+
+- Log : Toute opération sur une Entry sera consignée dans un objet Log(RM).
+
+- Account : Une Entry est une opération de débit ou de crédit sur un compte donné.
+Chacune d'elle concerne donc un et un seul compte.
+
+
+
+``Transaction``
+===============
+``Description :``
+-----------------
+Une Transaction représente une opération comptable, soit un ensemble d'écritures
+(Entry). Une Transaction n'est dite équilibrée que si la somme des montants des
+écritures de débit qui la composent est égale à celle des écritures de crédit(RM).
+Elle fera souvent référence à un document justificatif (par exemple une facture)
+qu'elle représentera comptablement. Elle est passée à une date donnée qui concerne
+par extension toutes les écritures qu'elle contient.
+
+``Attributs :``
+---------------
+
+- entryDate : La date d'entrée de l'opération (saisie par l'utilisateur).
+
+- voucherRef : Si utile, référence du document justificatif.
+
+- description : Description textuelle.
+
+
+``Liens :``
+-----------
+
+- Entry : Une Transaction est une composition d'un certain nombre d'écritures
+(Entry).
+
+- TimeSpan : Une transaction intervient pendant un intervalle de temps. La clôture
+de cet intervalle de temps (TimeSpan) implique que la Transaction n'est pas
+modifiable (règles métier de l'application(RM)).
+
+- Journal : Une Transaction appartient à un journal donné, selon là où elle a
+été entrée par l'utilisateur.
+
+
+
+``TimeSpan``
+============
+``Description :``
+-----------------
+Un TimeSpan, ou intervalle de temps, représente une subdivision de l'exercice
+comptable (Period) en plusieurs périodes plus petites afin de pouvoir clôturer
+son travail au fur et à mesure. La loi impose juste que les exercices soient
+clôturés de manière définitive, donc les clôtures de TimeSpan seront
+réversibles(RM). Un intervalle de temps ne pourra être verrouillé que si les
+précédents intervalles sont également verrouillés(RM). L'idée de cette
+fonctionnalité nous a été soumise par notre professeur de comptabilité. Nous
+avions commencé par concevoir des intervalles de temps de durée quelconque mis
+en place par l'utilisateur avant de s'orienter vers des TimeSpan d'une durée
+d'un mois, également sur ses conseils. Les différents TimeSpan (autant que de
+mois pour l'exercice) seront générés lors de la création de l'exercice(RM).
+
+``Attributs :``
+---------------
+
+- beginTimeSpan : Date de début de l'intervalle de temps.
+
+- endTimeSpan : Date de fin de l'intervalle de temps.
+
+- locked : Booléen indiquant si l'IT est clôturé ou non.
+
+
+``Liens :``
+-----------
+
+- Period : Un intervalle de temps appartient à un exercice (Period donné). En
+fait, il constitue un mois de cet exercice. Les dates de début et de fin de l'IT
+sont donc évidemment comprises dans celles de l'exercice auquel il appartient.
+
+- Transaction : Un ensemble de transactions est effectué pendant un intervalle
+de temps donné, déterminé par la date de transaction. Un intervalle de temps ne
+peut être clôturé que si toutes ses transactions sont équilibrées(RM).
+
+
+
+``Period``
+==========
+``Description :``
+-----------------
+Il s'agit d'un exercice comptable. Ses dates seront définies par l'utilisateur
+dans la limite de certaines règles métier qui permettront de respecter le cadre
+légal : un exercice commence là où le précédent se finit; la durée de l'exercice
+est fixée à l'avance et ne peut être modifiée; la clôture d'un exercice est
+définitive(RM). Il ne peut y avoir plus de deux exercices ouverts en même temps(RM)
+et aucun exercice ne peut être clôturé sans que le précédent ait été clôturé(RM).
+Lors de la clôture d'un exercice, une opération de report à nouveau est effectuée
+sur l'exercice suivant(RM). De fait, il est impossible de clôturer un exercice
+sans avoir préalablement créé le suivant(RM).
+
+``Attributs :``
+---------------
+
+- beginTimeSpan : Date de début de l'exercice.
+
+- endTimeSpan : Date de fin de l'exercice.
+
+- locked : Booléen indiquant si l'exercice est clôturé ou non.
+
+
+``Liens :``
+-----------
+
+- TimeSpan : Un exercice contient, selon sa longueur, un certain nombre
+d'intervalles de temps qui correspondent à ses différents mois. Les différents
+TimeSpan sont créés en même temps que l'exercice(RM). La clôture de l'exercice
+implique automatiquement la clôture de tous ses TimeSpan(RM).
+
+
+
+``Journal``
+===========
+``Description :``
+-----------------
+Le logiciel supporte la « comptabilité multi-journal », c'est-à-dire que
+l'utilisateur peut saisir ses opérations dans plusieurs journaux différents
+(Journal des ventes, journal des achats...).
+
+``Attributs :``
+---------------
+
+- label : Libellé du journal.
+
+- prefix : Prefix du journal, utilisé par l'interface.
+
+
+``Liens :``
+-----------
+
+- Transaction : Un journal est composé de transactions, mais peut être vide.
+
+
+
+``Log``
+=======
+``Description :``
+-----------------
+Chaque ajout/modification/suppression sur une Entry entraine la création d'un
+log contenant toutes les nouvelles informations de celui-ci (qui seront vides
+s'il s'agit d'une suppression(RM)). La modification d'une Transaction entraine
+aussi la création d'un log pour chacune de ses Entry(RM). Dans la mesure où les
+logs devraient pouvoir être consultés sans impliquer de traitement, on y réunira
+les informations consultant les Entry et les Transaction.
+
+``Attributs :``
+---------------
+
+- logDate : Date où le log est créé (déterminée à partir de l'horloge système)
+
+- type : Type de modification. Peut prendre 4 valeurs différentes : add (ajout),
+mod (modification), del (suppression), tmod (modification de transaction).
+
+- transDate : Date de la Transaction.
+
+- voucherRef : Référence du justificatif de la Transaction.
+
+- transDesc : Description de la Transaction.
+
+- entryDesc : Description de l'Entry.
+
+- amount : Montant de l'Entry.
+
+- debit : Booléen indiquant s'il s'agit d'une écriture de débit ou de crédit.
+
+- lettering : Letterage de l'Entry.
+
+
+``Liens :``
+-----------
+
+- Entry : Le log correspond à une Entry qui, elle, peut avoir plusieurs logs (au
+moins un et autant qu'elle a subi de modifications).
+
+
+
+``Account``
+===========
+``Description :``
+-----------------
+Correspond à un compte du PCG. Les sous-comptes (e.g. 4111) sont considérés
+comme étant agrégés dans leur « compte père » (e.g. 411). Un compte ne peut être
+supprimé s'il contient des écritures(RM).
+
+``Attributs :``
+---------------
+
+- label : Libellé du compte.
+
+- accountNumber : Numéro de compte.
+
+- Entry : Les Entry représentent les différentes opérations effectuées sur les
+comptes. Plusieurs écritures peuvent être passées concernant un compte donné,
+mais celui-ci peut exister sans écriture.
+
+
+``Liens :``
+-----------
+
+- Account : Un compte peut contenir des sous-comptes.
+
+
+``CallaoUser``
+==============
+``Description :``
+-----------------
+Bien que l'interface prévoit une phase d'authentification à son lancement, il
+n'est pour l'instant pas prévu d'implémenter une gestion multi-utilisateurs de
+Callao. Nous ajoutons néanmoins cette classe afin de pouvoir prévoir cette
+gestion dans une implémentation future.
+
+``Attributs :``
+---------------
+
+- userID : ID de l'utilisateur.
+
+- login : Login de l'utilisateur.
+
+- password : Mot de passe de l'utilisateur
+
+- right : Code le groupe de droits auquel l'utilisateur a accès
+
+
+
+``User``
+========
+``Description :``
+-----------------
+Cette classe va permettre de typer des écritures vis à vis des utilisateurs
+relatifs qu'elle touche. Ceci permettre d'effectuer des tris d'écriture afin
+d'extraire le coût ou produit généré par des individus.
+Cette démarche s'inscrit dans l'optique d'une synchronisation des données entre
+Chorem et Callao.
+
+``Attributs :``
+---------------
+
+- matcher : Le nom d'utilisateur
+
+
+
+``Type Presta``
+===============
+``Description :``
+-----------------
+Correspond aux propriétés d'une écriture. Permet de définir et classifier les
+écritures grâce aux catégories pertinentes afin de mieux analyser les résultats
+des différentes activités de l'entreprise.
+
+``Attributs :``
+---------------
+
+- matcher : Description du type de prestation associée à une écriture
+
+
+
+``Client``
+==========
+``Description :``
+-----------------
+Les catégories de clients sont des informations venant éventuellement se greffer
+sur des comptes afin de mieux renseigner les informations sur ces derniers, de
+pouvoir éventuellement les regrouper et déduire des généralisations par catégories
+de client, anticiper des durées de stockages de créances pour un client lambda
+fonction de sa catégorie.
+Ces catégories seront cependant le plus souvent associées aux comptes descendants
+du compte 411 (client) et assez rarement (voir pas du tout) d'autres comptes
+sauf exceptions sur les comptes 416 ou autres cas exceptionnels.
+Ce système reste évolutif et permet à un comptable d'associer des catégorie à
+n'importe quel compte dans la mesure où il le jugerait utile.
+
+``Attributs :``
+---------------
+
+- matcher : Le nom de la catégorie du client.
+
+
+
+``Project``
+===========
+``Description :``
+-----------------
+Les projets sont un moyen de regrouper des écritures afin de réaliser des
+recherches et des calculs de coûts associés à un projet précis. Ainsi un
+comptable pourra réaliser une compta-analytique et connaître la rentabilité de
+ses différents contrats.
+A long terme ces informations relatives à un projet proviendront de Chorem ou
+d'autre solutions purement de gestion de projet, ces informations seront importé
+afin d'en faciliter l'analyse comptable.
+
+``Attributs :``
+---------------
+
+- matcher : Le nom du projet.
+
+- uri : Une adresse vers laquelle sur laquelle pointera le projet Chorem relatif
+à l'écriture ciblée.
+
+
+
+``Tax``
+=======
+``Description :``
+-----------------
+Permettra d'assigner un type d'impot à une écriture comptable (TVA, IS, Banque,
+etc.).
+
+``Attributs :``
+---------------
+
+- matcher : Un type de taxe.
+
+
+
+``Particularité des classes : User, TypePresta, Client, Project et Tax``
+========================================================================
+``Explication :``
+-----------------
+Ces classes s'inscrivent dans une démarche de synchronisation des données entre
+Callao et Chorem dans l'objectif de pouvoir catégoriser des données en fonctions
+de ces cinq critères, fournis par Chorem.
+Ces données seront en fait stockées dans l'attribut detail d'une instance d'Entry
+afin dans une structure de données formatée CSV.
+Par exemple : "user:dupont;user:martin;typePresta:dev;client:LM;projet:lima"
Added: trunk/src/site/rst/callao/contact.rst
===================================================================
--- trunk/src/site/rst/callao/contact.rst (rev 0)
+++ trunk/src/site/rst/callao/contact.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,75 @@
+============
+Contact list
+============
+
+Pour contacter les membres du projet ou suivre son évolution, vous pouvez
+utiliser les listes de diffusion du projet :
+
+- Liste utilisateurs : (..USERS_) Liste de discussions des utilisateurs de CALLAO_
+- Liste développeurs : (..DEVEL_) Liste de discussions des développeurs de CALLAO_
+- Liste des commits : (..COMMITS_) Liste des modifications du code de CALLAO_
+
+=======
+Support
+=======
+
+.. image:: logo/codelutin.png
+
+
+Code Lutin est une société de services en logiciels libres spécialisée dans les
+technologies Java/J2EE, XML, UML. Son offre s'étend à l'audit, au conseil, à la
+tierce maintenance applicative et à la formation.
+
+SARL Code Lutin
+44 boulevard des Pas Enchantés
+44230 Saint-Sébastien-Sur-Loire
+France
+
+Contact : Benjamin Poussin, gérant et chef de projet.
+
+Tél : 02 40 50 29 28
+
+
+Code Lutin participe activement au mouvement du logiciel libre et fait partie du
+consortium ObjectWeb, d'Alliance Libre et du réseau Libre-entreprise
+
+
+Plus_.
+
+.. _Plus: http://www.codelutin.com
+
+
+
+
+----------------
+Libre-entreprise
+----------------
+
+.. image:: http://www.csquad.org/stages/stage-tech3/img/libre-entreprise.jpeg
+
+Un regroupement de sociétés expertes en solutions libres
+
+Libre-entreprise est un réseau de sociétés de services en logiciel libre. Son
+développement est fondé sur celui de la communauté du libre : mutualisation des
+compétences et transparence.
+
+
+SiteLibreEntreprise_.
+
+.. _SiteLibreEntreprise: http://www.libre-entreprise.com/index.php/Accueil
+
+
+--------------
+Alliance Libre
+--------------
+
+.. image:: http://www.solago.com/images/logo_AL.png
+
+SiteAllianceLibre_.
+
+.. _SiteAllianceLibre: http://www.alliance-libre.org/
+
+.. _USERS: http://list.chorem.org/cgi-bin/mailman/listinfo/callao-users
+.. _DEVEL: http://list.chorem.org/cgi-bin/mailman/listinfo/callao-devel
+.. _COMMITS: http://list.chorem.org/cgi-bin/mailman/listinfo/callao-commits
+.. _CALLAO: http://maven-site.chorem.org/callao/
\ No newline at end of file
Added: trunk/src/site/rst/callao/developpement.rst
===================================================================
--- trunk/src/site/rst/callao/developpement.rst (rev 0)
+++ trunk/src/site/rst/callao/developpement.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,82 @@
+=============
+Développement
+=============
+
+Nous utiliserons cette section pour fournir des informations concernant
+l'avancement du développement du moteur Callao.
+
+
+-----------------------
+La génération via ToPIA
+-----------------------
+
+A l'heure actuelle, la génération de code concerne uniquement la couche de
+données via l'utilisation de ToPIA-persistence_ avec xmi pour la définition du
+modèle, H2 pour la base de données, Hibernate pour la couche d'accès aux données,
+et Java pour l'implémentation.
+La construction et la génération du code du projet s'effectue directement via
+Maven à l'aide de la commande de compilation :
+
+``mvn clean compile``
+
+L'ensemble des paramètres commandant cette génération sont définis dans les
+fichiers de configuration de Maven du super pom et du pom du module
+''callao-entity''. Le modèle quant à lui est stocké dans un fichier ''zargo'',
+toujours dans le module ''callao-entity'' et peut être consulté à l'aide
+d' ArgoUML_ .
+LIMA propose un certain nombre de services disponibles via des interfaces, le but
+initial de CALLAO et de pouvoir implémenter ces services de manière locale ou
+distante. L'utilisation de Web Services, comme mis en place pour effectuer la
+communication entre LIMA et OFBiz constitue la solution à cette problématique.
+
+
+
+Néanmoins, pour le moment, les implémentation s'effectuent uniquement de manière
+locale. CALLAO s'occupe uniquement d'implémenter les interfaces de LIMA situées
+dans le module ''lima-service'' de manière locale, et les échanges de Web Services
+n'ont pas encore été mis en place.
+
+
+
+Cependant, une configuration de la génération de cette couche de communication
+par services a tout de même été effectuée via l'utilisation de ToPIA-soa_ . A ce
+titre, un modèle des services est présent en parallèle du modèle entité dans le
+module ''callao-entity''. Ce modèle décrit l'ensemble des services fournissant
+l'application des règles métiers définies pour l'application CALLAO. Couplé à
+ToPIA-soa_ , il permet la génération de cette couche et de ses interfaces associées.
+Cependant une problèmatique de connection aux services de LIMA reste encore non
+résolue.
+
+
+
+De même que pour la partie entity, la génération de la couche service est
+commandée par Maven via la configuration du fichier pom du module
+''callao-service''.
+
+
+
+-------------------------------
+L'implémentation des interfaces
+-------------------------------
+
+Les implémentations des interfaces services de LIMA dans CALLAO représentent les
+fragments de code source de l'application qui vont définir les règles métiers.
+L'ensemble de ce code source se situent dans le module ''callao-service'' et
+s'occupe à l'heure actuelle d'implémenter uniquement localement les interfaces
+services de LIMA.
+
+
+
+L'état d'avancement actuel de ces implémentations est inachevé. En effet, il
+reste encore des améliorations à fournir à celles effectuées et à compléter
+celles des classes ''Period'' et ''Journal'' pour pouvoir au moins répondre aux
+interfaces services existantes de LIMA. De plus, notre modèle de services ne
+reflétant pas entièrement celui de LIMA, il est fort à penser que LIMA aura à
+intégrer de nouvelles fonctionnalités notamment au niveau de l'intégration à
+Chorem, de la gestion des Imports Exports de sauvegardes et de la génération des
+états comptables.
+
+
+.. _ToPIA-persistence: http://topia.labs.libre-entreprise.org/topia/topia-persistence/
+.. _ToPIA-soa: http://topia.labs.libre-entreprise.org/topia/topia-soa/
+.. _ArgoUML: http://argouml.tigris.org/
Added: trunk/src/site/rst/callao/howto.rst
===================================================================
--- trunk/src/site/rst/callao/howto.rst (rev 0)
+++ trunk/src/site/rst/callao/howto.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,6 @@
+
+============================
+Installer et démarrer Callao
+============================
+
+A venir
\ No newline at end of file
Added: trunk/src/site/rst/callao/index.rst
===================================================================
--- trunk/src/site/rst/callao/index.rst (rev 0)
+++ trunk/src/site/rst/callao/index.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,21 @@
+
+==================
+Callao
+==================
+
+Issu du projet Chorem_, et créé pour fonctionner en collaboration avec LIMA_,
+CALLAO_ est *un moteur de comptabilité générale* respectant les conventions
+ainsi que normes imposées par la législation française aux entreprises.
+
+Ce rôle était jusqu'à alors remplis via le moteur de comptabilité d'OfBiz-Neogia,
+CALLAO_ doit pouvoir se substituer à ce moteur mais sans refondre LIMA_ afin de
+laisser aux utilisateurs de LIMA_ le choix du moteur de comptabilité qu'ils
+utilisent ou de faciliter les migrations d'un moteur à l'autre [#]_.
+
+
+----
+
+.. [#] A cet effet des fonctions d'import et d'export seront mises en place.
+.. _ChoreM: http://chorem.labs.libre-entreprise.org
+.. _LIMA: http://maven-site.chorem.org/lima
+.. _CALLAO: http://maven-site.chorem.org/callao
Added: trunk/src/site/rst/callao/lexique.rst
===================================================================
--- trunk/src/site/rst/callao/lexique.rst (rev 0)
+++ trunk/src/site/rst/callao/lexique.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,127 @@
+==========================
+Lexique de la comptabilité
+==========================
+
+Nous définirons ici les quelques notions de comptabilité d'entreprise nécessaires
+à l'appréhension du fonctionnement de CALLAO.
+
+``Actif :``
+-----------
+L'actif d'une entreprise est l'ensemble de son patrimoine. Il comporte notamment
+la trésorerie, les immobilisations et les créances (sommes dues par des tiers).
+
+``Bilan :``
+-----------
+Le bilan est un état comptable, obligatoirement publié à l'issue de l'exercice
+et déduit du Grand Livre. Il présente l'état des actifs (patrimoines, ou emplois
+des ressources) et passifs (ressources, sous diverses formes de dettes) de
+l'entreprise à une date donnée : la date de clôture de l'exercice.
+On peut également établir un bilan provisoire avant la fin de l'exercice.
+
+``Compte :``
+------------
+Un compte est la plus petite unité retenue pour le classement des flux de valeur.
+Il sera débité ou crédité pour symboliser certaines opérations. Il existe par
+exemple des comptes de charges (Impôts sur les sociétés, Achats, Variations de
+stocks...) qui sont débités lors de l'enregistrement d'une charge, des comptes
+d'actifs (Immobilisations...), qui sont débités lors de l'enregistrement d'une
+acquisition d'actif, etc.
+La liste des comptes est données, en France, par le Plan Comptable Général. Ce
+dernier définit, pour chaque compte, un numéro d'identifiant normalisé permettant
+de l'identifier. On distingue 4 grands types de comptes : d'actif, de passif, de
+charge et de produit. L'augmentation d'un compte de charge ou d'actif se traduit
+par un débit du compte concerné (et sa diminution par un crédit). De même,
+l'augmentation d'un compte de produit ou de passif se traduit par un crédit du
+compte concerné (débit pour la diminution).
+Ces comptes sont généralement représentés par deux colonnes (débit et crédit),
+dans lesquelles sont consignées par ordre chronologique descendant les sommes
+passées respectivement au débit et au crédit du compte. Cela leur donne une
+forme de T, ce qui a donné naissance à l'appellation de compte en T.
+
+``Compte de résultat :``
+------------------------
+Le compte de résultat est un état comptable, obligatoirement publié à l'issue de
+l'exercice et déduit du Grand Livre. Il oppose la liste des différentes charges
+(pertes d'argent ou de valeur, que ce soit par consommation, par paiement de
+taxes ou de salaires, par donations, par dépréciation d'actif...) à celle des
+différents produits (gains d'argent, généralement par vente de produits finis ou
+de marchandises).
+Il met également en avant la différence entre les deux, qui représente le
+résultat de l'entreprise pour l'exercice. Celui-ci peut être positif ou négatif,
+suivant que la somme des produits dépasse celle des charges ou non. S'il est
+positif, on parle alors de bénéfice qui pourra être redistribué aux actionnaires
+(propriétaires) ou conservé pour financer l'activité.
+
+``Ecriture :``
+--------------
+Une écriture comptable représente tout simplement le débit ou le crédit d'un
+compte. Elles sont passées par compte dans le Grand Livre, et rassemblées par
+opérations dans le Journal.
+
+``Etats comptables :``
+----------------------
+Les états comptables sont des documents de synthèse déduits du Journal et du
+Grand Livre et dont la publication est également obligatoire à la fin de
+l'exercice. Ils fournissent des indications sur la santé de l'entreprise. Les
+états sont, en France, le bilan, le compte de résultat et l'annexe.
+
+``Exercice :``
+--------------
+Un exercice est une période, généralement de un an, pour laquelle l'entreprise
+établit sa comptabilité. A l'issu de l'exercice, l'entreprise doit publier sa
+comptabilité concernant cette période. Une fois cette publication effectuée,
+aucun retour en arrière ne peut être effectué. C'est pourquoi on considère qu'un
+exercice, une fois fini, doit être clôturé, ce qui interdit alors toutes
+modifications sur les informations comptables concernant cet exercice.
+
+``Grand Livre :``
+-----------------
+Historiquement, le Grand Livre est le cahier où sont consignés tous les comptes
+en T de l'entreprises (tableaux de deux colonnes, débit et crédit, consignant
+les diverses écritures passées sur le compte), à raison d'un par page.
+
+``Journal :``
+-------------
+Historiquement, le journal est le cahier où l'entreprise consigne par ordre
+chronologique la trace de ses opérations comptables (transactions). Parfois,
+celle-ci utilise plusieurs journaux (journal des achats, journal des stocks,
+journal des ventes...) afin de séparer les différents types d'opération et de
+mieux s'y retrouver, ou de diviser la responsabilité de la consignation des
+transactions entre différentes personnes, chacune responsable d'un domaine
+précis (achat, vente, stock...). On parle alors de comptabilité multi-journaux.
+
+``Passif :``
+------------
+Le passif d'une entreprise est l'ensemble des ressources de l'entreprise, sous
+la forme de capitaux et de dettes.
+
+``Report à nouveau :``
+----------------------
+Historiquement, lors de la clôture d'un exercice comptable, on changeait de
+cahiers (Journal et Grand Live) pour attaquer la consignation des opérations du
+nouvel exercice. On soldait alors tous les comptes du Grand Livre en débitant
+les comptes créditeurs et en créditant les comptes débiteurs de la valeur du
+solde (différence entre débit et crédit) du compte. On effectuait alors
+l'opération inverse en première opération du nouvel exercice. On appelle cette
+opération un report à nouveau.
+Dans notre cas, comme dans tous les logiciels de comptabilité, le report à
+nouveau ne sera que partiellement effectué. Si CALLAO reportera bien le solde
+des différents comptes sur l'exercice suivant, nous ne solderons pas l'exercice
+précédent.
+
+``Transaction :``
+-----------------
+Ce que nous appelons ici transaction désigne une opération comptable, c'est-à-dire
+l'inscription au journal, à une date donnée, d'un certain nombre d'écritures de
+débit et de crédit. Pour que l'opération soit équilibrée, il faut que la somme
+des écritures de crédit (sur certains comptes) la composant soit égale à celle
+des écritures de débit (sur d'autres comptes). C'est pourquoi on peut voir
+l'ensemble comme une transaction entre plusieurs comptes.
+Une transaction peut, par exemple, représenter une opération d'achat à un
+fournisseur (Crédit du compte de "Achat", débit du compte "Fournisseur"), une
+opération de vente à un client... Dans ce genre de cas, la réalité de l'opération
+peut être prouvée à l'aide d'un justificatif, dont la référence sera inscrite
+dans la comptabilité.
+Historiquement, une transaction est inscrite au Journal (ou, pour la comptabilité
+multi-journaux au journal concerné : journal des ventes, journal des achats...)
+et ses écritures sont reportées au Grand Livre.
\ No newline at end of file
Added: trunk/src/site/rst/callao/news.rst
===================================================================
--- trunk/src/site/rst/callao/news.rst (rev 0)
+++ trunk/src/site/rst/callao/news.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,14 @@
+====
+News
+====
+
+Quoi de neuf sur le projet CALLAO ?
+
+Mise en Ligne du site
+=====================
+
+``Par :`` Jean ``[le Jeudi 24 septembre 2009]``
+
+Le site du projet est enfin en ligne, il faisait précédemment partie du site de
+Lima, il est maintenant autonome et s'étoffera au fur et à mesure de l'avancée
+du projet.
\ No newline at end of file
Added: trunk/src/site/rst/callao/roadmap.rst
===================================================================
--- trunk/src/site/rst/callao/roadmap.rst (rev 0)
+++ trunk/src/site/rst/callao/roadmap.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,9 @@
+=======
+RoadMap
+=======
+
++-----------------------------------------------------------------------------------------+
+| **A venir** |
++-------------------+---------------------------------------------------------------------+
+| *Release* | Release d'une version packagée exécutable comprenant Lima et Callao |
++-------------------+---------------------------------------------------------------------+
Added: trunk/src/site/rst/callao/todo.rst
===================================================================
--- trunk/src/site/rst/callao/todo.rst (rev 0)
+++ trunk/src/site/rst/callao/todo.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,17 @@
+TODO
+====
+
+- suppression des DTOs et utilisation directe des entities
+- suppression des convertObject qui du coup ne servent plus
+- les services devrait plutot lever des exceptions au lieu de retourner des
+ codes d'erreur. (donc revoir la gestion des erreurs dans lima)
+- les methodes de recherche devrait plutot etre dans les DAO que sur les
+ services
+- certaine methode de service ne devrait pas exister (modifyAccount qui prend
+ en argument les differents champs de l'entity, est a remplacer simplement
+ par un store de l'entity)
+- potentiellement il ne faudrait qu'un service CallaoService:
+ store(Object); load(Object); delete(Object); search(Criteria); search(????);
+ getReportList():List<String>; getReport(String name): html/pdf/data?
+ pas de: import(); export(); car c le job de lima ce qui uniformise les formats
+- a quoi sert les UserSerice (ne faut-il pas plutot utiliser celui de Topia ?)
Added: trunk/src/site/rst/callao/usecases.rst
===================================================================
--- trunk/src/site/rst/callao/usecases.rst (rev 0)
+++ trunk/src/site/rst/callao/usecases.rst 2010-03-30 14:15:15 UTC (rev 2819)
@@ -0,0 +1,312 @@
+=====================
+Les Cas d'Utilisation
+=====================
+
+| Cette section présente les cas d'utilisation du moteur CALLAO couplé à LIMA.
+
+``Cas d'utilisation``
+=====================
+
+``Diagramme global``
+--------------------
+
+| Afin d'optimiser la lisibilité des diagrammes, nous avons commencé par décrire les grandes groupes de fonctionnalités, avant d'entrer dans le détail des cas d'utilisation pour chacun.
+
+.. image:: uc/uc-base.png
+
+| On se retrouve donc avec 5 cas d'utilisation globaux :
+
+- Gérer Ecritures : Saisie et modification des écritures comptables.
+- Gérer Périodes : Paramétrage et clôturage des exercice, gestion de la semi-clôture des intervalles de temps.
+- Gérer Comptes : Ajout et modification des comptes.
+- Gérer Fichiers : Import et export des données.
+- Générer Etats : Génération d'états comptables sous forme imprimable, ainsi que des journaux et du grand livre.
+- Synchronier Chorem : Cette fonctionnalité ne correspond pas vraiment à un cas d'utilisation inhérent à LIMA-CALLAO, mais plus à une possibilité d'accès à certaines données qui doit être prévue pour une synchronisation entre CALLAO et Chorem via un logiciel tiers (qui est néanmoins détaillé ici).
+
+``Gérer Ecritures``
+-------------------
+.. image:: uc/uc-journal.png
+| Le diagramme parle de lui-même. Il faudra être vigilent à ne pas pouvoir ajouter d'écriture dans un exercice non encore ouvert ou déjà verrouillé. Il en va de même pour les modification et les suppression.
+
+
+
+| **Cas d'utilisation** : Ajouter Écriture étend : Ajouter Transaction; Gérer Ecritures
+| Acteur principal : Comptable
+| Invariants :
+
+- Une écriture (Entry) appartient à une transaction.
+- Toute opération (par extension tout ajout) sur une écriture (Entry) est répertoriée dans un Log.
+- On ne peut ajouter d'entrée à un exercice (Period) ou un intervalle de temps (TimeSpan) clôturé ou inexistant.
+| Scénario
+| Cas 1 : Ajout d'une écriture dans une transaction non existante pour un intervalle de temps (TimeSpan) non clôturé :
+| Préconditions :
+
+- L'entrée à créer n'appartient pas à une transaction déjà existante.
+- La date entrée pour cette transaction correspond à l'intervalle de temps en cours ou à un intervalle non clôturé.
+| Résultat :
+
+- Une nouvelle entrée est créée et répertoriée dans une nouvelle transaction, elle-même répertoriée dans un journal donné et dans l'intervalle de temps correspondant à la date donnée pour la transaction.
+- Cet ajout d'entrée est consigné dans un nouveau Log.
+| Description :
+
+- Une nouvelle transaction est créée, avec pour attributs les valeurs de la date et de la référence justificatif entrée dans l'interface.
+- Elle est ajoutée au journal depuis lequel l'utilisateur l'a créée (menu déroulant de l'interface), ainsi que dans l'intervalle de temps correspondant à la date donnée.
+- L'entrée est créée avec les données saisies (description, montant, débit, lettrage, compte) et ajoutée à la nouvelle transaction. Un Log est également créé, consignant la date courante (date de modif), la date donnée pour la transaction, le type d'opération (en l'occurrence, ajout) et les attributs de l'écriture et de la transaction.
+| Cas 2 : Ajout d'une écriture dans une transaction existante pour un intervalle de temps (TimeSpan) non clôturé :
+| Préconditions :
+
+- L'entrée à créer appartient à une transaction déjà existante.
+- La date entrée pour cette transaction correspond à l'intervalle de temps en cours ou à un intervalle non clôturé.
+| Résultat :
+
+- Une nouvelle entrée est créée dans une transaction existante. Cet ajout d'entrée est consigné dans un nouveau Log.
+| Description :
+
+- L'entrée est créée avec les données saisies (description, montant, débit, lettrage, compte) et ajoutée à la transaction donnée.
+- Un Log est également créé, consignant la date courante (date de modif), la date donnée pour la transaction, le type d'opération (en l'occurrence, ajout) et les attributs de l'écriture.
+| Exceptions
+| Exception1 : Ajout d'une écriture pour un exercice à venir n'existant pas encore.
+| Préconditions :
+
+- La date de la transaction correspondant à l'entrée ne correspond à aucun exercice existant.
+| Résultat : Rien.
+| Description :
+
+- Un message est affiché pour indiquer à l'utilisateur la démarche à suivre pour créer un nouvel exercice.
+| Exception 2 : Ajout d'une écriture pour un exercice (Period) ou un intervalle de temps (TimeSpan) clôturé.
+| Préconditions :
+
+- La date de la transaction correspondant à l'entrée appartient à un exercice ou un IT clôturé.
+| Résultat : Rien.
+| Description :
+
+- Un message d'erreur est affiché, indiquant à l'utilisateur qu'il ne peut effectuer l'opération d'ajout.
+
+| **Cas d'utilisation **: Modifier Ecriture étend : Gérer Ecritures
+| Acteur principal : Comptable
+| Invariants :
+
+- Une écriture (Entry) ne migre pas d'une transaction à l'autre.
+- Toute opération (par extension toute modification sur une écriture (Entry) est répertoriée dans un Log.
+- On ne peut migrer une entrée vers un exercice (Period) ou un intervalle de temps (TimeSpan) clôturé ou inexistant.
+
+| Scénario :
+| Cas 1 : Modification d'une écriture pour un intervalle de temps (TimeSpan) non clôturé :
+| Pré-conditions :
+
+- L'entrée à créer n'appartient pas à une transaction déjà existante.
+- La date entrée pour cette transaction correspond à l'intervalle de temps en cours ou à un intervalle non clôturé.
+| Résultat :
+
+- Une nouvelle entrée est créée et répertoriée dans une nouvelle transaction, elle-même répertoriée dans un journal donné et dans l'intervalle de temps correspondant à la date donnée pour la transaction.
+- Cet ajout d'entrée est consigné dans un nouveau Log.
+| Description :
+
+- L'entrée est modifiée avec les données nouvellement saisies (description, montant, débit, lettrage, compte).
+- Un Log est également créé, consignant la date courante (date de modif), la date donnée pour la transaction, le type d'opération (en l'occurrence, modification) et les attributs de l'écriture et de la transaction.
+| Exceptions
+| Exception1 : Modification d'une écriture pour un intervalle de temps clôturé.
+| Pré-conditions :
+
+- La date de la transaction correspondant à l'entrée correspond à un intervalle de temps semi-clôturé, voire à un exercice clôturé.
+| Résultat : Rien.
+| Description :
+
+- Un message d'erreur est affiché, indiquant à l'utilisateur qu'il ne peut effectuer l'opération de modification.
+
+| La suppression d'écriture se comporte de manière analogue à la modification, c'est pourquoi nous ne la détaillerons pas ici. Notons juste que si la dernière écriture restant dans une transaction est supprimée, celle-ci sera également supprimée.
+
+|
+| **Cas d'utilisation** : Modifier Transaction étend : Gérer Transactions
+| Acteur principal : Comptable
+| Invariants :
+
+- Aucune transaction ne peut être déplacée dans une période clôturée ou un intervalle de temps semi-clôturé, ni dans un exercice n'existant pas.
+| scénario
+| Cas 1 : Modification du voucherRef ou de la date vers un intervalle de temps existant et non-clôturé :
+| Pré-conditions :
+
+- La transaction n'appartient pas à un intervalle de temps clôturé.
+- La date n'est pas modifiée pour une date concernant un intervalle de temps non existant ou clôturé.
+| Résultat :
+
+- La transaction est modifiée.
+- Un nouveau log est créé pour chacune des Entry de la Transaction.
+| Description :
+
+- La transaction est modifiée avec les données nouvellement saisies (description, montant, débit, lettrage, compte).
+- Pour chacune des écritures de la transaction, un Log est également créé, consignant la date courante (date de modif), la date donnée pour la transaction, le type d'opération (en l'occurrence, modification) et les attributs de l'écriture et de la transaction.
+| Exceptions
+| Exception1 : Modification d'une transaction dans un intervalle de temps clôturé.
+| Pré-conditions :
+
+- La date de la transaction correspond à un intervalle de temps semi-clôturé, voire à un exercice clôturé.
+| Résultat : Rien.
+| Description :
+- Un message d'erreur est affiché, indiquant à l'utilisateur qu'il ne peut effectuer l'opération de modification.
+| Exception2 : Modification de la date de la transaction vers un intervalle de temps clôturé.
+| Pré-conditions :
+- La nouvelle date donnée pour la transaction correspond à un intervalle de temps semi-clôturé, voire à un exercice clôturé.
+| Résultat : Rien.
+| Description :
+- Un message d'erreur est affiché, indiquant à l'utilisateur qu'il ne peut effectuer l'opération de modification.
+
+
+``Gérer Périodes``
+------------------
+.. image:: uc/uc-exercice.png
+| Lors de l'ouverture d'un exercice, il est automatiquement divisé en TimeSpan (qui représenteront des mois en pratique). Ces TimeSpan sont verrouillables, de manière à accéder à un état proche de la clôture, mais où il reste possible de les déverrouiller, ce afin d'éviter d'éventuelles erreurs de saisie. La clôture d'un exercice entraîne la fermeture (définitive cette fois) de tous les TimeSpan qui le composent. A noter également qu'un TimeSpan ne peut être ouvert qu'à la condition que tous les TS posterieurs le soient aussi (et consecutivement un TS ne peut être semi-cloturé que si les TS anterieurs le sont aussi.
+|
+| **Cas d'utilisation** : UC Ouvrir Nouvel Exercice étend l'UC « cloture de periode »
+| Acteur principal : Comptable.
+| Invariant
+
+- Il ne peut jamais y avoir plus de deux exercices non clôturer en même temps.
+| Scénario
+| Cas 1: Création d'un exercice(Period).
+| Pré-condition :
+
+- L'exercice ne doit pas être déjà créer.
+| Description :
+
+- La création d'un nouvel exercice à besoin de connaitre la durée de ce nouvel exercice.
+- Par défaut cette période est de 12 mois.
+- Pour chaque mois, on crée un intervalle de temps.
+- On réalise les différents report à nouveau pour équilibrer l'exercice précèdent et commencer avec les bons chiffre l'exercice nouvellement créer.
+| Post-condition :
+
+- L'intégralité de l'exercice est couvert par des intervalles de temps.
+- La date de début d'exercice et la date de fin de l'exercice précédent se suivent.
+
+| Cas d'utilisation : UC Clôturer Exercice étend l'UC « cloture de periode »
+| Acteur principal : Comptable.
+| Scénario
+| Cas 1: Clôture d'un exercice(Period).
+| Pré-condition :
+
+- L'exercice ne doit pas être déjà clôturé.
+- La date de fin d'exercice doit être atteinte pour pouvoir clôturer l'exercice.
+| Description :
+
+- La clôture de l'exercice entraine la clôture définitive de l'ensemble des intervalles de temps qui le compose.
+- Les opérations de l'exercice ne sont plus éditables.
+- Il est alors possible de publier les documents comptables (ex: bilan, compte de résultat).
+- Les reports à nouveau sont calculés et passés sur l'exercice suivant.
+- Un backup de l'exercice est alors généré.
+| Post-condition :
+
+- L'ensemble des écritures n'est modifiable depuis Callao.
+
+
+| **Cas d'utilisation** : UC Semi-clôturer Intervalle de Temps (Cet UC est étendu par l'UC « création de période »)
+| Acteur principal : Comptable.
+| Invariant
+
+- Toutes les périodes d'un exercice clôturé sont clôturé.
+- Un intervalle de temps dure 1 mois
+| Scénario
+
+- Cas 1: Clôture d'un intervalle de temps(TimeSpan).
+| Pré-condition :
+- L'intervalle de temps ne doit pas être déjà clôturé.
+- La date de fin de période doit être supérieure à la date de début de la période à clôturer.
+| Description :
+
+- Lorsque l'utilisateur clôture l'intervalle, l'ensemble des écritures du mois sont bloquées.
+- S'ils ne le sont pas déjà, l'ensemble des mois précédents sont clôturés.
+- L'utilisateur a toujours la possibilité de débloquer cet intervalle tant que
+l'exercice n'est pas clôturé lui même.
+| Post-condition :
+
+- L'ensemble des écritures n'est plus modifiable depuis Callao.
+- Les périodes précédents cet intervalle sont clôturés.
+| Cas 2: Dé-clôturer un intervalle de temps.
+| Pré-condition :
+
+- L'intervalle de temps doit être clôturer.
+- L'exercice dont il fait parti ne doit pas être clôturer.
+| Description :
+
+- L'intervalle de temps redevient modifiable par l'utilisateur.
+- Le comptable peut alors ajouter, modifier ou supprimer des transactions sur cet intervalle.
+- Tout les intervalles de temps qui le suivent sont dé-clôturés, si ils sont déjà clôturés.
+- L'intervalle est de nouveau clôturable.
+| Post-Condition :
+- Les écritures sont de nouveaux modifiables, les périodes suivantes sont dé-clôturés.
+
+
+``Gérer Comptes``
+-----------------
+.. image:: uc/uc-comptes.png
+| La seule petite particularité de ces cas d'utilisation est qu'on ne pourra pas modifier le numéro ou supprimer un compte sur lequel des écritures ont été passées.
+
+``Gérer Fichiers``
+------------------
+.. image:: uc/uc-fichiers.png
+Génère des fichiers pour sauvegarder ou échanger les données.
+
+| **Cas d'utilisation** : UC Exporter vers Fichiers
+| Acteur principal : Comptable.
+| Scénario
+| Cas 1: Export d'un exercice comptable.
+| Description :
+
+- Récupération de l'ensemble des données.
+- Un fichier est crée avec l'ensemble des paramètres de l'application. Il comprend :
+- les données relatives à l'entreprise (siret, raison sociale...)
+- les comptes de l'entreprise
+- les journaux
+- Les exercices de l'entreprise.(Intervalle de temps, transactions, écritures...)
+| Post-condition :
+
+- Un fichier XML valide est généré.
+
+| **Cas d'utilisation** : UC Importer depuis Fichiers
+| Acteur principal : Comptable.
+| Scénario
+| Cas 1: Import de données
+| Description :
+
+- L'utilisateur spécifie le chemin du fichier à importer.
+- Le fichier est parsé, on supprime l'ensemble des données de la base
+- On enregistre dans la base de données les informations récupérer du fichier.
+| Cas exceptionnels
+| Cas Exceptionnel 1 : Le fichier spécifier n'est pas valide ou n'existe pas.
+| Description :
+
+- Un message d'erreur est affiché.
+- La base de données n'est pas changer.
+
+
+``Générer Etats``
+-----------------
+.. image:: uc/uc-etats.png
+| On aura une génération d'états provisoires pour les périodes non clôturées, et définitif pour les périodes clôturées. On prévoit pour l'instant une génération en PDF. Cette génération pourra être effectuée à n'importe quel moment.
+
+| **Cas d'utilisation** : UC Générer état
+| Acteur principal : Comptable.
+| Invariants
+
+- Un état concerne un seul exercice.
+- Un état sera prévisionnel tant que l'exercice concerné ne sera pas clôturé.
+| Scénario
+| Cas 1: Génération d'un état(Bilan, compte de résultat...).
+| Pré-condition :
+
+- Il faut que l'exercice existe pour pouvoir générer un état.
+| Description :
+
+- On solde les comptes concernés ( ex :produit et charge pour compte de résultat... ).
+- On les affectes aux champs de l'état comptable.
+- On récupère les informations sur la société ( numéro siren, raison sociale...)
+- On exporte dans un fichier au format pdf dont le chemin est prédéfini, l'état concerné.
+- Si l'état n'est pas clôturé, le fichier indique que c'est un état prévisionnel.
+| Post-condition :
+
+- Un fichier pdf est créé.
+
+
+``Synchronier Chorem``
+----------------------
+.. image:: uc/uc-liaison.png
+| Cette liaison permet de récupérer des informations de facturation depuis Chorem afin de les passer en écriture dans Lima/Callao, de fait cette "couche de liaison" disposera d'informations persistantes de manière à associer les clients de Chorem à des comptes (client tartenpion = 4111tartenpion etc ...) et de répercuter les domaines tout en sachant aussi éviter les redondances et faciliter les corrections. Une fois les informations éxtraite de Chorem et les données de liaison mises à jour, ces données pourront être poussées dans Lima/Callao.
1
0
Author: echatellier
Date: 2010-03-29 19:04:51 +0200 (Mon, 29 Mar 2010)
New Revision: 2818
Log:
Ajout d'un glossaire sur les noms anglais des entit?\195?\169s/beans.
Added:
trunk/src/site/rst/devel/glossary.rst
Added: trunk/src/site/rst/devel/glossary.rst
===================================================================
--- trunk/src/site/rst/devel/glossary.rst (rev 0)
+++ trunk/src/site/rst/devel/glossary.rst 2010-03-29 17:04:51 UTC (rev 2818)
@@ -0,0 +1,25 @@
+Lexique des objets manipulés dans Lima
+--------------------------------------
+
+Ce lexique vise à clarifier les termes utilisé dans les objets de Lima (entités
+beans...) par rapport à leur traduction francaise.
+
++------------------+--------------------------+-------------------------------+
+| Anglais | Français | Description |
++==================+==========================+===============================+
+| Account | Compte | |
++------------------+--------------------------+-------------------------------+
+| Entry book | Journal | |
++------------------+--------------------------+-------------------------------+
+| Entry | Écriture comptable | Entrée comptable |
++------------------+--------------------------+-------------------------------+
+| Record | Enregistrement comptable | Composition d'une écriture |
++------------------+--------------------------+-------------------------------+
+| Fiscal period | Exercice | |
++------------------+--------------------------+-------------------------------+
+| Financial period | Période | |
++------------------+--------------------------+-------------------------------+
+| Balance trial | Balance | |
++------------------+--------------------------+-------------------------------+
+| Balance Sheet | Bilan | |
++------------------+--------------------------+-------------------------------+
\ No newline at end of file
1
0
Author: echatellier
Date: 2010-03-29 18:40:23 +0200 (Mon, 29 Mar 2010)
New Revision: 2817
Log:
Suppression des DTO.
Ajout de beans g?\195?\169n?\195?\169r?\195?\169s pour les objets non entit?\195?\169s.
Removed:
trunk/lima-callao/src/main/xmi/accountingdto.zargo
Modified:
trunk/lima-callao/pom.xml
trunk/lima-callao/src/main/xmi/accounting.zargo
Modified: trunk/lima-callao/pom.xml
===================================================================
--- trunk/lima-callao/pom.xml 2010-03-27 20:07:11 UTC (rev 2816)
+++ trunk/lima-callao/pom.xml 2010-03-29 16:40:23 UTC (rev 2817)
@@ -61,7 +61,7 @@
<phase>generate-sources</phase>
<configuration>
<inputs>zargo</inputs>
- <templates>org.nuiton.topia.generator.TopiaMetaGenerator, org.nuiton.topia.generator.DTOGenerator</templates>
+ <templates>org.nuiton.topia.generator.TopiaMetaTransformer, org.nuiton.topia.generator.BeanTransformer</templates>
<defaultPackage>org.chorem.lima.entity</defaultPackage>
<fullPackagePath>org.chorem.lima</fullPackagePath>
</configuration>
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Deleted: trunk/lima-callao/src/main/xmi/accountingdto.zargo
===================================================================
(Binary files differ)
1
0
Author: tchemit
Date: 2010-03-27 21:07:11 +0100 (Sat, 27 Mar 2010)
New Revision: 2816
Log:
Utilisation de mavenpom4redmine 2.0.7
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-26 11:36:00 UTC (rev 2815)
+++ trunk/pom.xml 2010-03-27 20:07:11 UTC (rev 2816)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.0.6</version>
+ <version>2.0.7</version>
</parent>
<groupId>org.chorem</groupId>
1
0
r2815 - in trunk/lima-business/src/main/java/org/chorem/lima/business: . ejb
by echatellier@users.chorem.org 26 Mar '10
by echatellier@users.chorem.org 26 Mar '10
26 Mar '10
Author: echatellier
Date: 2010-03-26 12:36:00 +0100 (Fri, 26 Mar 2010)
New Revision: 2815
Log:
Am?\195?\169lioration du service pour recuperer seulement les fils d'un compte en particulier.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.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-25 13:40:03 UTC (rev 2814)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-03-26 11:36:00 UTC (rev 2815)
@@ -48,4 +48,6 @@
void updateAccount(Account account) throws LimaException;
void removeAccount(Account account) throws LimaException;
+
+ List<Account> getChildrenAccounts(Account masterAccount) throws LimaException;
}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2010-03-26 11:36:00 UTC (rev 2815)
@@ -0,0 +1,79 @@
+/* *##%
+ * 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.ejb;
+
+import org.apache.commons.logging.Log;
+import org.chorem.lima.business.LimaException;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public abstract class AbstractLimaService {
+
+ /**
+ * Generic code used to rollback a transaction.
+ *
+ * TODO : replace this by JTA
+ *
+ * @throws LimaException
+ */
+ protected void doCatch(TopiaContext transaction, Exception cause, Log log) throws LimaException {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", eee);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during create account", cause);
+ }
+ throw new LimaException("Exception during query", cause);
+ }
+
+ /**
+ * Generic code used too close a transaction.
+ *
+ * @param transaction transaction to close
+ * @param log log (can be null)
+ * @throws LimaException
+ */
+ protected void doFinally(TopiaContext transaction, Log log) throws LimaException {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log != null && log.isErrorEnabled()) {
+ log.error("Can't close transaction", ex);
+ }
+ throw new LimaException("Can't close transaction", ex);
+ }
+ }
+ }
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-03-26 11:36:00 UTC (rev 2815)
@@ -43,6 +43,7 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.framework.TopiaQuery;
/**
* Permet d'implémenter le Plan Comptable Général.
@@ -53,7 +54,7 @@
* @author Rémi Chapelet
*/
@Stateless
-public class AccountServiceImpl implements AccountService {
+public class AccountServiceImpl extends AbstractLimaService implements AccountService {
private static final Log log = LogFactory.getLog(AccountServiceImpl.class);
@@ -117,33 +118,13 @@
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);
+ doCatch(transaction, ex, log);
}
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);
- }
- }
+ doFinally(transaction, log);
}
}
+
/*public String createAccount (String accountNumber, String label,Account masterAccount,String type)
{
String result = ServiceHelper.RESPOND_ERROR;
@@ -377,8 +358,7 @@
}*/
/**
- * Permet de convertir tous les comptes en DTO. Il recherche dans un premier
- * temps tous les comptes "master".
+ * Permet de convertir tous les comptes.
*
* @return
* @throws LimaException
@@ -423,31 +403,75 @@
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);
- }
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
+ return accountsList;
+ }
+
+ /**
+ * Permet de recuperer la liste des comptes fils d'un compte en particulier.
+ *
+ * @param masterAccount (can be null)
+ * @return
+ * @throws LimaException
+ */
+ @Override
+ public List<Account> getChildrenAccounts(Account masterAccount) 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);
}
}
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
+ // 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);
+
+ TopiaQuery query = accountDAO.createQuery();
+ // masterAccount is not visible, but column "masterAccount"
+ // exist in Account table
+ query.add("masterAccount", masterAccount);
+
+ if (log.isDebugEnabled()) {
+ log.debug("getChildrenAccounts query : " + query);
}
- throw new LimaException("Can't create account", ex);
+
+ accountsList.addAll(accountDAO.findAllByQuery(query));
}
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
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);
- }
- }
+ doFinally(transaction, log);
}
return accountsList;
@@ -577,31 +601,10 @@
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);
+ doCatch(transaction, ex, log);
}
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);
- }
- }
+ doFinally(transaction, log);
}
}
1
0
r2814 - in trunk/lima-business/src: main/java/org/chorem/lima/business main/java/org/chorem/lima/business/ejb test/java/org/chorem/lima/business
by echatellier@users.chorem.org 25 Mar '10
by echatellier@users.chorem.org 25 Mar '10
25 Mar '10
Author: echatellier
Date: 2010-03-25 14:40:03 +0100 (Thu, 25 Mar 2010)
New Revision: 2814
Log:
Refactor some entities name
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/RecordServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/RecordServiceImplTest.java
Removed:
trunk/lima-business/src/main/java/org/chorem/lima/business/convertObject/
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/TimeSpanServiceImpl.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
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
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/UserServiceImplTest.java
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java (from rev 2811, trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/JournalServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -0,0 +1,473 @@
+/*
+ * *##% Callao EntryBookServiceImpl
+ * 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.EntryBook;
+import org.chorem.lima.entity.EntryBookDAO;
+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-EntryBook. Il est possible de créer ici le
+ * EntryBook des ventes, le EntryBook des achats, etc.
+ *
+ * @author Rémi Chapelet
+ */
+public class EntryBookServiceImpl {
+
+ private static final Log log = LogFactory.getLog(EntryBookServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ //private ConvertEntryBook convertEntryBook = new ConvertEntryBook();
+
+ public EntryBookServiceImpl() {
+ 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 EntryBook. Il peut être unique sur son label (au choix).
+ *
+ * @param EntryBook EntryBook
+ * @throws LimaException
+ */
+ public void createEntryBook(EntryBook EntryBook) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
+ .getEntryBookDAO(topiaContext);
+
+ // Si on souhaite avoir un EntryBook unique avec son label
+
+ EntryBook EntryBook = searchEntryBookWithLabel(label);
+ // Si un EntryBook existe déjà avec ce label
+ if (EntryBook != null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Un EntryBook avec le label " + label
+ + " existe déjà !");
+ }
+ result = ServiceHelper.EntryBook_DOUBLE;
+ } else {
+ // Creation du EntryBook
+ EntryBook newEntryBook = EntryBookDAO.create();
+ newEntryBook.setLabel(label);
+ newEntryBook.setPrefix(prefix);
+ newEntryBook.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 EntryBook de ce nom existe deja
+ EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction);
+ EntryBook existingEntryBook = EntryBookDAO.findByLabel(EntryBook.getLabel());
+ if (existingEntryBook != null) {
+ throw new LimaBusinessException(_("An EntryBook already exists with this label : %s", EntryBook.getLabel()));
+ }
+
+ // creation du EntryBook
+ EntryBookDAO.create(EntryBook);
+
+ // 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 EntryBook", 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 EntryBook", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Création d'un EntryBook à partir de son DTO.
+ * @param EntryBookDTO EntryBook au format DTO.
+ * @return
+ *
+ public String createEntryBook(EntryBookDTO EntryBookDTO) {
+ String result;
+ result = createEntryBook(EntryBookDTO.getLabel(), EntryBookDTO.getPrefix(),
+ EntryBookDTO.getDescription());
+ return result;
+ }*/
+
+ public List<EntryBook> getAllEntryBook() throws LimaException {
+ /*List<EntryBookDTO> listEntryBookDTO = new ArrayList<EntryBookDTO>();
+
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
+ .getEntryBookDAO(topiaContext);
+ // Creation du EntryBook
+ List<EntryBook> listEntryBook = EntryBookDAO.findAll();
+ // Pour chaque EntryBook, on le transforme en DTO
+ for (EntryBook EntryBook : listEntryBook) {
+ // Converti en DTO
+ EntryBookDTO EntryBookDTO = convertEntryBook
+ .EntryBookEntityToDto(EntryBook);
+ // Ajoute à la liste
+ listEntryBookDTO.add(EntryBookDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listEntryBookDTO;*/
+
+ List<EntryBook> EntryBooksList = new ArrayList<EntryBook>();
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // test si un EntryBook de ce nom existe deja
+ EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction);
+ List<EntryBook> EntryBooks = EntryBookDAO.findAll();
+ EntryBooksList.addAll(EntryBooks);
+
+ // 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 EntryBook", 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 EntryBook", ex);
+ }
+ }
+ }
+
+ return EntryBooksList;
+ }
+
+ /*
+ * Permet de rechercher un EntryBook 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 EntryBook recherché
+ * @return
+ *
+ public EntryBook searchEntryBookWithLabel(String label) {
+ EntryBook EntryBookResult = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
+ .getEntryBookDAO(topiaContext);
+ // Creation du EntryBook
+ EntryBookResult = EntryBookDAO.findByLabel(label);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return EntryBookResult;
+ }*/
+
+ /*
+ * Permet de rechercher un EntryBook existant à partir du label.
+ * Le EntryBook recherché est converti automatiquement en format DTO.
+ * @param prefix préfixe du EntryBook recherché
+ * @return
+ *
+ public EntryBookDTO searchEntryBookDTOWithLabel(String label) {
+ EntryBook EntryBook = searchEntryBookWithLabel(label);
+ EntryBookDTO EntryBookDTO = convertEntryBook.EntryBookEntityToDto(EntryBook);
+ return EntryBookDTO;
+ }*/
+
+ /*
+ * Permet de rechercher un EntryBook unique identifé par son topiaId.
+ * @param topiaId identifiant du EntryBook recherché
+ * @return
+ *
+ public EntryBook searchEntryBookWithTopiaId(String topiaId) {
+ EntryBook EntryBookResult = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
+ .getEntryBookDAO(topiaContext);
+ // Creation du EntryBook
+ EntryBookResult = EntryBookDAO.findByTopiaId(topiaId);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return EntryBookResult;
+ }*/
+
+ /*
+ * Permet de rechercher un EntryBook existant à partir du topiaId.
+ * Le EntryBook recherché est converti automatiquement en format DTO.
+ * @param prefix préfixe du EntryBook recherché
+ * @return
+ *
+ public EntryBookDTO searchEntryBookDTOWithTopiaId(String topiaId) {
+ EntryBook EntryBook = searchEntryBookWithTopiaId(topiaId);
+ EntryBookDTO EntryBookDTO = convertEntryBook.EntryBookEntityToDto(EntryBook);
+ return EntryBookDTO;
+ }*/
+
+ /*
+ * Permet de modifier un EntryBook.
+ * @param label
+ * @param prefix
+ * @return
+ *
+ public String modifyEntryBook(String topiaId, String label, String prefix,
+ String description) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ EntryBook EntryBookModify = searchEntryBookWithTopiaId(topiaId);
+ // Si le EntryBook n'existe pas
+ if (EntryBookModify == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le EntryBook " + label + " n'existe pas !");
+ }
+ result = ServiceHelper.EntryBook_NOT_EXIST;
+ } else // Sinon on modifie le EntryBook
+ {
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
+ .getEntryBookDAO(topiaContext);
+ // Modifie le EntryBook
+ EntryBookModify.setPrefix(prefix);
+ EntryBookModify.setDescription(description);
+ EntryBookDAO.update(EntryBookModify);
+ // 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 EntryBook dans la base de données.
+ *
+ * ATTENTION : si un EntryBook est associé avec des transactions, il est alors
+ * impossible de supprimer celui-ci.
+ *
+ * @param prefix préfixe du EntryBook à supprimer
+ * @return
+ * @throws LimaException
+ */
+ public void removeEntryBook(EntryBook EntryBook) throws LimaException {
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ EntryBook EntryBookDelete = searchEntryBookWithTopiaId(topiaId);
+ // Si le EntryBook n'existe pas
+ if (EntryBookDelete == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le EntryBook " + topiaId + " n'existe pas !");
+ }
+ result = ServiceHelper.EntryBook_NOT_EXIST;
+ } else // Sinon on efface le EntryBook
+ {
+
+ // Vérifie si une transaction n'appartient pas à ce EntryBook.
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche au moins une transaction avec ce EntryBook.
+ Transaction transaction = transactionDAO
+ .findByEntryBook(EntryBookDelete);
+ // Il existe au moins une transaction
+ if (transaction != null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Le EntryBook " + topiaId
+ + " possède des transactions comptables !");
+ }
+ result = ServiceHelper.EntryBook_WITH_TRANSACTIONS;
+ } else {
+
+ // Efface le EntryBook
+ // Chargement du DAO
+ EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
+ .getEntryBookDAO(topiaContext);
+ // Supprime le EntryBook
+ EntryBookDAO.delete(EntryBookDelete);
+ // 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 EntryBook.
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
+ Transaction transaction = transactionDAO.findByEntryBook(EntryBook);
+ if (transaction != null) {
+ throw new LimaBusinessException("Can't delete EntryBook with transactions");
+ }
+
+ // test si un EntryBook de ce nom existe deja
+ EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaTransaction);
+ EntryBookDAO.delete(EntryBook);
+
+ // 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 EntryBook", 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 EntryBook", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * Permet d'effacer un EntryBook dans la base de données.
+ * ATTENTION : si un EntryBook est associé avec des transactions, il est alors
+ * impossible de supprimer celui-ci.
+ * @param EntryBookDTO EntryBook au format DTO à supprimer
+ * @return
+ *
+ public String removeEntryBook(EntryBookDTO EntryBookDTO) {
+ String result = removeEntryBook(EntryBookDTO.getId());
+ return result;
+ }*/
+
+}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -43,7 +43,7 @@
private TopiaContext rootContext;
- private LogServiceImpl logServiceImpl = new LogServiceImpl();
+ private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
// TODO A revoir car transaction a besoin de entry et vice versa
private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -68,11 +68,11 @@
private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
- private JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
+ private EntryBookServiceImpl journalServiceImpl = new EntryBookServiceImpl();
- private PeriodServiceImpl periodServiceImpl = new PeriodServiceImpl();
+ private FiscalPeriodServiceImpl periodServiceImpl = new FiscalPeriodServiceImpl();
- private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
+ private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
private TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java (from rev 2811, trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TimeSpanServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -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.FinancialPeriod;
+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 FinancialPeriodServiceImpl { //implements TimeSpanService {
+
+ /** log */
+ private static final Log log = LogFactory.getLog(FinancialPeriodServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+
+ public FinancialPeriodServiceImpl() {
+ 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(FinancialPeriod 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/FiscalPeriodServiceImpl.java (from rev 2811, trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/PeriodServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -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.FinancialPeriod;
+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 FiscalPeriodServiceImpl { //implements PeriodService {
+
+ private static final Log log = LogFactory.getLog(FiscalPeriodServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
+
+ public FiscalPeriodServiceImpl() {
+ 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(FinancialPeriod 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/ejb/JournalServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/JournalServiceImpl.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/JournalServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,473 +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.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;
- }*/
-
-}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/LogServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/LogServiceImpl.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/LogServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,366 +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.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;
- }*/
-}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/PeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/PeriodServiceImpl.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/PeriodServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,505 +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.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/RecordServiceImpl.java (from rev 2811, trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/LogServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/RecordServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/RecordServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -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.Record;
+import org.chorem.lima.entity.RecordDAO;
+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 RecordServiceImpl { //implements LogService {
+
+ /** log */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(RecordServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+
+ public RecordServiceImpl() {
+ 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(Record 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
+ RecordDAO recordDAO = LimaCallaoDAOHelper
+ .getRecordDAO(transaction);
+ recordDAO.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<Record> 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<Record> entryLogsList = new ArrayList<Record>();
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // creation
+ RecordDAO recordDAO = LimaCallaoDAOHelper
+ .getRecordDAO(transaction);
+ List<Record> entryLogs = recordDAO.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/ejb/TimeSpanServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TimeSpanServiceImpl.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TimeSpanServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,534 +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.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;
- }*/
-}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -33,9 +33,9 @@
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.EntryBook;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.TimeSpan;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.Transaction;
import org.chorem.lima.entity.TransactionDAO;
import org.nuiton.topia.TopiaContext;
@@ -59,11 +59,11 @@
private TopiaContext rootContext;
- private LogServiceImpl logServiceImpl = new LogServiceImpl();
+ private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
- private TimeSpanServiceImpl timeSpanServiceImpl = new TimeSpanServiceImpl();
+ private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
public TransactionServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -5,6 +5,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.dto.AccountDTO;
+import org.chorem.lima.business.ejb.AccountServiceImpl;
import org.chorem.lima.business.utils.ServiceHelper;
import org.chorem.lima.entity.Account;
import org.junit.AfterClass;
Copied: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java (from rev 2802, trunk/lima-business/src/test/java/org/chorem/lima/business/JournalServiceImplTest.java)
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -0,0 +1,99 @@
+package org.chorem.lima.business;
+
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ejb.EntryBookServiceImpl;
+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 EntryBookServiceImplTest {
+
+ /** log. */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(EntryBookServiceImplTest.class);
+
+ private static EntryBookServiceImpl 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 EntryBookServiceImpl();
+ }
+
+ public EntryBookServiceImplTest() {
+ }
+
+ /**
+ * 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
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,6 +1,7 @@
package org.chorem.lima.business;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ejb.EntryServiceImpl;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,6 +1,7 @@
package org.chorem.lima.business;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ejb.FilesServiceImpl;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
Copied: trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java (from rev 2802, trunk/lima-business/src/test/java/org/chorem/lima/business/TimeSpanServiceImplTest.java)
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -0,0 +1,98 @@
+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.ejb.FinancialPeriodServiceImpl;
+import org.chorem.lima.business.utils.ServiceHelper;
+import org.chorem.lima.entity.FinancialPeriod;
+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 FinancialPeriodServiceImplTest {
+
+ /** log. */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(FinancialPeriodServiceImplTest.class);
+
+ private static FinancialPeriodServiceImpl 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 FinancialPeriodServiceImpl();
+ }
+
+ public FinancialPeriodServiceImplTest() {
+ }
+
+ /**
+ * 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 */
+ }
+
+}
Copied: trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java (from rev 2802, trunk/lima-business/src/test/java/org/chorem/lima/business/PeriodServiceImplTest.java)
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -0,0 +1,198 @@
+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.ejb.FiscalPeriodServiceImpl;
+import org.chorem.lima.business.utils.ServiceHelper;
+import org.chorem.lima.entity.FiscalPeriod;
+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 FiscalPeriodServiceImplTest {
+
+ /** log. */
+ private static final Log log = LogFactory
+ .getLog(FiscalPeriodServiceImplTest.class);
+
+ private static FiscalPeriodServiceImpl 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
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,6 +1,11 @@
package org.chorem.lima.business;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ejb.AccountServiceImpl;
+import org.chorem.lima.business.ejb.EntryBookServiceImpl;
+import org.chorem.lima.business.ejb.FiscalPeriodServiceImpl;
+import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl;
+import org.chorem.lima.business.ejb.TransactionServiceImpl;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -15,9 +20,9 @@
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 FiscalPeriodServiceImpl instancePeriod;
+ private static FinancialPeriodServiceImpl instanceTimespan;
+ private static EntryBookServiceImpl instanceJournal;
private static AccountServiceImpl instanceAccount;
private static String topiaIDTransaction;
@@ -30,9 +35,9 @@
@Before
public void setUp() {
instanceTransaction = new TransactionServiceImpl();
- instancePeriod = new PeriodServiceImpl();
- instanceTimespan = new TimeSpanServiceImpl();
- instanceJournal = new JournalServiceImpl();
+ instancePeriod = new FiscalPeriodServiceImpl();
+ instanceTimespan = new FinancialPeriodServiceImpl();
+ instanceJournal = new EntryBookServiceImpl();
instanceAccount = new AccountServiceImpl();
}
Deleted: trunk/lima-business/src/test/java/org/chorem/lima/business/JournalServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/JournalServiceImplTest.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/JournalServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,98 +0,0 @@
-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
Deleted: trunk/lima-business/src/test/java/org/chorem/lima/business/LogServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/LogServiceImplTest.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/LogServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,109 +0,0 @@
-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());*/
- }
-
-}
Deleted: trunk/lima-business/src/test/java/org/chorem/lima/business/PeriodServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/PeriodServiceImplTest.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/PeriodServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,197 +0,0 @@
-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
Copied: trunk/lima-business/src/test/java/org/chorem/lima/business/RecordServiceImplTest.java (from rev 2802, trunk/lima-business/src/test/java/org/chorem/lima/business/LogServiceImplTest.java)
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/RecordServiceImplTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/RecordServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -0,0 +1,110 @@
+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.business.ejb.RecordServiceImpl;
+import org.chorem.lima.entity.Record;
+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 RecordServiceImplTest {
+
+ /** log. */
+ private static final org.apache.commons.logging.Log log = LogFactory
+ .getLog(UserServiceImplTest.class);
+
+ private static RecordServiceImpl instance;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ LimaConfigTest.getInstance();
+ }
+
+ @Before
+ public void setUp() {
+ instance = new RecordServiceImpl();
+ }
+
+ @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());*/
+ }
+
+}
Deleted: trunk/lima-business/src/test/java/org/chorem/lima/business/TimeSpanServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/TimeSpanServiceImplTest.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/TimeSpanServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -1,97 +0,0 @@
-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 */
- }
-
-}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/UserServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/UserServiceImplTest.java 2010-03-25 13:03:22 UTC (rev 2813)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/UserServiceImplTest.java 2010-03-25 13:40:03 UTC (rev 2814)
@@ -2,6 +2,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ejb.UserServiceImpl;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
1
0
Author: echatellier
Date: 2010-03-25 14:03:22 +0100 (Thu, 25 Mar 2010)
New Revision: 2813
Log:
Rennomage des entit?\195?\169s avec les termes anglais correct.
Ajout de documentation sur le role de quelques entit?\195?\169s.
Modified:
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-callao/src/main/xmi/accounting.zargo
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-03-23 15:31:34 UTC (rev 2812)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-03-25 13:03:22 UTC (rev 2813)
@@ -1,4 +1,5 @@
# Precise l'entete de l'ensemble des fichiers generes
-model.tagvalue.copyright=/* *##%\n Copyright (C) 2009-2010 Lima Callao\n *##%*/
+model.tagvalue.copyright=/*\n Copyright (C) 2009-2010 Lima Callao\n */
+org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false
#model.tagvalue.dbSchema=Callao
model.tagvalue.String=text
\ No newline at end of file
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
1
0
r2812 - in trunk/lima-swing/src/main/java/org/chorem/lima: . service
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:31:34 +0100 (Tue, 23 Mar 2010)
New Revision: 2812
Log:
Ajout d'une factory pour recuperer les services via OpenEJB (en mode local pour l'instant)
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/service/
trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
Added: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-03-23 15:31:34 UTC (rev 2812)
@@ -0,0 +1,191 @@
+/* *##%
+ * 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.service;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openejb.OpenEJB;
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.loader.SystemInstance;
+import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.ejb.JournalServiceImpl;
+import org.chorem.lima.business.ejb.PeriodServiceImpl;
+
+/**
+ * Is class is a service factory based on embedded openejb container.
+ *
+ * More information:
+ * <ul>
+ * <li>http://openejb.apache.org/embedding-openejb.html</li>
+ * </ul>
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class LimaServiceFactory {
+
+ /** Log. */
+ private static Log log = LogFactory.getLog(LimaServiceFactory.class);
+
+ protected static LimaServiceFactory instance;
+
+ protected InitialContext ctx;
+
+ /**
+ * Init openejb jndi context.
+ */
+ public LimaServiceFactory() {
+ Properties properties = new Properties();
+
+ // embedded server
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory");
+
+ try {
+ ctx = new InitialContext(properties);
+ } catch (NamingException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't initialize initial context", eee);
+ }
+ }
+ }
+
+ /**
+ * Return service factory singleton instance.
+ *
+ * Init it at first call.
+ *
+ * @return singleton instance
+ */
+ public static LimaServiceFactory getInstance() {
+ if (instance == null) {
+ instance = new LimaServiceFactory();
+ }
+ return instance;
+ }
+
+ /**
+ * Get Account service.
+ *
+ * @return account service proxy
+ */
+ public AccountService getAccountService() {
+
+ // first way is
+ // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
+
+ // second way is (spec compliant)
+ // Object obj = ctx.lookup("my/bean/Foo");
+ // FooHome ejbHome = (FooHome)
+ // PortableRemoteObject.narrow(obj, FooHome.class);
+
+ // TODO put lookup name in configuration
+ String lookupName = AccountService.class.getName().replace('.', '/');
+ AccountService ejbHome = null;
+ try {
+ ejbHome = (AccountService)ctx.lookup("AccountServiceImplLocal");
+ } catch (NamingException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't lookup for service : " + lookupName, eee);
+ }
+ }
+ return ejbHome;
+ }
+
+ /**
+ * Get Journal service.
+ *
+ * @return account service proxy
+ */
+ public JournalServiceImpl getJournalService() {
+
+ // first way is
+ // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
+
+ // second way is (spec compliant)
+ // Object obj = ctx.lookup("my/bean/Foo");
+ // FooHome ejbHome = (FooHome)
+ // PortableRemoteObject.narrow(obj, FooHome.class);
+
+ // TODO put lookup name in configuration
+ String lookupName = JournalServiceImpl.class.getName().replace('.', '/');
+ JournalServiceImpl ejbHome = null;
+ try {
+ ejbHome = (JournalServiceImpl)ctx.lookup("JournalServiceImplLocal");
+ } catch (NamingException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't lookup for service : " + lookupName, eee);
+ }
+ }
+ return ejbHome;
+ }
+
+ /**
+ * Get Journal service.
+ *
+ * @return account service proxy
+ */
+ public PeriodServiceImpl getPeriodService() {
+
+ // first way is
+ // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
+
+ // second way is (spec compliant)
+ // Object obj = ctx.lookup("my/bean/Foo");
+ // FooHome ejbHome = (FooHome)
+ // PortableRemoteObject.narrow(obj, FooHome.class);
+
+ // TODO put lookup name in configuration
+ String lookupName = PeriodServiceImpl.class.getName().replace('.', '/');
+ PeriodServiceImpl ejbHome = null;
+ try {
+ ejbHome = (PeriodServiceImpl)ctx.lookup("PeriodServiceImplLocal");
+ } catch (NamingException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't lookup for service : " + lookupName, eee);
+ }
+ }
+ return ejbHome;
+ }
+
+ /**
+ * Destroy openejb jndi context.
+ *
+ * Code taken from openEJB faq :
+ * http://openejb.apache.org/faq.html
+ *
+ * @throws Exception when trying to destroy a non existent application
+ */
+ public void destroy() throws Exception {
+ Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
+ for (AppInfo appInfo : assembler.getDeployedApplications()) {
+ assembler.destroyApplication(appInfo.jarPath);
+ }
+ OpenEJB.destroy();
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0