Echobase-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
December 2011
- 2 participants
- 86 discussions
r145 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase/entities echobase-entities/src/main/resources/i18n echobase-entities/src/main/xmi echobase-tools/src/main/java/fr/ifremer/echobase/tools src/doc/reunions
by tchemit@users.forge.codelutin.com 05 Dec '11
by tchemit@users.forge.codelutin.com 05 Dec '11
05 Dec '11
Author: tchemit
Date: 2011-12-05 17:36:41 +0100 (Mon, 05 Dec 2011)
New Revision: 145
Url: http://forge.codelutin.com/repositories/revision/echobase/145
Log:
apply last acoustic data model
Added:
trunk/src/doc/reunions/reunion-2011-12-05.txt
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/ReferenceCsvGenerator.java
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-12-05 08:27:59 UTC (rev 144)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-12-05 16:36:41 UTC (rev 145)
@@ -45,9 +45,7 @@
result.add(EchoBaseEntityEnum.Voyage);
result.add(EchoBaseEntityEnum.Transit);
- result.add(EchoBaseEntityEnum.TransitVessel);
result.add(EchoBaseEntityEnum.Transect);
- result.add(EchoBaseEntityEnum.TransectAcousticInstrument);
result.add(EchoBaseEntityEnum.DataAcquisition);
result.add(EchoBaseEntityEnum.DataProcessing);
result.add(EchoBaseEntityEnum.Cell);
@@ -82,9 +80,7 @@
result.add(EchoBaseEntityEnum.Cell);
result.add(EchoBaseEntityEnum.DataProcessing);
result.add(EchoBaseEntityEnum.DataAcquisition);
- result.add(EchoBaseEntityEnum.TransectAcousticInstrument);
result.add(EchoBaseEntityEnum.Transect);
- result.add(EchoBaseEntityEnum.TransitVessel);
result.add(EchoBaseEntityEnum.Transit);
result.add(EchoBaseEntityEnum.Voyage);
Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-12-05 08:27:59 UTC (rev 144)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-12-05 16:36:41 UTC (rev 145)
@@ -40,6 +40,7 @@
echobase.common.cellMethod=
echobase.common.cellName=
echobase.common.cellType=
+echobase.common.childs=
echobase.common.citation=
echobase.common.classCode=
echobase.common.codeMemo=
@@ -276,7 +277,9 @@
echobase.common.voyageDescription=Description de campagne
echobase.common.voyageEndDate=Date de fin de campagne
echobase.common.voyageEndHarbour=Port de fin de campagne
+echobase.common.voyageEndPort=
echobase.common.voyageName=Nom de la campagne
echobase.common.voyageStartDate=Date de début de campagne
echobase.common.voyageStartHarbour=Port de début de campagne
+echobase.common.voyageStartPort=
echobase.config.data.directory.description=Chemin de l'application
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
Modified: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/ReferenceCsvGenerator.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/ReferenceCsvGenerator.java 2011-12-05 08:27:59 UTC (rev 144)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/ReferenceCsvGenerator.java 2011-12-05 16:36:41 UTC (rev 145)
@@ -76,7 +76,8 @@
T_Query_User : [ClefPere, Clef_User, Creer, Description, Dist, GB, Gen_Description, Gen_Requete, Ident, Modif, Numordre, Requete, Status, Titre, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 8 entries.
Table des erreurs : [NOM_CAMPAGNE] with 2 entries.
ZONE : [CODE_ZONE, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 5 entries.
-*/
+ */
+
protected final File msAccessFile;
protected final File exportDirectory;
Added: trunk/src/doc/reunions/reunion-2011-12-05.txt
===================================================================
--- trunk/src/doc/reunions/reunion-2011-12-05.txt (rev 0)
+++ trunk/src/doc/reunions/reunion-2011-12-05.txt 2011-12-05 16:36:41 UTC (rev 145)
@@ -0,0 +1,285 @@
+===============
+projet echobase
+===============
+
+Lundi 5-12-2011 (Ifremer)
+
+Présents : Mathieu, Tony
+
+Planning
+--------
+
+Finaliser le modèle d'import des données acoustiques.
+
+Modèle acoustique
+-----------------
+
+Entité Voyage
+~~~~~~~~~~~~~
+
+Sample recopie de la table *CAMPAGNE* avec en plus deux clef étrangères sur
+Mission et AreaOfOperation.
+
+*CAMPAGNE* -> VoyageName (S)
+*TYPE_CAMPAGNE* -> Mission (FK)
+*DATE_DEPART* -> VoyageStartDate (Date)
+*DATE_ARRIVEE* -> VoyageEndDate (Date)
+*PORT_DEPART* -> StartPort (S)
+*PORT_ARRIVEE* -> EndPort (S)
+*ZONE* -> AreaOfOperation (FK)
+*COMMENTAIRE* -> VoyageDescription (S)
+
+Entité Transit
+~~~~~~~~~~~~~~
+
+Pour les données anciennes on doit créer un transit pour une campagne
+
+Les seuls champs à renseigner sont les suivants :
+
+*TransitDescription* -> "Cruise"
+*TransitStartTime* -> Voyage#VoyageStartDate
+*TransitEndTime* -> Voyage#VoyageEndDate
+
+
+Entité Transect
+~~~~~~~~~~~~~~~
+
+Comme pour les transits, dans les données historiques, on a un seul transect
+par campagne. On crée donc artificiellement un tel objet par campagne.
+
+Voici les champs à renseigner :
+
+*Title* -> "Cruise" (S)
+*Comment* -> "From Baracouda" (S)
+*BinUnitsPingAxis* -> n.mi." (S)
+*BinSizePingAxis* -> 1 (I)
+*BinSizeRangeAxis* -> "variable" (S) ? cela ne colle pas avec un type (D) ?
+
+On supprime l'entité *TransitVessel* et on attache directement le Vessel sur le
+Transect.
+
+*CAMPAGNE#NAVIRE* -> vessel (FK)
+
+Ensemble des nouveaux champs :
+
+*Abstract* (S)
+*History* (S)
+*Metadata* (S)
+*Citation* (S)
+*Licence* (S)
+*VesselName* -> A supprimer car redondant
+*VoyageID* -> A supprimer car redondant
+*DateCreated* (Date)
+*GeospatialLonMin* (D)
+*GeospatialLonMax* (D)
+*GeospatialLatMin* (D)
+*GeospatialLatMax* (D)
+*Datum* (S)
+*Linestring* (S)
+*GeospatialVerticalMin* (D)
+*GeospatialVerticalMax* (D)
+*GeospatialVerticalPositive* (S)
+*TimeCoverageStart* (Date)
+*TimeCoverageEnd* (Date)
+*BinUnitsPingAxis* (S)
+*BinSizePingAxis* (D)
+*BinSizeRangeAxis* (D)
+
+Entité DataAcquisition
+~~~~~~~~~~~~~~~~~~~~~~
+
+Il s'agit d'une nouvelle table.
+
+On supprime l'entité *AcousticInstrumentInTransect* et on attache directement
+le *AcousticInstrument* sur le Transect.
+
+Pour les données anciennes on crée une ligne pour chaque Transect.
+
+AcousticInstrument (FK) la référence sur le AcousticInstrument utilisé à partir de *EI_SONDEUR#ID_REFSONDEUR*
+TransceiverAcquisitionAbsorption (D)
+TransceiverAcquisitionAbsorptionDescription (S)
+TransducerAcquisitionBeamAngleAthwartship (D)
+TransducerAcquisitionBeamAngleAlongship (D)
+TransducerAcquisitionPsi (D)
+TransceiverAcquisitionPower (I)
+TransectAcousticInstrumentID (S) inutile on a supprimer cette table d'association
+DataAcquisitionID ID -> inutile car on a déjà une clef technique
+AcquisitionSoftwareVersion (S)
+LoggedDataFormat (S)
+LoggedDataDatatype (S)
+TransceiverAcquisitionPulseLength (D)
+TransceiverAcquisitionGain (D)
+TransceiverAcquisitionSacorrection (D)
+PingDutyCycle (S)
+EchosounderSoundSpeed (I)
+SoundSpeedCalculations (S)
+
+Entité DataProcessing
+~~~~~~~~~~~~~~~~~~~~~
+
+Pour les données anciennes on crée une ligne pour chaque DataAcquisition.
+
+On récupère ensuite les données à partir de la table *EI_CONFIGURATION* en
+utilisant la ligne de la campagne *ID_EI*.
+
+*ID_EI* -> DataProcessingID (S) A ne pas conserver (ref vers la campagne)
+*TYPE_EI* -> ProcessingTemplate (S)
+*QUALIF_EI* -> ProcessingDescription (S)
+*CSTSONDEUR* -> SounderConstant (D)
+*SEUILNUM* -> DigitThreshold (I)
+*SEUILEIT* -> EIThreshold (I)
+*ENERG_UNIT_SOURCE* -> AcousticDensityUnit (S)
+*COMMENTAIRE* -> Notes (S)
+*SV_GAIN* -> TransceiverProcessingGain (D)
+
+Nouveaux champs :
+
+*DataAcquisitionID* (S) A supprimer
+*ProcessingSoftwareVersion* (S)
+*TransceiverProcessingSacorrection* (D)
+*TransceiverProcessingAbsorption* (D)
+*TransceiverProcessingAbsorptionDescription* (S)
+*TransducerProcessingPsi* (D)
+*TransducerProcessingBeamAngleAthwartship* (D)
+*TransducerProcessingBeamAngleAlongship* (D)
+*EchosounderSoundSpeed* (D)
+*SoundSpeedCalculations* (S)
+
+
+Entité Cell et Data
+~~~~~~~~~~~~~~~~~~~
+
+On utilise plutôt une relation Cell --> childs (Cell) car une cellule peut
+avoir plusieurs parents.
+
+On veut importer trois type de cellules :
+
+- cellule de type région
+- cellule de type ESDU (parent de type région)
+- cellule de type élémentaire (parent de type ESDU)
+
+Cellule de type Région
+++++++++++++++++++++++
+
+Cell
+____
+
+Il s'agit de cellules de type *RegionSURF* et *RegionCLAS*, elles proviennent
+de la table *POST_STRATE*.
+
+On prend uniquement les cellules dont le *Type_Image* vaut :
+
+*SURF* -> pour une cellule de type *RegionSURF*
+*CLAS* -> pour une cellule de type *RegionCLAS*
+
+On conserve uniquement la donnée suivbante :
+
+*ID_STRATE* -> *CellName* (S) c'est la clef métier que l'on veut conserver.
+
+Data
+____
+
+On considère une seule donnée pour les cellules de type *Région*, à savoir de
+type *Surface*.
+
+La donnée est encore dans la table *POST_STRATE* dans la colonne *SURFACE*
+
+*SURFACE* -> *dataValue* (S)
+
+Cellule de type ESDU
+++++++++++++++++++++
+
+Les cellules de type ESDU ont pour parent des cellules de type Région et
+proviennent de la table *EI_ESU*, une telle cellule aura un celluleType nommé
+*ESDU*.
+
+Pour rattacher une cellule de type “Esdu” à sa région, on utilise la table
+*SCENARIO* la région = POST_STRATE_SCENARIO et l'id de la cellule esdu c'est
+DTHU_SCENARIO.
+
+Cell
+____
+
+*ID_EI_ESDU* -> DataProcessingID (S) inutile car on possède d'ja cette information
+*DHTU_ESDU* -> CellName (S) Il s'agit de la clef métier que l'on va conserver
+*FLAG* -> DataQualityFlagValues (FK) vers la table DataQuality#qualityDataFlagValues
+
+celluleType -> vers celle de nom "ESDU"
+
+Data
+____
+
+5 types de données possibles :
+
+- *Latitude* (EI_ESU#LATDMC)
+- *Longitude* (EI_ESU#LGDMC)
+- *depth* (EI_ESU#SONDE)
+- *time* (EI_ESU#DHTU_DEVIATION)
+- *AcousticDensity* (EI_ESU#TOTAL)
+
+A noter que pour la donnée acoustique, on doit retrouver son type qui a été
+injecté dans DataMetadata depuis la table *EI_CONFIGURATION* et qui est lié à
+la campagne (utilisation du champs EI_CONFIGURATION#ENERG_UNIT_SOURCE).
+
+A noté que pour les données de type *Latitud*, *Longitude* et *depth*, on doit
+avoir cellMethod = "Start" dans la dataMetadata à utiliser.
+
+Cellule de type élémentaire
++++++++++++++++++++++++++++
+
+Les cellule de type élémentaire ont pour parent les cellules *ESDU* et
+proviennent de la table *EIT_DESCRIPT_TRANCHE*, une telle cellule aura un
+celluleType nommé *Elementaire*
+
+Pour rattacher une cellule de type “élémentaire” à sa cellule ESDU, on utilise
+la table *EIT_ENERGIE_TRANCHES* la cellule ESDU = DHTU_ESDU et l'id de la
+cellule esdu c'est Id_TRANCHE (mais on ne le conserve pas au final)
+
+Cell
+____
+
+*ID_TRANCHE* -> CellID ID (inutile car on a déjà une clef technique)
+*LIBELLE_TRANCHE* -> CellName (S) (c'est la clef métier à conserver)
+*FLAG* -> DataQualityFlagValues (FK) Utiliser la donnée de EI_ESDU#FLAG) vers
+ la table DataQuality#qualityDataFlagValues pour les données historiques.
+
+Data
+____
+
+Les cellules d'écho-intégration peuvent être référencées à la surface
+(LIBELLE_TRANCHE de type "Sx") ou au fond (LIBELLE_TRANCHE de type "Fx").
+Cette information se retrouve dans le type de Data décrivant leurs limites de
+profondeur.
+
+On utilise 3 types de données sur une telle cellule :
+
+- *DepthRefSurfaceStart* ou *DepthRefBottomStart* -> *EIT_DESCRIPT_TRANCHE#HMIN_TRANCHE*
+- *DepthRefSurfaceEnd* ou *DepthRefBottomEnd* -> *EIT_DESCRIPT_TRANCHE#HMAX_TRANCHE*
+- *AcousticDensity* -> *EIT_ENERGIE_TRANCHES#ENERGY*
+- *time* -> *EIT_ENERGIE_TRANCHES#DHTU_DEVIATION*
+
+Comme pour les cellules de type ESDU on retrouve la metaData de type
+*AcousticDensity* via le type de campagne et la meta importée à partir de la
+table *EI_CONFIGURATION*.
+
+Entité Result
+~~~~~~~~~~~~~
+
+Pas encore disponible
+
+Import
+------
+
+- Prévoir un import des Calibration
+- Prévoir un import des Résultats
+
+On en reparlera lors de la mise en place des imports.
+
+Actions
+-------
+
+- faire l'import du référentiel et des données depuis la base historique (Codelutin)
+- finir les actions d'import/export globale de la base (Codelutin)
+- définir les scénarii d'imports (Ifremer)
+- finir l'import des données historiques pour le modèle acoustique (Ifremer)
+- finir le modèle de pêche (Ifremer)
Property changes on: trunk/src/doc/reunions/reunion-2011-12-05.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
05 Dec '11
Author: tchemit
Date: 2011-12-05 09:27:59 +0100 (Mon, 05 Dec 2011)
New Revision: 144
Url: http://forge.codelutin.com/repositories/revision/echobase/144
Log:
introduce tools module to do the legacy import
Added:
trunk/echobase-tools/
trunk/echobase-tools/LICENSE.txt
trunk/echobase-tools/README.txt
trunk/echobase-tools/changelog.txt
trunk/echobase-tools/pom.xml
trunk/echobase-tools/src/
trunk/echobase-tools/src/main/
trunk/echobase-tools/src/main/java/
trunk/echobase-tools/src/main/java/fr/
trunk/echobase-tools/src/main/java/fr/ifremer/
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/ReferenceCsvGenerator.java
trunk/echobase-tools/src/main/resources/
trunk/echobase-tools/src/site/
trunk/echobase-tools/src/site/rst/
trunk/echobase-tools/src/site/rst/index.rst
trunk/echobase-tools/src/site/site_fr.xml
trunk/echobase-tools/src/test/
trunk/echobase-tools/src/test/java/
trunk/echobase-tools/src/test/java/fr/
trunk/echobase-tools/src/test/java/fr/ifremer/
trunk/echobase-tools/src/test/java/fr/ifremer/echobase/
trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/
trunk/echobase-tools/src/test/resources/
Property changes on: trunk/echobase-tools
___________________________________________________________________
Added: svn:ignore
+ target
*.ipr
*.iws
*.iml
*.log
Property changes on: trunk/echobase-tools/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-tools/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-tools/changelog.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-tools/pom.xml
===================================================================
--- trunk/echobase-tools/pom.xml (rev 0)
+++ trunk/echobase-tools/pom.xml 2011-12-05 08:27:59 UTC (rev 144)
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>fr.ifremer</groupId>
+ <artifactId>echobase</artifactId>
+ <version>0.2-SNAPSHOT</version>
+ </parent>
+
+ <groupId>fr.ifremer.echobase</groupId>
+ <artifactId>echobase-tools</artifactId>
+
+ <name>EchoBase :: Tools</name>
+ <description>EchoBase tools module</description>
+
+ <dependencies>
+
+ <!-- sibling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>echobase-entities</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>echobase-services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>fr.ird</groupId>
+ <artifactId>msaccess-importer</artifactId>
+ </dependency>
+
+ <!-- database dependencies -->
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- commons dependencies -->
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <!-- logging dependencies -->
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jcl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- transitive dependencies -->
+
+ <dependency>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
Property changes on: trunk/echobase-tools/pom.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/ReferenceCsvGenerator.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/ReferenceCsvGenerator.java (rev 0)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/ReferenceCsvGenerator.java 2011-12-05 08:27:59 UTC (rev 144)
@@ -0,0 +1,180 @@
+/*
+ * #%L
+ * EchoBase :: Tools
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.tools;
+
+import com.google.common.base.Preconditions;
+import com.healthmarketscience.jackcess.Database;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * To generate the sql references from a ms-access db.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class ReferenceCsvGenerator {
+
+ /*
+BIOMETRIE_ECHELLE : [Code_Param_Biometrie_Echelle, Code_echelle, Descriptif, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 44 entries.
+BIOMETRIE_PARAMETRE : [Code_Param_Biometrie, Label, Libelle_Param_Biometrie, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 110 entries.
+BIOMETRIE_VALEUR : [CODE_PARAM_VALEUR_BIOMETRIE, GENRE_ESP_VALEUR_BIOMETRIE, Gen_OBSERVATIONS, NOSTA_VALEUR_BIOMETRIE, NUMIND_VALEUR_BIOMETRIE, OBSERVATIONS, VALEUR_BIOMETRIE, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 251793 entries.
+BIOMRES : [Biomasse_NB(Milliers), Biomasse_W(tonnes), CAMPAGNE, CATEGORIE, DHTU_ESDU, ESDU, Energie_esp(sA), GENRE_ESP, ID_EI_ESDU, LAT, LIBELLE_DEVIATION, Long, Numéro, Poids_moy, PrAcoust, STATION, Taille_Moy, Type_AFFECT] with 58044 entries.
+BIOMRES_AGE : [AGE, ESDUID, GENR_ESP, LAT, LONG, N, NTOT, Numéro, TC] with 9965 entries.
+BIOMRES_REGIONS : [AREA, CAMPAGNE, CodEsp, DEV, GENR_ESP, ID, Nhauls, Numéro, Region, biom, bioms, mXe, mXes, sA, wbiom, wbioms, wmXe, wmXes] with 146 entries.
+CAMPAGNES : [CAMPAGNE, CHEF_MISSION, COMMENTAIRE, DATE_ARRIVEE, DATE_DEPART, Gen_COMMENTAIRE, Gen_ROSCOP, LETTRE_AN, LIMITE_EST, LIMITE_NORD, LIMITE_OUEST, LIMITE_SUD, NAVIRE, NOM_CAMPAGNE, PORT_ARRIVEE, PORT_DEPART, ROSCOP, TYPE_CAMPAGNE, ZONE, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 42 entries.
+CAPTURES : [CATEG, GENRE_ESP, LMOY, MOULE_MENS, NOSTA, NTOT, PESP_MENS, PESP_METRIE, PMOY, PT_ESP, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 9505 entries.
+CAPTURES_old : [CATEG, GENRE_ESP, LMOY, MOULE_MENS, NOSTA, NTOT, PESP_MENS, PESP_METRIE, PMOY, PT_ESP, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 7499 entries.
+CATEGORIE : [Code_Categorie, Libelle_Categorie, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 10 entries.
+CLE_TAILLE_AGE : [AGE, CAMPAGNE, GENRE_ESP, Origine_Data, POURCENTAGE, TAILLE, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 1637 entries.
+COEFFICIENT_ACOUSTIQUE : [BAC, CAC, Genre_esp, Id_sondeur, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 422 entries.
+EIT_DESCRIPT_ECHOS : [ID_DESCRIPTION_DEVIATION, IMAGES, LIBELLE_DESCRIPTION_DEVIATION, TYPE_DEVIATION, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 61 entries.
+EIT_DESCRIPT_TRANCHE : [HMAX_TRANCHE, HMIN_TRANCHE, ID_TRANCHE, LIBELLE_TRANCHE, SEUIL_MAX, SEUIL_MIN, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 251 entries.
+EIT_ENERGIES_TRANCHES : [DHTU_DEVIATION, ENERGIE, ID_EI_ESDU, ID_TRANCHE, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 355238 entries.
+EIT_FORMULES_ECHOS : [COEFFICIENT, DTHU_DEVIATION, ID_EI_DEVIATION, ID_TRANCHE, LIBELLE_DEVIATION, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 0 entries.
+EIT_VALEUR_ECHOS : [DHTU_DEVIATION, ENERGIE, FORMULE_DEVIATION, ID_DESCRIPTION_DEVIATION, ID_EI_DEVIATION, LIBELLE_DEVIATION, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 170231 entries.
+EI_CONFIGURATION : [CAMPAGNE, COMMENTAIRE, CSTSONDEUR, Coeff_conversion_SA, DEVPOISSONFORMULE, DURÉEIMPULSION, ENERG_UNIT_SOURCE, Gen_COMMENTAIRE, ID_EI, ID_REFSONDEUR, LOITVG, PUISSANCE, QUALIF_EI, SEUILEIT, SEUILNUM, SL_VR, SL_VR_MAX, SV_GAIN, TS_GAIN, TYPE_EI, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 29 entries.
+EI_ESU : [CODE_IMAGE, DEVPOISSON, DHTU_ESDU, ESDU, ESUCUT, ESUTYPE, Energie_Total_Banc, Energy_Hors_Banc, FLAG, ID_EI_ESDU, LATDMC, LGDMC, Nb_Ecant_Total, Nb_Echant_Hors_Banc, Nb_Echant_Integre, R, Reverb_Total, SEI, SONDE, TOTAL, Troncon, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 34524 entries.
+EI_SONDEUR : [10LOGPSI, ALONGSHIP, ALPHA, ATHWARTSHIP, BILLE, CHAMP_PROCHE, FREQ, FREQUENCE, IDENT_SONDEUR, ID_REFSONDEUR, NAVIRE, PUISSANCE_MAX, SONDEUR, TRANSDUCTEUR, TS_BILLE, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 20 entries.
+ESPECE_ECHOS : [CODE_DESCRIPTION_DEVIATION, GENRE_ESP, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 198 entries.
+Feuille1$_ImportErrors : [Champ, Erreur, Ligne] with 57100 entries.
+LIEN_ECHO_ESU_STATION : [AC_EI_LIEN_ESDU, DTHU_LIEN_ESDU, ID_STATION, LIBELLE_ECHO, TYPE_AFFECTATION, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 167170 entries.
+LIEN_STRATE_ESU : [AC_EI_LIEN_ESDU, DTHU_LIEN_ESDU, ID_STRATE, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 2604 entries.
+LISTE_NAVIRE : [Nom_navire, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 4 entries.
+LISTE_TYPE_CAMPAGNE : [Code_type_campagne, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 13 entries.
+MENSURATIONS : [CATEG, GENRE_ESP, NBIND, NOSTA, POIDSTAILLE, TAILLE, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 50507 entries.
+POST_STRATE : [ID_STRATE, LIBELLE_STRATE, SURFACE, TYPE_AFFECTATION, Type_Image, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 127 entries.
+REFERENCE_ESPECE : [CODE_SIH, GENRE_ESP, NIVEAU_ESPECE_ECHO, NODC, NOM_ESP, NOM_SCIENTIFIQUE, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 217 entries.
+SCENARIO : [COMMENTAIRE_SCENARIO, DHTU_SCENARIO, ID_EI_SCENARIO, LIBELLE_ECHO_SCENARIO, NOSTA_SCENARIO, NOSTA_VALIDATION, POST_STRATE_SCENARIO, Type_Image, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 126113 entries.
+STATIONS : [CAMPAGNE, COMMENTAIRE, DHTUDEB, DHTUFIN, ENGIN, ESDU_REF, ETAT, JOUR_NUIT, LATDD, LATDEB, LATFIN, LFUNES, LGDD, LGDEB, LGFIN, NOCHA, NOSTA, POIDS_TOTAL_PRELEVEMENT, SONDE, SONDEDEB, SONDEFIN, STA_IMAGES, VMAX, VMIN, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 1560 entries.
+TAILLE_POIDS : [Campagne, Categorie, Coeff_A_RTP, Commentaire, Exposant_N_RTP, Genre_esp, Origine_DATA, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 220 entries.
+TYPE_AFFECTATION : [Code_affectation, Libelle_affectation, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 3 entries.
+TYPE_IMAGE : [Libelle_image, Type_Image, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 5 entries.
+T_Query_User : [ClefPere, Clef_User, Creer, Description, Dist, GB, Gen_Description, Gen_Requete, Ident, Modif, Numordre, Requete, Status, Titre, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 8 entries.
+Table des erreurs : [NOM_CAMPAGNE] with 2 entries.
+ZONE : [CODE_ZONE, s_ColLineage, s_GUID, s_Generation, s_Lineage] with 5 entries.
+*/
+ protected final File msAccessFile;
+
+ protected final File exportDirectory;
+
+ protected final EchoBaseServiceContext serviceContext;
+
+ protected Database msAccessDb;
+
+ public ReferenceCsvGenerator(File msAccessFile,
+ File exportDirectory,
+ EchoBaseServiceContext serviceContext) {
+ Preconditions.checkNotNull(serviceContext, "serviceContext parameter can not be null");
+ Preconditions.checkNotNull(msAccessFile, "msAccessFile parameter can not be null");
+ Preconditions.checkNotNull(exportDirectory, "exportDirectory parameter can not be null");
+ Preconditions.checkArgument(msAccessFile.exists(),
+ "file " + msAccessFile + " does not exist.");
+ this.msAccessFile = msAccessFile;
+ this.exportDirectory = exportDirectory;
+ this.serviceContext = serviceContext;
+ }
+
+ public void doExport() {
+
+ }
+
+ public void exportSpecies() {
+ //TODO
+ }
+ public void exportCalibration() {
+ //TODO
+ }
+
+ public void exportAcousticInstrument() {
+ //TODO
+ }
+
+ public void exportTSParameters() {
+ // require species and acousticInstrument
+ }
+
+ public void exportVesselType() {
+
+ }
+
+ public void exportVessel() {
+ // require vesselType
+ }
+
+ public void exportMission() {
+ // require vesselType
+ }
+
+ public void exportDepthStratumType() {
+
+ }
+
+ public void exportDepthStratum() {
+ // require depthStratumType
+ }
+
+ public void exportEchotypeCategory() {
+
+ }
+
+ public void exportEchotype() {
+ // require depthStratum and echotypeCategory
+ }
+
+ public void exportAreaOfOperation() {
+
+ }
+
+ public void exportReferenceDatumType() {
+
+ }
+
+ public void exportReferenceDatum() {
+ // require referenceDatumType
+
+ }
+
+ public void exportDataType() {
+
+ }
+
+ public void exportCellMethod() {
+
+ }
+
+ public void exportDataMetadata() {
+ // require referenceDatum, dataType and cellMethod
+ }
+
+ protected Database getMsAccessDb() throws IOException {
+ if (msAccessDb == null) {
+ msAccessDb = Database.open(msAccessFile);
+ }
+ return msAccessDb;
+ }
+}
+
Property changes on: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/ReferenceCsvGenerator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-tools/src/site/rst/index.rst
===================================================================
--- trunk/echobase-tools/src/site/rst/index.rst (rev 0)
+++ trunk/echobase-tools/src/site/rst/index.rst 2011-12-05 08:27:59 UTC (rev 144)
@@ -0,0 +1,27 @@
+.. -
+.. * #%L
+.. * EchoBase :: Tools
+.. *
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2011 Ifremer, Codelutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Affero General Public License as published by
+.. * the Free Software Foundation, either version 3 of the License, or
+.. * (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Public License for more details.
+.. *
+.. * You should have received a copy of the GNU Affero General Public License
+.. * along with this program. If not, see <http://www.gnu.org/licenses/>.
+.. * #L%
+.. -
+EchoBase dbbatch
+================
+
+Ce module définit les outils pour générer le script des données de la base initiale.
Property changes on: trunk/echobase-tools/src/site/rst/index.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-tools/src/site/site_fr.xml
===================================================================
--- trunk/echobase-tools/src/site/site_fr.xml (rev 0)
+++ trunk/echobase-tools/src/site/site_fr.xml 2011-12-05 08:27:59 UTC (rev 144)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ EchoBase :: Tools
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+
+
+<project name="${project.name}">
+
+ <body>
+
+ <menu ref="parent"/>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html"/>
+ </breadcrumbs>
+
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Property changes on: trunk/echobase-tools/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r143 - in trunk/echobase-ui/src: main/java/fr/ifremer/echobase/ui main/java/fr/ifremer/echobase/ui/actions main/java/fr/ifremer/echobase/ui/actions/dbeditor main/java/fr/ifremer/echobase/ui/actions/export main/java/fr/ifremer/echobase/ui/actions/user main/webapp/WEB-INF/jsp main/webapp/WEB-INF/jsp/dbeditor main/webapp/WEB-INF/jsp/export site/rst
by tchemit@users.forge.codelutin.com 05 Dec '11
by tchemit@users.forge.codelutin.com 05 Dec '11
05 Dec '11
Author: tchemit
Date: 2011-12-05 09:27:35 +0100 (Mon, 05 Dec 2011)
New Revision: 143
Url: http://forge.codelutin.com/repositories/revision/echobase/143
Log:
-fix grid sort (no more prefix)
-no i18n on columns in dbeditor (neither in table names)
-impact from dbeditor
Modified:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/AbstractJSONPaginedAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/AbstractLoadPage.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/GetSqlResult.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/GetUsers.java
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/modificationLogs.jsp
trunk/echobase-ui/src/site/rst/index.rst
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-12-05 08:27:35 UTC (rev 143)
@@ -107,7 +107,7 @@
List<EchoBaseEntityEnum> entityEnums =
Lists.newArrayList(EchoBaseEntityEnum.values());
// entityEnums.remove(EchoBaseEntityEnum.EchoBaseUser);
- DbMeta dbMeta = new DbMeta(entityEnums.toArray(new EchoBaseEntityEnum[entityEnums.size()]));
+ DbMeta dbMeta = DbMeta.newDbMeta(entityEnums);
applicationContext.setDbMeta(dbMeta);
@@ -122,7 +122,7 @@
try {
boolean schemaExist = isSchemaCreated();
if (!schemaExist ||
- configuration.getOptionAsBoolean(EchoBaseConfiguration.OPTION_UPDATE_SCHEMA)) {
+ configuration.getOptionAsBoolean(EchoBaseConfiguration.OPTION_UPDATE_SCHEMA)) {
updateSchema(configuration);
}
@@ -220,7 +220,7 @@
// no users in database create the admin user
if (log.isInfoEnabled()) {
log.info("No user in database, will create default " +
- "admin user (password admin).");
+ "admin user (password admin).");
}
service.createDefaultAdminUser();
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/AbstractJSONPaginedAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/AbstractJSONPaginedAction.java 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/AbstractJSONPaginedAction.java 2011-12-05 08:27:35 UTC (rev 143)
@@ -56,13 +56,6 @@
protected String filters;
- /** Prefix added to the sidx when used. */
- protected final String sidx_prefix;
-
- protected AbstractJSONPaginedAction(String sidx_prefix) {
- this.sidx_prefix = sidx_prefix;
- }
-
public void setRows(Integer rows) {
pager.setPageSize(rows);
}
@@ -98,7 +91,7 @@
protected String getSortColumn() {
String result = null;
if (useSort()) {
- result = sidx.substring(sidx_prefix.length());
+ result = sidx;
}
return result;
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/AbstractLoadPage.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/AbstractLoadPage.java 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/AbstractLoadPage.java 2011-12-05 08:27:35 UTC (rev 143)
@@ -75,8 +75,7 @@
DbMeta dbMeta = getEchoBaseApplicationContext().getDbMeta();
for (TableMeta tableMeta : dbMeta) {
String name = tableMeta.getName();
- String i18nKey = tableMeta.getI18nKey();
- entityTypes.put(name, _(i18nKey));
+ entityTypes.put(name, name);
}
if (entityType == null) {
@@ -86,7 +85,7 @@
// load table metas
DbEditorService dbEditorService = newService(DbEditorService.class);
- tableMeta = dbEditorService.getTableMetas(entityType);
+ tableMeta = dbEditorService.getTableMeta(entityType);
}
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2011-12-05 08:27:35 UTC (rev 143)
@@ -50,10 +50,6 @@
/** Datas of the given table. */
protected Map<?, ?>[] datas;
- public GetEntities() {
- super("datas_");
- }
-
public void setEntityType(EchoBaseEntityEnum entityType) {
this.entityType = entityType;
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-12-05 08:27:35 UTC (rev 143)
@@ -23,8 +23,6 @@
*/
package fr.ifremer.echobase.ui.actions.dbeditor;
-import fr.ifremer.echobase.entities.meta.ColumnMeta;
-
/**
* To load the db editor pages.
*
@@ -51,14 +49,4 @@
}
return INPUT;
}
-
- public String getFormatter(ColumnMeta meta) {
- String editType = "'string'";
- if (meta.isBoolean()) {
- editType = "'checkbox'";
- } else if (meta.isFK()) {
- editType = "'formatEntityLabel'";
- }
- return editType;
- }
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java 2011-12-05 08:27:35 UTC (rev 143)
@@ -30,6 +30,7 @@
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.interceptor.ParameterAware;
+import org.nuiton.topia.persistence.TopiaEntity;
import java.util.List;
import java.util.Map;
@@ -71,7 +72,7 @@
public String execute() throws Exception {
DbEditorService service = newService(DbEditorService.class);
- TableMeta tableMeta = service.getTableMetas(entityType);
+ TableMeta tableMeta = service.getTableMeta(entityType);
Map<String, String> properties = Maps.newHashMap();
List<String> columnNames = tableMeta.getColumnNames();
for (String columnName : columnNames) {
@@ -92,9 +93,9 @@
}
}
}
+ properties.put(TopiaEntity.TOPIA_ID, id);
service.saveEntity(tableMeta,
- id,
properties,
getEchoBaseSession().getEchoBaseUser());
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/GetSqlResult.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/GetSqlResult.java 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/GetSqlResult.java 2011-12-05 08:27:35 UTC (rev 143)
@@ -44,10 +44,6 @@
/** Datas of the given table. */
protected Map<?, ?>[] datas;
- public GetSqlResult() {
- super("datas_");
- }
-
public void setSql(String sql) {
this.sql = sql;
}
@@ -78,7 +74,6 @@
@Override
public String execute() throws Exception {
-
ExportSqlService service = newService(ExportSqlService.class);
datas = service.executeSql(sql, pager);
return SUCCESS;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/GetUsers.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/GetUsers.java 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/GetUsers.java 2011-12-05 08:27:35 UTC (rev 143)
@@ -43,10 +43,6 @@
protected List<EchoBaseUserDTO> users;
- public GetUsers() {
- super("users_");
- }
-
public List<EchoBaseUserDTO> getUsers() {
return users;
}
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-12-05 08:27:35 UTC (rev 143)
@@ -257,9 +257,7 @@
</s:if>
<s:else>
<sjg:gridColumn name="%{#meta.name}"
- title="%{getText(#meta.i18nKey)}"
- formatter='%{getFormatter(#meta)}'
- formatoptions="{newformat : 'd/m/Y'}"
+ title="%{#meta.name}"
sortable="true" editable="true"/>
</s:else>
@@ -292,6 +290,7 @@
<s:hidden id="id" name='id' label=''/>
<s:iterator value="columnMetas" var="meta" status="status">
+ <s:set var="metaName" value='%{#meta.name}'/>
<s:if test="#meta.fK">
<s:url id="urlName"
action="getForeignEntities"
@@ -299,29 +298,29 @@
escapeAmp="false">
<s:param name="entityType" value="%{#meta.typeSimpleName}"/>
</s:url>
- <sj:select id="%{#meta.name}"
- label="%{getText(#meta.i18nKey)}"
+ <sj:select id="%{#metaName}"
+ label="%{#metaName}"
href="%{urlName}"
list="entities"
emptyOption="true"/>
</s:if>
<s:else>
<s:if test='#meta.columnType == "string"'>
- <s:textfield id="%{#meta.name}"
- name="%{#meta.name}"
- label="%{getText(#meta.i18nKey)}"
+ <s:textfield id="%{#metaName}"
+ name="%{#metaName}"
+ label="%{#metaName}"
disabled="%{#meta.fK}"
value=""/>
</s:if>
<s:elseif test='#meta.columnType == "boolean"'>
- <s:checkbox id="%{#meta.name}"
- name="%{#meta.name}"
- label="%{getText(#meta.i18nKey)}" value="%{false}"/>
+ <s:checkbox id="%{#metaName}"
+ name="%{#metaName}"
+ label="%{#metaName}" value="%{false}"/>
</s:elseif>
<s:elseif test='#meta.columnType == "date"'>
- <sj:datepicker id="%{#meta.name}"
- name="%{#meta.name}"
- label="%{getText(#meta.i18nKey)}"
+ <sj:datepicker id="%{#metaName}"
+ name="%{#metaName}"
+ label="%{#metaName}"
value="%{new java.util.Date()}"
displayFormat="dd/mm/yy"
timepicker="true"
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp 2011-12-05 08:27:35 UTC (rev 143)
@@ -96,7 +96,7 @@
<s:label value="%{query.lastModifiedDate}" readonly="true"
label="%{getText('echobase.common.lastModifiedDate')}"/>
- <s:label value="%{decorate(query.lastModifiedUser, null)}" readonly="true"
+ <s:label value="%{query.lastModifiedUser}" readonly="true"
label="%{getText('echobase.common.lastModifiedUser')}"/>
</s:if>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/modificationLogs.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/modificationLogs.jsp 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/modificationLogs.jsp 2011-12-05 08:27:35 UTC (rev 143)
@@ -29,11 +29,6 @@
<s:set var="emptySelection"><s:text name="echobase.message.noEntrySelection"/></s:set>
<script type="text/javascript">
- function formatEntityLabel(cellvalue, options, rowObject) {
- var columnName = options.colModel.name + "_lib";
- return rowObject[columnName];
- }
-
jQuery(document).ready(function () {
$.addRowSelectTopic('datas', function(event){
var text = $("tr[aria-selected=true] td[aria-describedby='datas_modificationText']").text();
@@ -67,7 +62,7 @@
title="%{getText('echobase.common.modificationDate')}"/>
<sjg:gridColumn name="modificationText" sortable="true"
title="%{getText('echobase.common.modificationText')}"/>
- <sjg:gridColumn name="modificationUser" sortable="true" formatter="formatEntityLabel"
+ <sjg:gridColumn name="modificationUser" sortable="true"
title="%{getText('echobase.common.modificationUser')}"/>
</sjg:grid>
Modified: trunk/echobase-ui/src/site/rst/index.rst
===================================================================
--- trunk/echobase-ui/src/site/rst/index.rst 2011-12-05 08:24:55 UTC (rev 142)
+++ trunk/echobase-ui/src/site/rst/index.rst 2011-12-05 08:27:35 UTC (rev 143)
@@ -21,7 +21,7 @@
.. * along with this program. If not, see <http://www.gnu.org/licenses/>.
.. * #L%
.. -
-baracouda-ui
+EchoBase ui
============
Ce module définit l'application web du projet.
1
0
r142 - in trunk/echobase-services/src: main/java/fr/ifremer/echobase/services main/java/fr/ifremer/echobase/services/models main/resources test/java/fr/ifremer/echobase test/java/fr/ifremer/echobase/services test/resources
by tchemit@users.forge.codelutin.com 05 Dec '11
by tchemit@users.forge.codelutin.com 05 Dec '11
05 Dec '11
Author: tchemit
Date: 2011-12-05 09:24:55 +0100 (Mon, 05 Dec 2011)
New Revision: 142
Url: http://forge.codelutin.com/repositories/revision/echobase/142
Log:
-Introduce models package
-remove dummy db configuration file
-begin of implementation of import/export of global db
-use same code for import/export of a entity and load/save it
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportExportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/CsvModelUtil.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityAssociationCsvModel.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityCsvModel.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ExportSqlCsvModel.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/DbImportExportServiceTest.java
Removed:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvModelUtil.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorCsvModel.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java
trunk/echobase-services/src/main/resources/echobase-db.properties
trunk/echobase-services/src/test/resources/echobase.properties
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvImportResult.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalService.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/TestHelper.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvImportResult.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvImportResult.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvImportResult.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -39,21 +39,35 @@
private static final long serialVersionUID = 1L;
/** type of entity to import csv datas. */
- protected EchoBaseEntityEnum entityType;
+ protected final EchoBaseEntityEnum entityType;
/** Name of the csv file to import. */
- protected String importFileName;
+ protected final String importFileName;
+ /** Flag to authorize to create entities not found in db. */
+ protected final boolean createIfNotFound;
+
/** Count of created entities. */
-
protected int numberCreated;
/** Count of updated entities. */
protected int numberUpdated;
- /** Flag to authorize to create entities not found in db. */
- protected boolean createIfNotFound;
+ public static CsvImportResult newResult(EchoBaseEntityEnum entityType,
+ String importFileName,
+ boolean createIfNotFound) {
+ CsvImportResult result = new CsvImportResult(entityType, importFileName,
+ createIfNotFound);
+ return result;
+ }
+ protected CsvImportResult(EchoBaseEntityEnum entityType,
+ String importFileName,
+ boolean createIfNotFound) {
+ this.entityType = entityType;
+ this.importFileName = importFileName;
+ this.createIfNotFound = createIfNotFound;
+ }
public EchoBaseEntityEnum getEntityType() {
return entityType;
@@ -84,15 +98,4 @@
numberUpdated++;
}
- public void setEntityType(EchoBaseEntityEnum entityType) {
- this.entityType = entityType;
- }
-
- public void setImportFileName(String importFileName) {
- this.importFileName = importFileName;
- }
-
- public void setCreateIfNotFound(boolean createIfNotFound) {
- this.createIfNotFound = createIfNotFound;
- }
}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvModelUtil.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvModelUtil.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvModelUtil.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -1,134 +0,0 @@
-/*
- * #%L
- * EchoBase :: Services
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.echobase.services;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Maps;
-import fr.ifremer.echobase.EchoBaseTechnicalException;
-import org.apache.commons.lang3.StringUtils;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.util.csv.Common;
-import org.nuiton.util.csv.ValueFormatter;
-import org.nuiton.util.csv.ValueParserFormatter;
-
-import java.text.ParseException;
-import java.util.Collection;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * Usefull class to build csv import-export models.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class CsvModelUtil extends Common {
-
- public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type) {
- return new ForeignKeyValue<E>(type);
- }
-
- public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type, Collection<E> entitites) {
- return new ForeignKeyValue<E>(type, entitites);
- }
-
- public static <E extends TopiaEntity> ForeignKeyDecoratedValue<E> newForeignKeyDecoratedValue(Class<E> entityType, DecoratorService decoratorService, Locale locale) {
- return new ForeignKeyDecoratedValue<E>(entityType, decoratorService, locale);
- }
-
- public static class ForeignKeyValue<E extends TopiaEntity> implements ValueParserFormatter<E> {
-
- protected final Class<E> entityType;
-
- protected final Map<String, E> universe;
-
- public ForeignKeyValue(Class<E> entityType, Collection<E> entitites) {
- this.entityType = entityType;
- universe = Maps.uniqueIndex(entitites, new Function<E, String>() {
- @Override
- public String apply(E input) {
- return input.getTopiaId();
- }
- });
- }
-
- public ForeignKeyValue(Class<E> entityType) {
- this.entityType = entityType;
- universe = Maps.newHashMap();
- }
-
- @Override
- public E parse(String value) throws ParseException {
- E result = null;
- if (StringUtils.isNotBlank(value)) {
-
- // get entity from universe
- result = universe.get(value);
-
- if (result == null) {
-
- // can not find entity this is a big problem for us...
- throw new EchoBaseTechnicalException(
- "Could not find entity with name " + value);
- }
- }
- return result;
- }
-
- @Override
- public String format(E e) {
- String value = "";
- if (e != null) {
- value = e.getTopiaId();
- }
- return value;
- }
- }
-
- public static class ForeignKeyDecoratedValue<E extends TopiaEntity> implements ValueFormatter<E> {
-
- protected final Class<E> entityType;
-
- protected final DecoratorService decoratorService;
-
- protected final Locale locale;
-
- public ForeignKeyDecoratedValue(Class<E> entityType, DecoratorService decoratorService, Locale locale) {
- this.entityType = entityType;
- this.decoratorService = decoratorService;
- this.locale = locale;
-
- }
-
- @Override
- public String format(E e) {
- String value = "";
- if (e != null) {
-
- value = decoratorService.decorate(locale, e, null);
- }
- return value;
- }
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorCsvModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorCsvModel.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorCsvModel.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -1,159 +0,0 @@
-/*
- * #%L
- * EchoBase :: Services
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.echobase.services;
-
-import fr.ifremer.echobase.entities.meta.TableMeta;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.util.csv.ExportableColumn;
-import org.nuiton.util.csv.ImportExportModel;
-import org.nuiton.util.csv.ImportableColumn;
-import org.nuiton.util.csv.ModelBuilder;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-/**
- * Import/Export csv model.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class DbEditorCsvModel<E extends TopiaEntity> implements ImportExportModel<E> {
-
- protected final char separator;
-
- protected final TableMeta tableMeta;
-
- protected ModelBuilder<E> modelBuilder;
-
- public DbEditorCsvModel(char separator, TableMeta tableMeta) {
- this.separator = separator;
- this.tableMeta = tableMeta;
- modelBuilder = new ModelBuilder<E>();
- }
-
- @Override
- public char getSeparator() {
- return separator;
- }
-
- @Override
- public Collection<ExportableColumn<E, Object>> getColumnsForExport() {
- return (Collection)
- modelBuilder.getColumnsForExport();
- }
-
- @Override
- public Collection<ImportableColumn<E, Object>> getColumnsForImport() {
- return (Collection)
- modelBuilder.getColumnsForImport();
- }
-
- @Override
- public void pushCsvHeaderNames(List<String> headerNames) {
- }
-
- @Override
- public E newEmptyInstance() {
- return (E) tableMeta.newEntity();
- }
-
- public void addForeignKeyForExport(String propertyName,
- Class<TopiaEntity> entityType) {
-
- modelBuilder.newColumnForExport(
- propertyName,
- propertyName,
- CsvModelUtil.newForeignKeyValue(entityType)
- );
- }
-
- public void addForeignKeyForImport(String propertyName,
- Class<TopiaEntity> entityType,
- Collection<TopiaEntity> universe) {
-
- modelBuilder.newMandatoryColumn(
- propertyName,
- propertyName,
- CsvModelUtil.newForeignKeyValue(entityType, universe)
- );
- }
-
- public <E extends TopiaEntity> void addDefaultColumn(String propertyName,
- Class<?> type) {
-
- if (Date.class.equals(type)) {
- modelBuilder.newColumnForImportExport(
- propertyName,
- propertyName,
- CsvModelUtil.DAY_TIME_SECOND
- );
- } else if (float.class.equals(type)) {
- modelBuilder.newColumnForImportExport(
- propertyName,
- propertyName,
- CsvModelUtil.PRIMITIVE_FLOAT
- );
- } else if (Float.class.equals(type)) {
- modelBuilder.newColumnForImportExport(
- propertyName,
- propertyName,
- CsvModelUtil.FLOAT
- );
- } else if (int.class.equals(type)) {
- modelBuilder.newColumnForImportExport(
- propertyName,
- propertyName,
- CsvModelUtil.PRIMITIVE_INTEGER
- );
- } else if (Integer.class.equals(type)) {
- modelBuilder.newColumnForImportExport(
- propertyName,
- propertyName,
- CsvModelUtil.INTEGER
- );
- } else if (boolean.class.equals(type)) {
- modelBuilder.newColumnForImportExport(
- propertyName,
- propertyName,
- CsvModelUtil.PRIMITIVE_BOOLEAN
- );
- } else if (Boolean.class.equals(type)) {
- modelBuilder.newColumnForImportExport(
- propertyName,
- propertyName,
- CsvModelUtil.BOOLEAN
- );
- } else {
-
- // string
- modelBuilder.newColumnForImportExport(
- propertyName,
- propertyName
- );
- }
- }
-
-}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -32,7 +32,8 @@
import fr.ifremer.echobase.entities.meta.ColumnMeta;
import fr.ifremer.echobase.entities.meta.DbMeta;
import fr.ifremer.echobase.entities.meta.TableMeta;
-import org.apache.commons.io.IOUtils;
+import fr.ifremer.echobase.services.models.CsvModelUtil;
+import fr.ifremer.echobase.services.models.EntityCsvModel;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,17 +43,13 @@
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.beans.BeanMonitor;
import org.nuiton.util.beans.PropertyDiff;
-import org.nuiton.util.csv.Export;
-import org.nuiton.util.csv.ExportableColumn;
-import org.nuiton.util.csv.Import;
-import org.nuiton.util.csv.ImportableColumn;
-import org.nuiton.util.csv.ModelBuilder;
+import org.nuiton.util.csv.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
+import java.io.IOException;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -88,7 +85,7 @@
}
}
- public TableMeta getTableMetas(EchoBaseEntityEnum tableName) {
+ public TableMeta getTableMeta(EchoBaseEntityEnum tableName) {
DbMeta dbMeta = getDbMeta();
TableMeta result = dbMeta.getTable(tableName);
return result;
@@ -111,9 +108,9 @@
List<E> result;
EchoBaseEntityEnum entityEnum = tableMeta.getEntityEnum();
- Class<? extends TopiaEntity> contract = entityEnum.getContract();
+ Class<E> contract = (Class<E>) entityEnum.getContract();
try {
- TopiaDAO dao = getDAO(contract);
+ TopiaDAO<E> dao = getDAO(contract);
// first query to count datas
TopiaQuery countQuery = dao.createQuery("e");
@@ -163,18 +160,17 @@
Boolean ascendantOrder,
boolean addDecorated) {
- TableMeta tableMeta = getTableMetas(entityType);
+ TableMeta meta = getTableMeta(entityType);
- List<TopiaEntity> entities = getEntities(tableMeta,
- pager,
- sidx,
- ascendantOrder
+ List<TopiaEntity> entities = getEntities(meta,
+ pager,
+ sidx,
+ ascendantOrder
);
Map<?, ?>[] rows = new Map[entities.size()];
- DbEditorCsvModel<TopiaEntity> model =
- buildForLoad(tableMeta, addDecorated);
+ ImportExportModel<TopiaEntity> model = buildForLoad(meta, addDecorated);
int i = 0;
for (Object o : entities) {
@@ -191,23 +187,21 @@
try {
TopiaDAO<?> dao = getDAO(entityEnum.getContract());
TopiaEntity entity = dao.findByTopiaId(topiaId);
- DbEditorCsvModel<TopiaEntity> model = buildForLoad(tableMeta, true);
+ ImportExportModel<TopiaEntity> model = buildForLoad(tableMeta, true);
return loadRow(entity, model);
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not obtain data", eee);
}
}
- public void saveEntity(TableMeta tableMeta,
- String id,
+ public void saveEntity(TableMeta meta,
Map<String, String> properties,
EchoBaseUser user) {
// transform properties entity
- DbEditorCsvModel<TopiaEntity> model = buildForSave(tableMeta);
+ ImportExportModel<TopiaEntity> model = buildForSave(meta);
TopiaEntity entity = model.newEmptyInstance();
- entity.setTopiaId(id);
for (ImportableColumn<TopiaEntity, Object> column : model.getColumnsForImport()) {
String propertyName = column.getHeaderName();
@@ -221,12 +215,12 @@
try {
column.setValue(entity, o);
} catch (Exception e) {
- throw new EchoBaseTechnicalException("Could not set property [" + propertyName + "] with value " + stringValue + " to entity " + entity);
+ throw new EchoBaseTechnicalException(
+ "Could not set property [" + propertyName + "] with value " + stringValue + " to entity " + entity);
}
}
- saveEntity(
- tableMeta,
+ saveEntity(meta,
"Modification utilisateur",
entity,
user,
@@ -239,31 +233,28 @@
String importFileName,
File importFile,
boolean createIfNotFound,
- EchoBaseUser user) {
- TableMeta tableMeta = getTableMetas(entityType);
- DbEditorCsvModel<TopiaEntity> csvModel = buildForImport(tableMeta);
+ EchoBaseUser user) throws IOException {
+
+ TableMeta meta = getTableMeta(entityType);
+ ImportExportModel<TopiaEntity> csvModel = buildForImport(meta);
String messagePrefix = "Import du fichier " + importFileName + " le " + newDate();
- CsvImportResult result = new CsvImportResult();
- result.setImportFileName(importFileName);
- result.setEntityType(entityType);
- BufferedReader bf = null;
+ CsvImportResult result = CsvImportResult.newResult(entityType,
+ importFileName,
+ createIfNotFound);
+ BufferedReader bf = new BufferedReader(new FileReader(importFile));
try {
- bf = new BufferedReader(new FileReader(importFile));
Import<TopiaEntity> importer = Import.newImport(csvModel, bf);
- Iterator<TopiaEntity> iterator = importer.startImport();
-
try {
- while (iterator.hasNext()) {
- TopiaEntity entity = iterator.next();
- boolean create = saveEntity(tableMeta,
- messagePrefix,
- entity,
- user,
- createIfNotFound
+ for (TopiaEntity entity : importer) {
+ boolean create = saveEntity(meta,
+ messagePrefix,
+ entity,
+ user,
+ createIfNotFound
);
if (create) {
@@ -276,7 +267,7 @@
}
} finally {
- importer.stopImport();
+ importer.close();
}
commitTransaction("Could not commit transaction");
@@ -286,19 +277,18 @@
log.error("Failed to read import file " + importFile.getName(), eee);
throw new EchoBaseTechnicalException(eee);
} finally {
- IOUtils.closeQuietly(bf);
+ bf.close();
}
-
return result;
}
public String exportDatas(EchoBaseEntityEnum entityType) {
- TableMeta tableMeta = getTableMetas(entityType);
+ TableMeta tableMeta = getTableMeta(entityType);
List<TopiaEntity> datas = getEntities(tableMeta, null, null, null);
- DbEditorCsvModel<TopiaEntity> model = buildForExport(tableMeta);
+ ImportExportModel<TopiaEntity> model = buildForExport(tableMeta);
Export<TopiaEntity> export = Export.newExport(model, datas);
@@ -314,7 +304,6 @@
TopiaEntity entity,
EchoBaseUser user,
boolean createIfNotFound) {
-
String[] columnNames = tableMeta.getColumnNamesAsArray();
BeanMonitor monitor = null;
@@ -340,7 +329,8 @@
if (!createIfNotFound) {
// this is an error
- throw new EchoBaseTechnicalException("Could not found entity with id " + id);
+ throw new EchoBaseTechnicalException(
+ "Could not found entity with id " + id);
} else {
entityToSave = dao.create(TopiaEntity.TOPIA_ID, id);
create = true;
@@ -358,7 +348,7 @@
tableMeta.copy(entity, entityToSave);
PropertyDiff[] propertyDiffs = monitor == null ? null :
- monitor.getPropertyDiffs();
+ monitor.getPropertyDiffs();
createEntityModificationLog(
tableMeta,
@@ -392,7 +382,7 @@
buffer = new StringBuilder(messagePrefix + "\n");
if (create) {
- buffer.append("Une entité à été crée d'identifiant ").append(topiaId);
+ buffer.append("Une entité a été crée d'identifiant ").append(topiaId);
} else {
int length = propertyDiffs.length;
@@ -423,9 +413,9 @@
}
}
buffer.append(String.format("\n Propriété '%s', ancienne valeur : %s, nouvelle valeur : %s",
- propertyName,
- sourceValue,
- targetValue
+ propertyName,
+ sourceValue,
+ targetValue
));
}
}
@@ -436,7 +426,7 @@
dao.create(
EntityModificationLog.PROPERTY_ENTITY_TYPE, tableMeta.getEntityEnum().name(),
EntityModificationLog.PROPERTY_ENTITY_ID, topiaId,
- EntityModificationLog.PROPERTY_MODIFICATION_USER, user,
+ EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
EntityModificationLog.PROPERTY_MODIFICATION_TEXT, buffer.toString()
);
@@ -444,7 +434,7 @@
protected <E extends TopiaEntity> Map<String, Object> loadRow(
E entity,
- DbEditorCsvModel<E> loadModel) {
+ ImportExportModel<E> loadModel) {
Map<String, Object> row = Maps.newLinkedHashMap();
@@ -459,7 +449,7 @@
} catch (Exception eee) {
throw new EchoBaseTechnicalException(
"Could not obtain property [" + propertyName +
- "] value ", eee);
+ "] value ", eee);
}
String formatedValue = column.formatValue(value);
row.put(propertyName, formatedValue);
@@ -468,19 +458,15 @@
return row;
}
- protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForImport(TableMeta tableMetas) {
+ public <E extends TopiaEntity> ImportExportModel<E> buildForImport(TableMeta meta) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(),
- tableMetas);
-
- ModelBuilder<E> modelBuilder = model.modelBuilder;
-
- modelBuilder.newColumnForImportExport(
- TopiaEntity.TOPIA_ID,
+ EntityCsvModel<E> model = EntityCsvModel.newModel(
+ getConfiguration().getCsvSeparator(),
+ meta,
TopiaEntity.TOPIA_ID
);
- for (ColumnMeta columnMeta : model.tableMeta) {
+ for (ColumnMeta columnMeta : meta) {
String propertyName = columnMeta.getName();
Class<?> type = columnMeta.getType();
if (columnMeta.isFK()) {
@@ -495,30 +481,22 @@
return model;
}
- protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForSave(TableMeta tableMetas) {
+ public <E extends TopiaEntity> ImportExportModel<E> buildForExport(TableMeta meta) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(),
- tableMetas);
-
- ModelBuilder<E> modelBuilder = model.modelBuilder;
-
- modelBuilder.newColumnForExport(
- TopiaEntity.TOPIA_ID,
+ EntityCsvModel<E> model = EntityCsvModel.newModel(
+ getConfiguration().getCsvSeparator(),
+ meta,
TopiaEntity.TOPIA_ID
);
- for (ColumnMeta columnMeta : model.tableMeta) {
+
+ for (ColumnMeta columnMeta : meta) {
String propertyName = columnMeta.getName();
Class<?> type = columnMeta.getType();
if (columnMeta.isFK()) {
Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
-
- Collection<TopiaEntity> universe = getForeignDatas(entityType);
-
- // translate foreign key to his id
- model.addForeignKeyForImport(propertyName, entityType, universe);
-
+ model.addForeignKeyForExport(propertyName, entityType);
} else {
model.addDefaultColumn(propertyName, type);
}
@@ -526,25 +504,25 @@
return model;
}
- protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForExport(TableMeta tableMetas) {
+ protected <E extends TopiaEntity> ImportExportModel<E> buildForSave(TableMeta meta) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(),
- tableMetas);
-
- ModelBuilder<E> modelBuilder = model.modelBuilder;
-
- modelBuilder.newColumnForImportExport(
- TopiaEntity.TOPIA_ID,
+ EntityCsvModel<E> model = EntityCsvModel.newModel(
+ getConfiguration().getCsvSeparator(),
+ meta,
TopiaEntity.TOPIA_ID
);
- for (ColumnMeta columnMeta : model.tableMeta) {
+ for (ColumnMeta columnMeta : meta) {
String propertyName = columnMeta.getName();
Class<?> type = columnMeta.getType();
if (columnMeta.isFK()) {
Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
- model.addForeignKeyForExport(propertyName, entityType);
+ Collection<TopiaEntity> universe = getForeignDatas(entityType);
+
+ // translate foreign key to his id
+ model.addForeignKeyForImport(propertyName, entityType, universe);
+
} else {
model.addDefaultColumn(propertyName, type);
}
@@ -552,20 +530,16 @@
return model;
}
- protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForLoad(TableMeta tableMetas,
- boolean addDecorated) {
+ protected <E extends TopiaEntity> ImportExportModel<E> buildForLoad(TableMeta meta,
+ boolean addDecorated) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(),
- tableMetas);
-
- ModelBuilder<E> modelBuilder = model.modelBuilder;
-
- modelBuilder.newColumnForImportExport(
- "id",
- TopiaEntity.TOPIA_ID
+ EntityCsvModel<E> model = EntityCsvModel.newModel(
+ getConfiguration().getCsvSeparator(),
+ meta,
+ "id"
);
- for (ColumnMeta columnMeta : model.tableMeta) {
+ for (ColumnMeta columnMeta : meta) {
String propertyName = columnMeta.getName();
Class<?> type = columnMeta.getType();
if (columnMeta.isFK()) {
@@ -578,7 +552,7 @@
if (addDecorated) {
// translate foreign key to his decorated value
- modelBuilder.newColumnForExport(
+ model.addNewColumnForExport(
propertyName + "_lib",
propertyName,
CsvModelUtil.newForeignKeyDecoratedValue(
@@ -594,5 +568,4 @@
}
return model;
}
-
}
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportExportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportExportService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportExportService.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -0,0 +1,441 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EntitiesUtil;
+import fr.ifremer.echobase.entities.meta.AssociationMeta;
+import fr.ifremer.echobase.entities.meta.TableMeta;
+import fr.ifremer.echobase.services.models.EntityAssociationCsvModel;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.csv.Export;
+import org.nuiton.util.csv.Import;
+import org.nuiton.util.csv.ImportExportModel;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * Service to import / export a complete db.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class DbImportExportService extends EchoBaseServiceSupport {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(DbImportExportService.class);
+
+ protected DbEditorService dbEditorService;
+
+ /**
+ * Import a complete db from the given zip file.
+ *
+ * @param file zip file where all csv files are located
+ * @param user user which perform the import
+ * @throws IOException if any io exception while import
+ */
+ public void importDb(File file, EchoBaseUser user) throws IOException {
+
+ ZipFile zipFile = new ZipFile(file);
+ try {
+ FileEntry[] entries = getEntries();
+
+ List<String> missingEntries = Lists.newArrayList();
+
+ Map<FileEntry, ZipEntry> entriestoConsume = Maps.newLinkedHashMap();
+
+ // check that all mandatories
+ for (FileEntry entry : entries) {
+ String filename = entry.getFilename();
+ ZipEntry zipEntry = zipFile.getEntry(filename);
+
+ if (zipEntry == null) {
+ missingEntries.add(filename);
+ } else {
+ entriestoConsume.put(entry, zipEntry);
+ }
+ }
+
+ if (!missingEntries.isEmpty()) {
+
+ // there is some missing file entries
+ throw new EchoBaseTechnicalException(
+ "There is some missing mandatory files " +
+ missingEntries + " in import " + file);
+ }
+
+ // consume all found entries
+ for (Map.Entry<FileEntry, ZipEntry> entry :
+ entriestoConsume.entrySet()) {
+
+ FileEntry entryDef = entry.getKey();
+ ZipEntry value = entry.getValue();
+ CsvImportResult csvResult = CsvImportResult.newResult(
+ entryDef.getSource(),
+ value.getName(),
+ false
+ );
+ Reader reader =
+ new InputStreamReader(zipFile.getInputStream(value));
+ try {
+ importFile(entryDef, reader, csvResult);
+ } finally {
+ reader.close();
+ }
+ }
+
+ // add a log entry of import db
+ if (log.isInfoEnabled()) {
+ log.info("Import done with user " + user.getEmail());
+ }
+ commitTransaction("Could not commit db import " + file);
+ } finally {
+ zipFile.close();
+ }
+ }
+
+ /**
+ * Export the complete db into csv files stored in a zip archive file.
+ *
+ * @param fileName file name of the zip to create
+ * @return the zip archive file
+ */
+ public File exportDb(String fileName) {
+ File tempDirectory = new File(FileUtils.getTempDirectory(),
+ "echobase-exportDb_" + System.nanoTime());
+ tempDirectory.deleteOnExit();
+
+ File zipFile = new File(tempDirectory, fileName + ".zip");
+
+ FileEntry[] entries = getEntries();
+ for (FileEntry entry : entries) {
+
+ EchoBaseEntityEnum source = entry.getSource();
+
+ File entryFile = new File(tempDirectory, entry.getFilename());
+
+ List<TopiaEntity> entities = entry.getDatas(getTransaction());
+ if (log.isInfoEnabled()) {
+ log.info("Export " + entities + " entities of type " +
+ source + " to " + entryFile);
+ }
+
+ exportFile(entry, entryFile, entities);
+ }
+
+ compressZipFile(zipFile, tempDirectory);
+
+ return zipFile;
+ }
+
+ protected void importFile(FileEntry entry,
+ Reader reader,
+ CsvImportResult csvResult) throws IOException {
+
+ EchoBaseEntityEnum source = entry.getSource();
+
+ DbEditorService service = getDbEditorService();
+
+ TableMeta tableMeta = getTableMeta(source);
+
+ if (entry.isAssociation()) {
+
+ // load a association input
+
+ AssociationMeta associationMeta =
+ tableMeta.getAssociations(entry.getPropertyName());
+
+ ImportExportModel<TopiaEntity> model =
+ EntityAssociationCsvModel.newModel(
+ getConfiguration().getCsvSeparator(),
+ associationMeta
+ );
+
+ importEntityAssociation(associationMeta, model, csvResult, reader);
+
+ } else {
+
+ // normal entity table import
+
+ ImportExportModel<TopiaEntity> model = service.buildForImport(tableMeta);
+
+ importEntities(tableMeta, model, csvResult, reader);
+ }
+ }
+
+ protected void exportFile(FileEntry entry,
+ File entryFile,
+ List<TopiaEntity> entities) {
+ ImportExportModel<TopiaEntity> model;
+
+ TableMeta meta = getTableMeta(entry.getSource());
+
+ if (entry.isAssociation()) {
+ AssociationMeta associationMeta =
+ meta.getAssociations(entry.getPropertyName());
+
+ model = EntityAssociationCsvModel.newModel(
+ getConfiguration().getCsvSeparator(),
+ associationMeta
+ );
+
+ } else {
+
+ model = getDbEditorService().buildForExport(meta);
+ }
+
+ Export<TopiaEntity> export = Export.newExport(model, entities);
+
+ try {
+ String entryFileContent = export.startExportAsString();
+ FileUtil.writeString(entryFile, entryFileContent, "utf-8");
+ } catch (Exception eee) {
+ throw new EchoBaseTechnicalException("Can not export datas", eee);
+ }
+ }
+
+
+ protected TableMeta getTableMeta(EchoBaseEntityEnum tableName) {
+ return getDbEditorService().getTableMeta(tableName);
+ }
+
+ public FileEntry[] getEntries() {
+
+ List<FileEntry> result = Lists.newArrayList();
+
+ addEntries(result, EntitiesUtil.getReferenceTypesForCopy());
+ addEntries(result, EntitiesUtil.getDataTypesforCopy());
+ return result.toArray(new FileEntry[result.size()]);
+ }
+
+ protected void addEntries(List<FileEntry> result, EchoBaseEntityEnum[] types) {
+ for (EchoBaseEntityEnum type : types) {
+
+ TableMeta tableMeta = getTableMeta(type);
+
+ result.add(FileEntry.newEntry(tableMeta));
+
+ for (AssociationMeta associationMeta : tableMeta.getAssociations()) {
+ result.add(FileEntry.newEntry(associationMeta));
+ }
+
+ }
+ }
+
+ protected DbEditorService getDbEditorService() {
+ if (dbEditorService == null) {
+ dbEditorService = newService(DbEditorService.class);
+ }
+ return dbEditorService;
+ }
+
+ public void importEntities(TableMeta meta,
+ ImportExportModel<TopiaEntity> csvModel,
+ CsvImportResult result,
+ Reader reader) {
+
+ Import<TopiaEntity> importer = Import.newImport(csvModel, reader);
+
+
+ try {
+ TopiaDAO<TopiaEntity> dao = getDAO(meta.getEntityEnum());
+
+ for (TopiaEntity entity : importer) {
+
+
+ TopiaEntity entityToSave = dao.create(TopiaEntity.TOPIA_ID,
+ entity.getTopiaId());
+
+ meta.copy(entity, entityToSave);
+
+ result.incrementsNumberUpdated();
+ }
+ } catch (Exception eee) {
+ throw new EchoBaseTechnicalException("Could not import entities of type " + meta.getEntityEnum(), eee);
+ } finally {
+
+ importer.close();
+ }
+ }
+
+ protected <E extends TopiaEntity> void importEntityAssociation(AssociationMeta meta,
+ ImportExportModel<E> csvModel,
+ CsvImportResult result,
+ Reader reader) {
+
+ try {
+
+ EchoBaseEntityEnum sourceType = meta.getSource();
+ EchoBaseEntityEnum targetType = meta.getTarget();
+
+ Import<E> importer = Import.newImport(csvModel, reader);
+ TopiaDAO<TopiaEntity> sourceDAO = getDAO(sourceType);
+ TopiaDAO<TopiaEntity> targetDAO = getDAO(targetType);
+
+ try {
+ for (E row : importer) {
+
+ TopiaEntity entityToSave =
+ sourceDAO.findByTopiaId(row.getTopiaId());
+
+ // check entity exits ?
+ if (entityToSave == null) {
+ throw new EchoBaseTechnicalException(
+ "Could not find entity with id " + row.getTopiaId());
+ }
+ Collection<TopiaEntity> assoc = meta.getChilds(row);
+ Collection<TopiaEntity> associationToSave = Lists.newArrayList();
+ for (TopiaEntity topiaEntity : assoc) {
+ TopiaEntity byTopiaId = targetDAO.findByTopiaId(topiaEntity.getTopiaId());
+ if (byTopiaId == null) {
+ throw new EchoBaseTechnicalException(
+ "Could not find entity with id " + topiaEntity.getTopiaId());
+ }
+ associationToSave.add(byTopiaId);
+ result.incrementsNumberUpdated();
+ }
+ meta.setChilds(entityToSave, associationToSave);
+ }
+ } finally {
+
+ importer.close();
+ }
+
+ commitTransaction("Could not commit transaction");
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+
+ public static class FileEntry {
+
+ public static FileEntry newEntry(TableMeta tableMeta) {
+ return newEntry(tableMeta.getEntityEnum(), null, null);
+ }
+
+ public static FileEntry newEntry(AssociationMeta tableMeta) {
+ return newEntry(tableMeta.getSource(), tableMeta.getTarget(), tableMeta.getName());
+ }
+
+ public static FileEntry newEntry(EchoBaseEntityEnum source,
+ EchoBaseEntityEnum target,
+ String propertyName) {
+ return new FileEntry(source, target, propertyName);
+ }
+
+ final EchoBaseEntityEnum source;
+
+ final EchoBaseEntityEnum target;
+
+ final String propertyName;
+
+ protected CsvImportResult importResult;
+
+ FileEntry(EchoBaseEntityEnum source,
+ EchoBaseEntityEnum target,
+ String propertyName) {
+
+ this.source = source;
+ this.target = target;
+ this.propertyName = propertyName;
+ }
+
+ public EchoBaseEntityEnum getSource() {
+ return source;
+ }
+
+ public EchoBaseEntityEnum getTarget() {
+ return target;
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public boolean isAssociation() {
+ return target != null && propertyName != null;
+ }
+
+ public String getFilename() {
+ String result;
+ if (isAssociation()) {
+ result = source.name() + "_" + propertyName + "_" + target.name();
+ } else {
+ result = source.name();
+ }
+ return result + ".csv";
+ }
+
+ public CsvImportResult getImportResult() {
+ return importResult;
+ }
+
+ public void setImportResult(CsvImportResult importResult) {
+ this.importResult = importResult;
+ }
+
+ public List<TopiaEntity> getDatas(TopiaContext transaction) {
+
+ try {
+ TopiaDAO<TopiaEntity> dao = EchoBaseDAOHelper.<TopiaEntity, TopiaDAO<TopiaEntity>>getDAO(transaction, (Class<TopiaEntity>) source.getContract());
+
+ List<TopiaEntity> result;
+ if (isAssociation()) {
+
+ // filter only entities with some data in the association
+ TopiaQuery query = dao.createQuery("e");
+ query.addWhere("size(e." + propertyName + ") > 0");
+ result = dao.findAllByQuery(query);
+ } else {
+ result = dao.findAll();
+ }
+ return result;
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException("Could not obtain datas for " + this, eee);
+ }
+ }
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportExportService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -64,7 +64,7 @@
Preconditions.checkNotNull(
decorator,
"Could not find decorator for type " + type +
- " and context " + context
+ " and context " + context
);
return decorator;
}
@@ -107,7 +107,7 @@
Preconditions.checkNotNull(
decorator,
"Could not find decorator for type " + object.getClass() +
- " and context " + context
+ " and context " + context
);
DecoratorUtil.sort((JXPathDecorator<O>) decorator, list, 0);
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -52,10 +52,10 @@
EchoBaseServiceContext serviceContext,
TopiaContext transaction) {
return newContext(serviceContext.getLocale(),
- transaction,
- serviceContext.getConfiguration(),
- serviceContext.getDbMeta(),
- serviceContext.getServiceFactory()
+ transaction,
+ serviceContext.getConfiguration(),
+ serviceContext.getDbMeta(),
+ serviceContext.getServiceFactory()
);
}
@@ -66,10 +66,10 @@
DbMeta dbMeta,
EchoBaseServiceFactory serviceFactory) {
return new EchoBaseServiceContextImpl(locale,
- transaction,
- configuration,
- dbMeta,
- serviceFactory);
+ transaction,
+ configuration,
+ dbMeta,
+ serviceFactory);
}
protected EchoBaseServiceContextImpl(Locale locale,
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -35,7 +35,11 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.ZipUtil;
+import java.io.File;
+import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Locale;
@@ -73,7 +77,7 @@
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(
"Could not obtain data of id [" + id + "] for type " +
- entityType, eee);
+ entityType, eee);
}
}
@@ -125,4 +129,15 @@
return result;
}
+ protected void compressZipFile(File zipFile, File directory) {
+ try {
+ ZipUtil.compress(zipFile, directory);
+ } catch (IOException eee) {
+ throw new EchoBaseTechnicalException(
+ "Can not create zip file " + zipFile, eee);
+ } finally {
+ FileUtil.deleteRecursively(directory);
+ }
+ }
+
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -39,13 +39,8 @@
import org.nuiton.topia.replication.TopiaReplicationService;
import org.nuiton.topia.replication.model.ReplicationModel;
import org.nuiton.util.FileUtil;
-import org.nuiton.util.ZipUtil;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
import java.net.URISyntaxException;
import java.util.List;
@@ -88,7 +83,7 @@
File warLocation = getConfiguration().getWarLocation();
File tempDirectory = new File(FileUtils.getTempDirectory(),
- "echobase-embedded_" + System.nanoTime());
+ "echobase-embedded_" + System.nanoTime());
tempDirectory.deleteOnExit();
File zipDirectory = new File(tempDirectory, fileName);
@@ -97,7 +92,7 @@
if (log.isInfoEnabled()) {
log.info("Creates zip file [" + zipFile + "] from directory " +
- zipDirectory);
+ zipDirectory);
}
try {
// create /
@@ -118,19 +113,11 @@
} catch (Exception eee) {
throw new EchoBaseTechnicalException(
"Could not create zip structure at location " +
- zipDirectory, eee);
+ zipDirectory, eee);
}
+ compressZipFile(zipFile, zipDirectory);
- try {
- ZipUtil.compress(zipFile, zipDirectory);
- } catch (IOException eee) {
- throw new EchoBaseTechnicalException(
- "Can not create zip file " + zipFile, eee);
- } finally {
- FileUtil.deleteRecursively(zipDirectory);
- }
-
return zipFile;
}
@@ -193,7 +180,7 @@
// create new service context (with new transaction)
EchoBaseServiceContext newServiceContext =
EchoBaseServiceContextImpl.newContext(serviceContext,
- topiaContext);
+ topiaContext);
// get user service from h2 db
UserService userService =
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -1,85 +0,0 @@
-/*
- * #%L
- * EchoBase :: Services
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.echobase.services;
-
-import org.nuiton.util.csv.ExportableColumn;
-import org.nuiton.util.csv.ImportExportModel;
-import org.nuiton.util.csv.ImportableColumn;
-import org.nuiton.util.csv.ModelBuilder;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Csv model to export sql in {@link ExportSqlService}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class ExportSqlCsvModel implements ImportExportModel<Map<String, Object>> {
-
-
- protected final char separator;
-
- protected final ModelBuilder<?> modelBuilder;
-
- public ExportSqlCsvModel(char separator, String[] columnHeaders) {
- this.separator = separator;
- modelBuilder = new ModelBuilder<Object>();
- for (String columnHeader : columnHeaders) {
- modelBuilder.newColumnForExport(
- columnHeader,
- columnHeader,
- CsvModelUtil.TO_STRING_FORMATTER
- );
- }
- }
-
- @Override
- public char getSeparator() {
- return separator;
- }
-
- @Override
- public Collection<ExportableColumn<Map<String, Object>, Object>> getColumnsForExport() {
- return (Collection) modelBuilder.getColumnsForExport();
- }
-
- @Override
- public Collection<ImportableColumn<Map<String, Object>, Object>> getColumnsForImport() {
- // never do import from this model
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void pushCsvHeaderNames(List<String> headerNames) {
- }
-
- @Override
- public Map<String, Object> newEmptyInstance() {
- // never do import from this model
- throw new UnsupportedOperationException();
- }
-}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -26,6 +26,7 @@
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.ExportQuery;
+import fr.ifremer.echobase.services.models.ExportSqlCsvModel;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -72,7 +73,7 @@
entityToSave.setDescription(exportQuery.getDescription());
entityToSave.setSqlQuery(exportQuery.getSqlQuery());
entityToSave.setLastModifiedDate(newDate());
- entityToSave.setLastModifiedUser(user);
+ entityToSave.setLastModifiedUser(user.getEmail());
dao.update(entityToSave);
getTransaction().commitTransaction();
@@ -103,7 +104,8 @@
sqlQuery.getResult(getTransaction());
return result.toArray(new Map[result.size()]);
} catch (TopiaException eee) {
- throw new EchoBaseTechnicalException("Could not execute sql query", eee);
+ throw new EchoBaseTechnicalException(
+ "Could not execute sql query", eee);
}
}
@@ -121,7 +123,8 @@
String[] result = sqlQuery.getColumnNames(getTransaction());
return result;
} catch (TopiaException eee) {
- throw new EchoBaseTechnicalException("Could not execute query " + limitSql, eee);
+ throw new EchoBaseTechnicalException(
+ "Could not execute query " + limitSql, eee);
}
}
@@ -132,7 +135,8 @@
try {
rows = sqlQuery.getResult(getTransaction());
} catch (TopiaException eee) {
- throw new EchoBaseTechnicalException("Could not execute sql query", eee);
+ throw new EchoBaseTechnicalException(
+ "Could not execute sql query", eee);
}
char csvSeparator = getConfiguration().getCsvSeparator();
ExportSqlCsvModel csvModel = sqlQuery.generateCsvModel(csvSeparator);
@@ -217,7 +221,7 @@
// get row number (getRow() begins at 1)
int rowNumber = set.getRow() - 1;
if (rowNumber < pager.getStartIndex() ||
- rowNumber >= pager.getEndIndex()) {
+ rowNumber >= pager.getEndIndex()) {
// out of pager bound, by returning null
// result will not be take in account
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -49,7 +49,7 @@
try {
Mission result = getDAO(Mission.class).create(mission);
commitTransaction("Could not create mission " +
- mission.getMissionName());
+ mission.getMissionName());
return result;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
@@ -72,7 +72,7 @@
default:
throw new IllegalStateException(
"Can not know what to do with importDataMode " +
- importDataMode);
+ importDataMode);
}
@@ -90,7 +90,7 @@
if (log.isInfoEnabled()) {
log.info("Starts data import with mission " +
- mission.getMissionName());
+ mission.getMissionName());
}
InputFile acousticFile = configuration.getAcousticFile();
@@ -118,7 +118,7 @@
if (log.isInfoEnabled()) {
log.info("Starts data import with mission " +
- mission.getMissionName());
+ mission.getMissionName());
}
InputFile acousticFile = configuration.getAcousticFile();
@@ -208,9 +208,9 @@
InputFile importFile) {
if (log.isInfoEnabled()) {
log.info("Starts " + importFile.getLabel() + " with file " +
- importFile.getFile());
+ importFile.getFile());
}
- CsvImportResult result = new CsvImportResult();
+ CsvImportResult result = CsvImportResult.newResult(null, importFile.getFileName(), false);
prepareImport();
return result;
}
@@ -219,9 +219,9 @@
InputFile importFile) {
if (log.isInfoEnabled()) {
log.info("Starts " + importFile.getLabel() + " with file " +
- importFile.getFile());
+ importFile.getFile());
}
- CsvImportResult result = new CsvImportResult();
+ CsvImportResult result = CsvImportResult.newResult(null, importFile.getFileName(), false);
prepareImport();
return result;
}
@@ -230,9 +230,9 @@
InputFile importFile) {
if (log.isInfoEnabled()) {
log.info("Starts " + importFile.getLabel() + " with file " +
- importFile.getFile());
+ importFile.getFile());
}
- CsvImportResult result = new CsvImportResult();
+ CsvImportResult result = CsvImportResult.newResult(null, importFile.getFileName(), false);
prepareImport();
return result;
}
@@ -241,9 +241,9 @@
InputFile importFile) {
if (log.isInfoEnabled()) {
log.info("Starts " + importFile.getLabel() + " with file " +
- importFile.getFile());
+ importFile.getFile());
}
- CsvImportResult result = new CsvImportResult();
+ CsvImportResult result = CsvImportResult.newResult(null, importFile.getFileName(), false);
prepareImport();
return result;
}
@@ -252,9 +252,9 @@
InputFile importFile) {
if (log.isInfoEnabled()) {
log.info("Starts " + importFile.getLabel() + " with file " +
- importFile.getFile());
+ importFile.getFile());
}
- CsvImportResult result = new CsvImportResult();
+ CsvImportResult result = CsvImportResult.newResult(null, importFile.getFileName(), false);
prepareImport();
return result;
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalService.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalService.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -50,7 +50,7 @@
if (log.isInfoEnabled()) {
log.info("Starts historical import with file " +
- input.getFileName());
+ input.getFileName());
}
try {
@@ -65,7 +65,7 @@
protected CsvImportResult doImport(InputFile input) {
- CsvImportResult result = new CsvImportResult();
+ CsvImportResult result = CsvImportResult.newResult(null, input.getFileName(), false);
prepareImport();
return result;
}
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/CsvModelUtil.java (from rev 139, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvModelUtil.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/CsvModelUtil.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/CsvModelUtil.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -0,0 +1,185 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services.models;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.services.DecoratorService;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.ObjectUtil;
+import org.nuiton.util.StringUtil;
+import org.nuiton.util.csv.Common;
+import org.nuiton.util.csv.ValueFormatter;
+import org.nuiton.util.csv.ValueParserFormatter;
+
+import java.text.ParseException;
+import java.util.Collection;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Usefull class to build csv import-export models.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class CsvModelUtil extends Common {
+
+ public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type) {
+ return new ForeignKeyValue<E>(type);
+ }
+
+ public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type, Collection<E> entitites) {
+ return new ForeignKeyValue<E>(type, entitites);
+ }
+
+ public static <E extends TopiaEntity> ForeignKeyDecoratedValue<E> newForeignKeyDecoratedValue(Class<E> entityType,
+ DecoratorService decoratorService, Locale locale) {
+ return new ForeignKeyDecoratedValue<E>(entityType, decoratorService, locale);
+ }
+
+ public static <E extends TopiaEntity> AssociationValueParserFormatter<E> newAssociationValueParserFormatter(Class<E> type) {
+ return new AssociationValueParserFormatter<E>(type);
+ }
+
+ public static class AssociationValueParserFormatter<E extends TopiaEntity> implements ValueParserFormatter<Collection<E>> {
+
+ protected final Class<E> entityType;
+
+ public AssociationValueParserFormatter(Class<E> entityType) {
+ this.entityType = entityType;
+ }
+
+ @Override
+ public Collection<E> parse(String value) throws ParseException {
+ Collection<E> result = Lists.newArrayList();
+ if (StringUtils.isNotBlank(value)) {
+
+ String[] ids = value.split("|");
+ for (String id : ids) {
+ E association = ObjectUtil.newInstance(entityType);
+ association.setTopiaId(id);
+ result.add(association);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String format(Collection<E> e) {
+ if (CollectionUtils.isEmpty(e)) {
+ return "";
+ }
+ Collection<String> ids = Lists.newArrayList();
+ for (E e1 : e) {
+ ids.add(e1.getTopiaId());
+ }
+ String value = StringUtil.join(ids, "|", true);
+ return value;
+ }
+ }
+
+ public static class ForeignKeyValue<E extends TopiaEntity> implements ValueParserFormatter<E> {
+
+ protected final Class<E> entityType;
+
+ protected final Map<String, E> universe;
+
+ public ForeignKeyValue(Class<E> entityType, Collection<E> entitites) {
+ this.entityType = entityType;
+ universe = Maps.uniqueIndex(entitites, new Function<E, String>() {
+ @Override
+ public String apply(E input) {
+ return input.getTopiaId();
+ }
+ });
+ }
+
+ public ForeignKeyValue(Class<E> entityType) {
+ this.entityType = entityType;
+ universe = Maps.newHashMap();
+ }
+
+ @Override
+ public E parse(String value) throws ParseException {
+ E result = null;
+ if (StringUtils.isNotBlank(value)) {
+
+ // get entity from universe
+ result = universe.get(value);
+
+ if (result == null) {
+
+ // can not find entity this is a big problem for us...
+ throw new EchoBaseTechnicalException(
+ "Could not find entity with name " + value);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String format(E e) {
+ String value = "";
+ if (e != null) {
+ value = e.getTopiaId();
+ }
+ return value;
+ }
+ }
+
+ public static class ForeignKeyDecoratedValue<E extends TopiaEntity> implements ValueFormatter<E> {
+
+ protected final Class<E> entityType;
+
+ protected final DecoratorService decoratorService;
+
+ protected final Locale locale;
+
+ public ForeignKeyDecoratedValue(Class<E> entityType, DecoratorService decoratorService, Locale locale) {
+ this.entityType = entityType;
+ this.decoratorService = decoratorService;
+ this.locale = locale;
+
+ }
+
+ @Override
+ public String format(E e) {
+ String value = "";
+ if (e != null) {
+
+ value = decoratorService.decorate(locale, e, null);
+ }
+ return value;
+ }
+ }
+
+ protected CsvModelUtil() {
+ // avoid instanciation on helper class
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/CsvModelUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityAssociationCsvModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityAssociationCsvModel.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityAssociationCsvModel.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -0,0 +1,102 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services.models;
+
+import fr.ifremer.echobase.entities.meta.AssociationMeta;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.csv.ExportableColumn;
+import org.nuiton.util.csv.ImportExportModel;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * A model to import / export associations of entities into csv files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class EntityAssociationCsvModel<E extends TopiaEntity> implements ImportExportModel<E> {
+
+ protected final char separator;
+
+ protected final AssociationMeta meta;
+
+ protected ModelBuilder<E> modelBuilder;
+
+ public static <E extends TopiaEntity> EntityAssociationCsvModel<E> newModel(char separator,
+ AssociationMeta meta) {
+ return new EntityAssociationCsvModel<E>(separator, meta);
+ }
+
+ @Override
+ public char getSeparator() {
+ return separator;
+ }
+
+ @Override
+ public Collection<ExportableColumn<E, Object>> getColumnsForExport() {
+ return (Collection)
+ modelBuilder.getColumnsForExport();
+ }
+
+ @Override
+ public Collection<ImportableColumn<E, Object>> getColumnsForImport() {
+ return (Collection)
+ modelBuilder.getColumnsForImport();
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> headerNames) {
+ }
+
+ @Override
+ public E newEmptyInstance() {
+ return (E) meta.newEntity();
+ }
+
+ protected EntityAssociationCsvModel(char separator,
+ AssociationMeta meta) {
+ this.separator = separator;
+ this.meta = meta;
+ modelBuilder = new ModelBuilder<E>();
+
+ // topiaId <-> topiaId
+ modelBuilder.newColumnForImportExport(
+ TopiaEntity.TOPIA_ID,
+ TopiaEntity.TOPIA_ID
+ );
+
+ // add association -> target
+ modelBuilder.newColumnForImportExport(
+ meta.getName(),
+ meta.getName(),
+ CsvModelUtil.newAssociationValueParserFormatter(meta.getTarget().getImplementation())
+ );
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityAssociationCsvModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityCsvModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityCsvModel.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityCsvModel.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -0,0 +1,184 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services.models;
+
+import fr.ifremer.echobase.entities.meta.TableMeta;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.csv.ExportableColumn;
+import org.nuiton.util.csv.ImportExportModel;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * A model to import / export entities into csv files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class EntityCsvModel<E extends TopiaEntity> implements ImportExportModel<E> {
+
+ protected final char separator;
+
+ protected final TableMeta tableMeta;
+
+ protected ModelBuilder<E> modelBuilder;
+
+ public static <E extends TopiaEntity> EntityCsvModel<E> newModel(
+ char separator,
+ TableMeta tableMeta,
+ String idHeader
+ ) {
+ return new EntityCsvModel<E>(separator, tableMeta, idHeader);
+ }
+
+ @Override
+ public char getSeparator() {
+ return separator;
+ }
+
+ @Override
+ public Collection<ExportableColumn<E, Object>> getColumnsForExport() {
+ return (Collection)
+ modelBuilder.getColumnsForExport();
+ }
+
+ @Override
+ public Collection<ImportableColumn<E, Object>> getColumnsForImport() {
+ return (Collection)
+ modelBuilder.getColumnsForImport();
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> headerNames) {
+ }
+
+ @Override
+ public E newEmptyInstance() {
+ return (E) tableMeta.newEntity();
+ }
+
+ public void addForeignKeyForExport(String propertyName,
+ Class<TopiaEntity> entityType) {
+
+ modelBuilder.newColumnForExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.newForeignKeyValue(entityType)
+ );
+ }
+
+ public void addForeignKeyForImport(String propertyName,
+ Class<TopiaEntity> entityType,
+ Collection<TopiaEntity> universe) {
+
+ modelBuilder.newMandatoryColumn(
+ propertyName,
+ propertyName,
+ CsvModelUtil.newForeignKeyValue(entityType, universe)
+ );
+ }
+
+ public void addNewColumnForExport(String headerName,
+ String propertyName,
+ CsvModelUtil.ForeignKeyDecoratedValue<TopiaEntity> topiaEntityForeignKeyDecoratedValue) {
+ modelBuilder.newColumnForExport(
+ headerName,
+ propertyName,
+ topiaEntityForeignKeyDecoratedValue
+ );
+ }
+
+ public void addDefaultColumn(String propertyName,
+ Class<?> type) {
+
+ if (Date.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.DAY_TIME_SECOND
+ );
+ } else if (float.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.PRIMITIVE_FLOAT
+ );
+ } else if (Float.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.FLOAT
+ );
+ } else if (int.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.PRIMITIVE_INTEGER
+ );
+ } else if (Integer.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.INTEGER
+ );
+ } else if (boolean.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.PRIMITIVE_BOOLEAN
+ );
+ } else if (Boolean.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.BOOLEAN
+ );
+ } else {
+
+ // string
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName
+ );
+ }
+ }
+
+ protected EntityCsvModel(char separator,
+ TableMeta tableMeta,
+ String idHeader) {
+ this.separator = separator;
+ this.tableMeta = tableMeta;
+ modelBuilder = new ModelBuilder<E>();
+ modelBuilder.newColumnForImportExport(
+ idHeader,
+ TopiaEntity.TOPIA_ID
+ );
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityCsvModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ExportSqlCsvModel.java (from rev 139, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ExportSqlCsvModel.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ExportSqlCsvModel.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -0,0 +1,86 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services.models;
+
+import fr.ifremer.echobase.services.ExportSqlService;
+import org.nuiton.util.csv.ExportableColumn;
+import org.nuiton.util.csv.ImportExportModel;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Csv model to export sql in {@link ExportSqlService}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class ExportSqlCsvModel implements ImportExportModel<Map<String, Object>> {
+
+
+ protected final char separator;
+
+ protected final ModelBuilder<?> modelBuilder;
+
+ public ExportSqlCsvModel(char separator, String[] columnHeaders) {
+ this.separator = separator;
+ modelBuilder = new ModelBuilder<Object>();
+ for (String columnHeader : columnHeaders) {
+ modelBuilder.newColumnForExport(
+ columnHeader,
+ columnHeader,
+ CsvModelUtil.TO_STRING_FORMATTER
+ );
+ }
+ }
+
+ @Override
+ public char getSeparator() {
+ return separator;
+ }
+
+ @Override
+ public Collection<ExportableColumn<Map<String, Object>, Object>> getColumnsForExport() {
+ return (Collection) modelBuilder.getColumnsForExport();
+ }
+
+ @Override
+ public Collection<ImportableColumn<Map<String, Object>, Object>> getColumnsForImport() {
+ // never do import from this model
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> headerNames) {
+ }
+
+ @Override
+ public Map<String, Object> newEmptyInstance() {
+ // never do import from this model
+ throw new UnsupportedOperationException();
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ExportSqlCsvModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-services/src/main/resources/echobase-db.properties
===================================================================
--- trunk/echobase-services/src/main/resources/echobase-db.properties 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/main/resources/echobase-db.properties 2011-12-05 08:24:55 UTC (rev 142)
@@ -1,41 +0,0 @@
-###
-# #%L
-# EchoBase :: Services
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2011 Ifremer, Codelutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# #L%
-###
-###
-# DB configuration
-hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
-hibernate.connection.driver_class=org.postgresql.Driver
-hibernate.connection.provider_class=org.nuiton.topia.framework.TopiaConnectionProvider
-hibernate.show_sql=false
-hibernate.format_sql=false
-hibernate.use_sql_comments=false
-hibernate.hbm2ddl.auto=none
-hibernate.connection.username=${configuration.login}
-hibernate.connection.password=${configuration.password}
-hibernate.connection.url=${configuration.url}
-
-# Migration configuration
-topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine
-topia.service.migration.callback=fr.ifremer.echobase.services.migration.EchoBaseMigrationCallback
-topia.service.migration.showSql=true
-
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/TestHelper.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/TestHelper.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/TestHelper.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -23,10 +23,16 @@
*/
package fr.ifremer.echobase;
+import com.google.common.base.Supplier;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import org.apache.commons.io.FileUtils;
import org.junit.Ignore;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.persistence.TopiaEntity;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
/**
* Utility methods for tests
@@ -39,6 +45,8 @@
protected static File basedir;
+ protected static final long timestamp = System.currentTimeMillis();
+
public static File getBasedir() {
//FIXME : No we do not want to go in tmp directory :( We want to stay
// inside of the project. So a mvn clean will remove all tests data.
@@ -53,4 +61,38 @@
return basedir;
}
+ public static File getTestBasedir(Class<?> testClass) {
+ File result = new File(getBasedir(), testClass.getName() + "_" + timestamp);
+ return result;
+ }
+
+ public static TopiaContext getRootContext(File dbDir) {
+ EchoBaseTopiaRootContextSupplierFactory factory =
+ new EchoBaseTopiaRootContextSupplierFactory();
+
+ Supplier<TopiaContext> topiaContextSupplier =
+ factory.newEmbeddedDatabase(dbDir);
+ return topiaContextSupplier.get();
+ }
+
+ /**
+ * Used to get all contract of a package
+ *
+ * @param entitiesPackage package contening desired entities
+ * @return contracts contained in entitiesPackage
+ */
+ public static EchoBaseEntityEnum[] getContractsOf(Package entitiesPackage) {
+ EchoBaseEntityEnum[] echoBaseEntityEnums = EchoBaseEntityEnum.values();
+ List<EchoBaseEntityEnum> refClasses = new ArrayList<EchoBaseEntityEnum>();
+ for (EchoBaseEntityEnum echoBaseEntityEnum : echoBaseEntityEnums) {
+
+ // Get all entities in package fr.ifremer.echobase.entities.references
+ Class<? extends TopiaEntity> contract = echoBaseEntityEnum.getContract();
+ if (entitiesPackage.equals(contract.getPackage())) {
+ refClasses.add(echoBaseEntityEnum);
+ }
+ }
+ return refClasses.toArray(new EchoBaseEntityEnum[refClasses.size()]);
+ }
+
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -50,8 +50,11 @@
public abstract class AbstractEchoBaseServiceTest extends Assert {
protected TopiaContext transaction;
+
protected EchoBaseConfiguration config;
+
protected EchoBaseServiceFactory serviceFactory;
+
protected DbMeta dbMeta;
@After
@@ -92,7 +95,7 @@
if (dbMeta == null) {
List<EchoBaseEntityEnum> entityEnums =
Lists.newArrayList(EchoBaseEntityEnum.values());
- dbMeta = new DbMeta(entityEnums.toArray(new EchoBaseEntityEnum[entityEnums.size()]));
+ dbMeta = DbMeta.newDbMeta(entityEnums);
}
return dbMeta;
}
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/DbImportExportServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/DbImportExportServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/DbImportExportServiceTest.java 2011-12-05 08:24:55 UTC (rev 142)
@@ -0,0 +1,161 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services;
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.TestHelper;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.EntitiesUtil;
+import junit.framework.Assert;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.replication.TopiaReplicationModelBuilder;
+import org.nuiton.topia.replication.model.ReplicationModel;
+import org.nuiton.topia.replication.model.ReplicationNode;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Test the {@link DbImportExportService}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class DbImportExportServiceTest {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(DbImportExportServiceTest.class);
+
+ @Rule
+ public TestName testName = new TestName();
+
+ protected File testdir;
+
+ protected TopiaContext rootContext;
+
+ @Before
+ public void setUp() throws Exception {
+ testdir = new File(TestHelper.getTestBasedir(getClass()),
+ testName.getMethodName());
+ if (log.isInfoEnabled()) {
+ log.info("Test directory = " + testdir);
+ }
+// rootContext = TestHelper.getRootContext(testdir);
+ }
+
+ @Test
+ public void testGetReferentielCopyModel() throws TopiaException {
+
+ EchoBaseEntityEnum[] types = EntitiesUtil.getReferenceTypesForCopy();
+ Set<TopiaEntityEnum> dones = Sets.newHashSet();
+
+ ReplicationModel model = new ReplicationModel(types, false);
+ new TopiaReplicationModelBuilder().initModel(model, false);
+ List<ReplicationNode> order = model.getOrder();
+
+ StringBuilder buffer = new StringBuilder();
+ for (ReplicationNode node : order) {
+ TopiaEntityEnum type = node.getContract();
+ Assert.assertTrue(type + " was already treated.", dones.add(type));
+ Collection<ReplicationNode> dependencies = node.getDependencies().values();
+ for (ReplicationNode dependency : node.getDependencies().values()) {
+ TopiaEntityEnum dependencyType = dependency.getContract();
+ Assert.assertTrue(dependencyType +
+ " was detected as a dependency of node " +
+ type + " but was not still registred",
+ dones.contains(dependencyType));
+ }
+ Collection<ReplicationNode> assocations = node.getAssociations().values();
+ for (ReplicationNode assocation : assocations) {
+ TopiaEntityEnum assocationType = assocation.getContract();
+ Assert.assertTrue(assocationType +
+ " was detected as a association of node " +
+ type + " but was not still registred",
+ dones.contains(assocationType));
+ }
+ buffer.append('\n');
+ buffer.append(type);
+ buffer.append(" - ");
+ buffer.append(dependencies);
+ buffer.append(" - ");
+ buffer.append(assocations);
+ }
+ if (log.isInfoEnabled()) {
+ log.info(buffer.toString());
+ }
+ }
+
+ @Test
+ public void testGetDataCopyModel() throws TopiaException {
+
+ EchoBaseEntityEnum[] types = EntitiesUtil.getDataTypesforCopy();
+ Set<TopiaEntityEnum> dones = Sets.newHashSet();
+
+ ReplicationModel model = new ReplicationModel(types, false);
+ new TopiaReplicationModelBuilder().initModel(model, false);
+ List<ReplicationNode> order = model.getOrder();
+
+ StringBuilder buffer = new StringBuilder();
+ for (ReplicationNode node : order) {
+ TopiaEntityEnum type = node.getContract();
+ Assert.assertTrue(type + " was already treated.", dones.add(type));
+ Collection<ReplicationNode> dependencies = node.getDependencies().values();
+ for (ReplicationNode dependency : node.getDependencies().values()) {
+ TopiaEntityEnum dependencyType = dependency.getContract();
+ Assert.assertTrue(dependencyType +
+ " was detected as a dependency of node " +
+ type + " but was not still registred",
+ dones.contains(dependencyType));
+ }
+ Collection<ReplicationNode> assocations = node.getAssociations().values();
+ for (ReplicationNode assocation : assocations) {
+ TopiaEntityEnum assocationType = assocation.getContract();
+ Assert.assertTrue(assocationType +
+ " was detected as a association of node " +
+ type + " but was not still registred",
+ dones.contains(assocationType));
+ }
+ buffer.append('\n');
+ buffer.append(type);
+ buffer.append(" - ");
+ buffer.append(dependencies);
+ buffer.append(" - ");
+ buffer.append(assocations);
+ }
+ if (log.isInfoEnabled()) {
+ log.info(buffer.toString());
+ }
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/DbImportExportServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-services/src/test/resources/echobase.properties
===================================================================
--- trunk/echobase-services/src/test/resources/echobase.properties 2011-12-05 08:22:27 UTC (rev 141)
+++ trunk/echobase-services/src/test/resources/echobase.properties 2011-12-05 08:24:55 UTC (rev 142)
@@ -1,24 +0,0 @@
-###
-# #%L
-# EchoBase :: Services
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2011 Ifremer, Codelutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# #L%
-###
-data.directory=${java.io.tmpdir}
\ No newline at end of file
1
0
r141 - in trunk/echobase-entities/src: main/java/fr/ifremer/echobase/entities main/java/fr/ifremer/echobase/entities/meta main/resources main/xmi test/resources
by tchemit@users.forge.codelutin.com 05 Dec '11
by tchemit@users.forge.codelutin.com 05 Dec '11
05 Dec '11
Author: tchemit
Date: 2011-12-05 09:22:27 +0100 (Mon, 05 Dec 2011)
New Revision: 141
Url: http://forge.codelutin.com/repositories/revision/echobase/141
Log:
-add AssociationMeta
-denormalize ExportSql and ModificationLog entities (no more FK on EchoBaseUser)
-add replication service configuration (but may not be used...)
-add entities order to import/export global db
Added:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/AssociationMeta.java
Removed:
trunk/echobase-entities/src/test/resources/echobase.properties
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/ExportQueryImpl.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java
trunk/echobase-entities/src/main/resources/topia-h2.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-12-05 06:42:35 UTC (rev 140)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-12-05 08:22:27 UTC (rev 141)
@@ -55,62 +55,115 @@
result.add(EchoBaseEntityEnum.Result);
result.add(EchoBaseEntityEnum.Operation);
result.add(EchoBaseEntityEnum.OperationMetadataValue);
- result.add(EchoBaseEntityEnum.Individual);
result.add(EchoBaseEntityEnum.OperationGearMetadataValue);
result.add(EchoBaseEntityEnum.Sample);
result.add(EchoBaseEntityEnum.SampleData);
- result.add(EchoBaseEntityEnum.SampleAge);
return result.toArray(new EchoBaseEntityEnum[result.size()]);
}
/**
+ * @return the entity types of data in correct order for replication
+ * purpose.
+ */
+ public static EchoBaseEntityEnum[] getDataTypesforCopy() {
+
+ List<EchoBaseEntityEnum> result = Lists.newLinkedList();
+
+ result.add(EchoBaseEntityEnum.SampleData);
+ result.add(EchoBaseEntityEnum.Sample);
+
+ result.add(EchoBaseEntityEnum.OperationMetadataValue);
+ result.add(EchoBaseEntityEnum.OperationGearMetadataValue);
+ result.add(EchoBaseEntityEnum.Operation);
+
+ result.add(EchoBaseEntityEnum.Data);
+ result.add(EchoBaseEntityEnum.Result);
+ result.add(EchoBaseEntityEnum.Cell);
+ result.add(EchoBaseEntityEnum.DataProcessing);
+ result.add(EchoBaseEntityEnum.DataAcquisition);
+ result.add(EchoBaseEntityEnum.TransectAcousticInstrument);
+ result.add(EchoBaseEntityEnum.Transect);
+ result.add(EchoBaseEntityEnum.TransitVessel);
+ result.add(EchoBaseEntityEnum.Transit);
+ result.add(EchoBaseEntityEnum.Voyage);
+
+ return result.toArray(new EchoBaseEntityEnum[result.size()]);
+ }
+
+ /**
* @return the entity types of reference in correct order for replication
* purpose.
*/
public static EchoBaseEntityEnum[] getReferenceTypes() {
List<EchoBaseEntityEnum> result = Lists.newLinkedList();
- result.add(EchoBaseEntityEnum.Mission);
- result.add(EchoBaseEntityEnum.Echotype);
- result.add(EchoBaseEntityEnum.TSParameters);
+ result.add(EchoBaseEntityEnum.MeasureType);
+ result.add(EchoBaseEntityEnum.DataType);
+ result.add(EchoBaseEntityEnum.ReferenceDatumType);
+ result.add(EchoBaseEntityEnum.VesselType);
result.add(EchoBaseEntityEnum.EchotypeCategory);
+ result.add(EchoBaseEntityEnum.Localisation);
+ result.add(EchoBaseEntityEnum.CellMethod);
result.add(EchoBaseEntityEnum.AcousticInstrument);
- result.add(EchoBaseEntityEnum.AreaOfOperation);
- result.add(EchoBaseEntityEnum.Calibration);
- result.add(EchoBaseEntityEnum.Category);
+ result.add(EchoBaseEntityEnum.CategoryType);
+ result.add(EchoBaseEntityEnum.GearType);
result.add(EchoBaseEntityEnum.CategoryMeaning);
- result.add(EchoBaseEntityEnum.CategoryRef);
- result.add(EchoBaseEntityEnum.CategoryType);
- result.add(EchoBaseEntityEnum.CellMethod);
- result.add(EchoBaseEntityEnum.CellType);
- result.add(EchoBaseEntityEnum.DataMetadata);
- result.add(EchoBaseEntityEnum.DataType);
- result.add(EchoBaseEntityEnum.DataQuality);
- result.add(EchoBaseEntityEnum.DepthStratum);
+ result.add(EchoBaseEntityEnum.Species);
result.add(EchoBaseEntityEnum.DepthStratumType);
- result.add(EchoBaseEntityEnum.Gear);
result.add(EchoBaseEntityEnum.GearCaracteristic);
+ result.add(EchoBaseEntityEnum.ReferenceDatum);
+ result.add(EchoBaseEntityEnum.DepthStratum);
+ result.add(EchoBaseEntityEnum.Category);
+ result.add(EchoBaseEntityEnum.ReferencingMethod);
+ result.add(EchoBaseEntityEnum.GearMetadataValue);
result.add(EchoBaseEntityEnum.GearMetadata);
- result.add(EchoBaseEntityEnum.GearMetadataValue);
- result.add(EchoBaseEntityEnum.GearType);
+ result.add(EchoBaseEntityEnum.Calibration);
+ result.add(EchoBaseEntityEnum.OperationType);
+ result.add(EchoBaseEntityEnum.MeasurementMetadata);
+ result.add(EchoBaseEntityEnum.SampleDataType);
+ result.add(EchoBaseEntityEnum.Vessel);
+ result.add(EchoBaseEntityEnum.SampleRatioType);
+ result.add(EchoBaseEntityEnum.Echotype);
+ result.add(EchoBaseEntityEnum.DataMetadata);
+ result.add(EchoBaseEntityEnum.CellType);
result.add(EchoBaseEntityEnum.Impacte);
- result.add(EchoBaseEntityEnum.Localisation);
- result.add(EchoBaseEntityEnum.MeasurementMetadata);
- result.add(EchoBaseEntityEnum.MeasureType);
+ result.add(EchoBaseEntityEnum.Mission);
result.add(EchoBaseEntityEnum.OperationMetadata);
- result.add(EchoBaseEntityEnum.OperationType);
- result.add(EchoBaseEntityEnum.ReferenceDatum);
- result.add(EchoBaseEntityEnum.ReferenceDatumType);
- result.add(EchoBaseEntityEnum.ReferencingMethod);
+ result.add(EchoBaseEntityEnum.Station);
+ result.add(EchoBaseEntityEnum.AreaOfOperation);
+ result.add(EchoBaseEntityEnum.CategoryRef);
+ result.add(EchoBaseEntityEnum.DataQuality);
result.add(EchoBaseEntityEnum.SampleTag);
- result.add(EchoBaseEntityEnum.SampleDataType);
- result.add(EchoBaseEntityEnum.SampleRatioType);
+ result.add(EchoBaseEntityEnum.TSParameters);
+ result.add(EchoBaseEntityEnum.Gear);
+ return result.toArray(new EchoBaseEntityEnum[result.size()]);
+ }
+
+ /**
+ * @return the entity types of reference in correct order for copy
+ * purpose (says import / export of all a database.
+ */
+ public static EchoBaseEntityEnum[] getReferenceTypesForCopy() {
+ List<EchoBaseEntityEnum> result = Lists.newLinkedList();
+
result.add(EchoBaseEntityEnum.Species);
- result.add(EchoBaseEntityEnum.Station);
+ result.add(EchoBaseEntityEnum.Calibration);
+ result.add(EchoBaseEntityEnum.AcousticInstrument);
+ result.add(EchoBaseEntityEnum.TSParameters);
+ result.add(EchoBaseEntityEnum.VesselType);
result.add(EchoBaseEntityEnum.Vessel);
- result.add(EchoBaseEntityEnum.VesselType);
+ result.add(EchoBaseEntityEnum.Mission);
+ result.add(EchoBaseEntityEnum.DepthStratumType);
+ result.add(EchoBaseEntityEnum.DepthStratum);
+ result.add(EchoBaseEntityEnum.EchotypeCategory);
+ result.add(EchoBaseEntityEnum.Echotype);
+ result.add(EchoBaseEntityEnum.AreaOfOperation);
+ result.add(EchoBaseEntityEnum.ReferenceDatumType);
+ result.add(EchoBaseEntityEnum.ReferenceDatum);
+ result.add(EchoBaseEntityEnum.DataType);
+ result.add(EchoBaseEntityEnum.CellMethod);
+ result.add(EchoBaseEntityEnum.DataMetadata);
return result.toArray(new EchoBaseEntityEnum[result.size()]);
}
-
}
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java 2011-12-05 06:42:35 UTC (rev 140)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java 2011-12-05 08:22:27 UTC (rev 141)
@@ -40,7 +40,7 @@
result.setEntityId(getEntityId());
result.setModificationDate(getModificationDate());
result.setModificationText(getModificationText());
- result.setModificationUser(getModificationUser().toDTO());
+ result.setModificationUser(getModificationUser());
return result;
}
}
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/ExportQueryImpl.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/ExportQueryImpl.java 2011-12-05 06:42:35 UTC (rev 140)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/ExportQueryImpl.java 2011-12-05 08:22:27 UTC (rev 141)
@@ -39,7 +39,7 @@
dto.setDescription(getDescription());
dto.setId(getTopiaId());
dto.setLastModifiedDate(getLastModifiedDate());
- dto.setLastModifiedUser(getLastModifiedUser().toDTO());
+ dto.setLastModifiedUser(getLastModifiedUser());
dto.setName(getName());
dto.setSqlQuery(getSqlQuery());
return dto;
Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/AssociationMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/AssociationMeta.java (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/AssociationMeta.java 2011-12-05 08:22:27 UTC (rev 141)
@@ -0,0 +1,110 @@
+/*
+ * #%L
+ * EchoBase :: Entities
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.entities.meta;
+
+import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.util.EntityOperator;
+import org.nuiton.util.ObjectUtil;
+
+import java.io.Serializable;
+import java.util.Collection;
+
+/**
+ * Define the meta data of a entity association field.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class AssociationMeta implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Association source entity type. */
+ protected EchoBaseEntityEnum source;
+
+ /** Association target entity type. */
+ protected EchoBaseEntityEnum target;
+
+ /** Name fo the association. */
+ protected String name;
+
+ /** Operator of the source entity used to get / set associations. */
+ protected transient EntityOperator<TopiaEntity> operator;
+
+ protected static AssociationMeta newMeta(EchoBaseEntityEnum source,
+ EchoBaseEntityEnum target,
+ String name) {
+ return new AssociationMeta(source, target, name);
+ }
+
+ public AssociationMeta(EchoBaseEntityEnum source,
+ EchoBaseEntityEnum target,
+ String name) {
+ this.source = source;
+ this.target = target;
+ this.name = name;
+ }
+
+ public EchoBaseEntityEnum getSource() {
+ return source;
+ }
+
+ public EchoBaseEntityEnum getTarget() {
+ return target;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public TopiaEntity newEntity() {
+ return ObjectUtil.newInstance(source.getImplementation());
+ }
+
+ public Object newAssociation() {
+ return ObjectUtil.newInstance(target.getImplementation());
+ }
+
+ public Collection<TopiaEntity> getChilds(TopiaEntity entity) {
+ Object o = getOperator().get(name, entity);
+ return (Collection<TopiaEntity>) o;
+ }
+
+ public void setChilds(TopiaEntity entity, Collection<TopiaEntity> childs) {
+ getOperator().addAllChild(name, entity, childs);
+ }
+
+ public EntityOperator<TopiaEntity> getOperator() {
+ if (operator == null) {
+ operator =
+ (EntityOperator<TopiaEntity>)
+ EchoBaseDAOHelper.getOperator(
+ source.getContract());
+ }
+
+ return operator;
+ }
+}
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/AssociationMeta.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java 2011-12-05 06:42:35 UTC (rev 140)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java 2011-12-05 08:22:27 UTC (rev 141)
@@ -23,52 +23,35 @@
*/
package fr.ifremer.echobase.entities.meta;
-import org.hibernate.mapping.Column;
import org.nuiton.topia.persistence.TopiaEntity;
import java.io.Serializable;
import java.util.Date;
/**
- * Define the meta data.
+ * Define the meta data of a entity field.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
public class ColumnMeta implements Serializable {
- protected static ColumnMeta newMeta(String name, String label, Class<?> type) {
- return new ColumnMeta(name, label, type);
+ protected static ColumnMeta newMeta(String name, Class<?> type) {
+ return new ColumnMeta(name, type);
}
private static final long serialVersionUID = 1L;
+ /** Name of the column. */
protected String name;
- protected String i18nKey;
-
- protected Column hibernateColumn;
-
+ /** Type of the column. */
protected Class<?> type;
- public ColumnMeta(String name, Class<?> type) {
- this(name, name, type);
- }
-
- public ColumnMeta(String name, String i18nKey, Class<?> type) {
- this.name = name;
- this.i18nKey = i18nKey;
- this.type = type;
- }
-
public String getName() {
return name;
}
- public String getI18nKey() {
- return i18nKey;
- }
-
public Class<?> getType() {
return type;
}
@@ -99,7 +82,9 @@
return boolean.class.equals(type);
}
- public Column getHibernateColumn() {
- return hibernateColumn;
+ protected ColumnMeta(String name, Class<?> type) {
+ this.name = name;
+ this.type = type;
}
+
}
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java 2011-12-05 06:42:35 UTC (rev 140)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java 2011-12-05 08:22:27 UTC (rev 141)
@@ -43,8 +43,8 @@
protected final EchoBaseEntityEnum[] entityEnums;
- public DbMeta(EchoBaseEntityEnum[] entityEnums) {
- this.entityEnums = entityEnums;
+ public static DbMeta newDbMeta(List<EchoBaseEntityEnum> entityEnums) {
+ return new DbMeta(entityEnums.toArray(new EchoBaseEntityEnum[entityEnums.size()]));
}
public List<String> getTableNames() {
@@ -59,7 +59,7 @@
if (tables == null) {
tables = Lists.newArrayList();
for (EchoBaseEntityEnum entityEnum : entityEnums) {
- TableMeta tableMeta = new TableMeta(entityEnum);
+ TableMeta tableMeta = TableMeta.newMeta(entityEnum);
tables.add(tableMeta);
}
}
@@ -82,4 +82,8 @@
public Iterator<TableMeta> iterator() {
return getTables().iterator();
}
+
+ protected DbMeta(EchoBaseEntityEnum[] entityEnums) {
+ this.entityEnums = entityEnums;
+ }
}
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java 2011-12-05 06:42:35 UTC (rev 140)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java 2011-12-05 08:22:27 UTC (rev 141)
@@ -33,7 +33,6 @@
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderModelBuilder;
-import java.beans.Introspector;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
@@ -48,25 +47,22 @@
private static final long serialVersionUID = 1L;
- protected final String i18nKey;
+ public static TableMeta newMeta(EchoBaseEntityEnum entityEnum) {
+ return new TableMeta(entityEnum);
+ }
- protected final EntityOperator<?> operator;
-
+ /** Type of the entity. */
protected final EchoBaseEntityEnum entityEnum;
+ /** List of columns of the entity. */
protected List<ColumnMeta> columns;
+ /** List of associations of the entity. */
+ protected List<AssociationMeta> associations;
+
+ /** Binder used to copy entities (lazy loaded). */
protected Binder<TopiaEntity, TopiaEntity> binder;
- public TableMeta(EchoBaseEntityEnum entityEnum) {
- Preconditions.checkNotNull(entityEnum);
- this.entityEnum = entityEnum;
- Class<? extends TopiaEntity> contract = entityEnum.getContract();
- i18nKey = "echobase.common." +
- Introspector.decapitalize(contract.getSimpleName());
- operator = EchoBaseDAOHelper.getOperator(contract);
- }
-
public String getName() {
return entityEnum.name();
}
@@ -79,14 +75,6 @@
return entityEnum.getContract();
}
- public String getI18nKey() {
- return i18nKey;
- }
-
- public EntityOperator<?> getOperator() {
- return operator;
- }
-
public ColumnMeta getColumns(String columnName) {
Preconditions.checkNotNull(columnName);
ColumnMeta result = null;
@@ -113,20 +101,22 @@
}
public List<ColumnMeta> getColumns() {
- if (columns == null) {
- columns = Lists.newLinkedList();
- Class<? extends TopiaEntity> contract = entityEnum.getContract();
- EntityOperator<? extends TopiaEntity> operator =
- EchoBaseDAOHelper.getOperator(contract);
- List<String> properties = operator.getProperties();
- for (String property : properties) {
- Class<?> propertyType = operator.getPropertyType(property);
- String i18nKey = "echobase.common." + property;
- ColumnMeta tableMeta = ColumnMeta.newMeta(property, i18nKey, propertyType);
- columns.add(tableMeta);
+ return columns;
+ }
+
+ public List<AssociationMeta> getAssociations() {
+ return associations;
+ }
+
+ public AssociationMeta getAssociations(String name) {
+ AssociationMeta result = null;
+ for (AssociationMeta meta : getAssociations()) {
+ if (name.equals(meta.getName())) {
+ result = meta;
+ break;
}
}
- return columns;
+ return result;
}
public void copy(TopiaEntity source, TopiaEntity target) {
@@ -160,4 +150,46 @@
}
return binder;
}
+
+ protected TableMeta(EchoBaseEntityEnum entityEnum) {
+ Preconditions.checkNotNull(entityEnum);
+ this.entityEnum = entityEnum;
+
+ Class<? extends TopiaEntity> contract = entityEnum.getContract();
+ EntityOperator<? extends TopiaEntity> operator =
+ EchoBaseDAOHelper.getOperator(contract);
+
+ associations = Lists.newArrayList();
+ columns = Lists.newLinkedList();
+
+ // fill associations
+ List<String> associationProperties = operator.getAssociationProperties();
+ for (String property : associationProperties) {
+ Class<?> propertyType = operator.getPropertyType(property);
+ if (TopiaEntity.class.isAssignableFrom(propertyType)) {
+
+ // only use it for entity
+ EchoBaseEntityEnum targetEnum =
+ EchoBaseEntityEnum.valueOf(propertyType);
+
+ AssociationMeta meta = AssociationMeta.newMeta(entityEnum,
+ targetEnum,
+ property
+ );
+ associations.add(meta);
+ }
+ }
+
+ // fill properties (remove all asociations)
+ List<String> properties = Lists.newArrayList(operator.getProperties());
+ properties.removeAll(associationProperties);
+ for (String property : properties) {
+ Class<?> propertyType = operator.getPropertyType(property);
+ ColumnMeta meta = ColumnMeta.newMeta(property,
+ propertyType);
+ columns.add(meta);
+ }
+
+
+ }
}
Modified: trunk/echobase-entities/src/main/resources/topia-h2.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/topia-h2.properties 2011-12-05 06:42:35 UTC (rev 140)
+++ trunk/echobase-entities/src/main/resources/topia-h2.properties 2011-12-05 08:22:27 UTC (rev 141)
@@ -24,6 +24,9 @@
hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
+# Replication configuration
+topia.service.replication=org.nuiton.topia.replication.TopiaReplicationServiceImpl
+
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.connection.username=sa
hibernate.connection.password=sa
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
Deleted: trunk/echobase-entities/src/test/resources/echobase.properties
===================================================================
--- trunk/echobase-entities/src/test/resources/echobase.properties 2011-12-05 06:42:35 UTC (rev 140)
+++ trunk/echobase-entities/src/test/resources/echobase.properties 2011-12-05 08:22:27 UTC (rev 141)
@@ -1,34 +0,0 @@
-###
-# #%L
-# EchoBase :: Entities
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2011 Ifremer, Codelutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# #L%
-###
-hibernate.hbm2ddl.auto=update
-hibernate.show_sql=false
-hibernate.dialect=org.hibernate.dialect.H2Dialect
-
-hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.url=jdbc:h2:file:${data.directory}/echobase/h2data
-hibernate.connection.username=sa
-hibernate.connection.password=sa
-
-war.directory=${data.directory}/war
-war.location=${war.directory}/echobase-ui-${project.version}.war
\ No newline at end of file
1
0
Author: tchemit
Date: 2011-12-05 07:42:35 +0100 (Mon, 05 Dec 2011)
New Revision: 140
Url: http://forge.codelutin.com/repositories/revision/echobase/140
Log:
update dependencies
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-29 12:08:00 UTC (rev 139)
+++ trunk/pom.xml 2011-12-05 06:42:35 UTC (rev 140)
@@ -20,6 +20,7 @@
<modules>
<module>echobase-entities</module>
<module>echobase-services</module>
+ <module>echobase-tools</module>
<module>echobase-ui</module>
</modules>
@@ -107,16 +108,16 @@
<eugenePluginVersion>2.4.1</eugenePluginVersion>
<topiaVersion>2.6.4</topiaVersion>
- <nuitonUtilsVersion>2.4-SNAPSHOT</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.4</nuitonUtilsVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
- <nuitonWebVersion>1.6</nuitonWebVersion>
+ <nuitonWebVersion>1.8</nuitonWebVersion>
<msaccessImporterVersion>1.4.1</msaccessImporterVersion>
<struts2Version>2.2.3.1</struts2Version>
<jqueryPluginVersion>3.2.0</jqueryPluginVersion>
- <seleniumVersion>2.5.0</seleniumVersion>
- <h2Version>1.3.157</h2Version>
- <postgresqlVersion>9.0-801.jdbc4</postgresqlVersion>
- <slf4jVersion>1.6.1</slf4jVersion>
+ <seleniumVersion>2.14.0</seleniumVersion>
+ <h2Version>1.3.162</h2Version>
+ <postgresqlVersion>9.1-901.jdbc4</postgresqlVersion>
+ <slf4jVersion>1.6.4</slf4jVersion>
<jettyVersion>7.5.3.v20111011</jettyVersion>
<!-- This version does not work (missing javax.el api in overlay) -->
<!--<jettyVersion>8.0.1.v20110908</jettyVersion>-->
@@ -298,7 +299,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>10.0</version>
+ <version>10.0.1</version>
</dependency>
<!-- librairies web -->
1
0