Tutti-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
February 2013
- 6 participants
- 236 discussions
r440 - in trunk: . tutti-persistence tutti-service tutti-ui-swing
by maven-release@users.forge.codelutin.com 18 Feb '13
by maven-release@users.forge.codelutin.com 18 Feb '13
18 Feb '13
Author: maven-release
Date: 2013-02-18 08:50:14 +0100 (Mon, 18 Feb 2013)
New Revision: 440
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/440
Log:
[maven-release-plugin] prepare release tutti-1.0
Modified:
trunk/pom.xml
trunk/tutti-persistence/pom.xml
trunk/tutti-service/pom.xml
trunk/tutti-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-02-18 07:43:40 UTC (rev 439)
+++ trunk/pom.xml 2013-02-18 07:50:14 UTC (rev 440)
@@ -21,9 +21,7 @@
#L%
-->
-<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">
+<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>
@@ -35,7 +33,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0</version>
<modules>
<module>tutti-persistence</module>
@@ -91,12 +89,12 @@
</developers>
<scm>
- <url>http://svn.forge.codelutin.com/svn/tutti/trunk</url>
+ <url>http://svn.forge.codelutin.com/svn/tutti/tags/tutti-1.0</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-1.0
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-1.0
</developerConnection>
</scm>
@@ -534,18 +532,15 @@
<inherited>false</inherited>
<configuration>
<tasks>
- <echo message="Copy model to site"/>
- <copy verbose="true" failonerror="false"
- overwrite="true" filtering="true"
- todir="${project.build.directory}/update">
+ <echo message="Copy model to site" />
+ <copy verbose="true" failonerror="false" overwrite="true" filtering="true" todir="${project.build.directory}/update">
<filterset>
- <filter value="${project.version}"
- token="projectVersion"/>
- <filter value="${jreVersion}" token="jreVersion"/>
- <filter value="${dbVersion}" token="dbVersion"/>
+ <filter value="${project.version}" token="projectVersion" />
+ <filter value="${jreVersion}" token="jreVersion" />
+ <filter value="${dbVersion}" token="dbVersion" />
</filterset>
<fileset dir="${basedir}/src/update/">
- <include name="update-tutti.properties"/>
+ <include name="update-tutti.properties" />
</fileset>
</copy>
</tasks>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-02-18 07:43:40 UTC (rev 439)
+++ trunk/tutti-persistence/pom.xml 2013-02-18 07:50:14 UTC (rev 440)
@@ -21,16 +21,14 @@
#L%
-->
-<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">
+<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>
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-02-18 07:43:40 UTC (rev 439)
+++ trunk/tutti-service/pom.xml 2013-02-18 07:50:14 UTC (rev 440)
@@ -28,7 +28,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-02-18 07:43:40 UTC (rev 439)
+++ trunk/tutti-ui-swing/pom.xml 2013-02-18 07:50:14 UTC (rev 440)
@@ -21,16 +21,14 @@
#L%
-->
-<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">
+<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>
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
1
0
Author: tchemit
Date: 2013-02-18 08:43:40 +0100 (Mon, 18 Feb 2013)
New Revision: 439
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/439
Log:
fix doc
Modified:
trunk/src/site/rst/features.rst
Modified: trunk/src/site/rst/features.rst
===================================================================
--- trunk/src/site/rst/features.rst 2013-02-18 07:40:56 UTC (rev 438)
+++ trunk/src/site/rst/features.rst 2013-02-18 07:43:40 UTC (rev 439)
@@ -29,7 +29,7 @@
Abstract
--------
-Ce document décrit les fonctionnalités proposées par **Tutti**:
+Ce document décrit les fonctionnalités de **Tutti**, à savoir:
- `Gestionnaire de base`_
- `Gestionnaire de référentiel`_
@@ -41,13 +41,13 @@
Tutti utilise une base de travail compatible **Allegro**, l'application permet
de gérer ces bases, à savoir :
-* Installer une base à partir d'une url distante via le mécanisme de mise à jour
+- Installer une base à partir d'une url distante via le mécanisme de mise à jour
intégré.
-* Mise à jour automatique via le mécanisme de mise à jour intégré.
-* Exporter la base de travail (sous forme d'archive zip).
+- Mise à jour automatique via le mécanisme de mise à jour intégré.
+- Exporter la base de travail (sous forme d'archive zip).
-Pour utiliser ces fonctionnalités, rendez-vous sur l'écran **Gestion des bases**
-(Menu fichier -> Gestionnaire de bases).
+Pour utiliser ces fonctionnalités, rendez-vous sur l'écran **Gestionnaire de base**
+(Menu fichier -> Gestionnaire de base).
Gestionnaire de référentiel
---------------------------
@@ -77,7 +77,7 @@
Format des colonnes
+++++++++++++++++++
-- name (chaîne de cacractère) : nom de l'espèce scientifique
+- **name** (chaîne de cacractère) : nom de l'espèce scientifique
Exemple
+++++++
@@ -102,9 +102,9 @@
Format des colonnes
+++++++++++++++++++
-- name (chaîne de cacractère) : nom de l'espèce scientifique
-- internationalRegistrationCode (chaîne de cacractère) : immatriculation du navire
-- scientificVessel (Y,N) : Y si c'est un navire scientifique, N pour un navire professionel
+- **name** (chaîne de cacractère) : nom de l'espèce scientifique
+- **internationalRegistrationCode** (chaîne de cacractère) : immatriculation du navire
+- **scientificVessel** (Y,N) : Y si c'est un navire scientifique, N pour un navire professionel
Exemple
+++++++
@@ -130,9 +130,9 @@
Format des colonnes
+++++++++++++++++++
-- name (chaîne de cacractère) : nom de l'espèce scientifique
-- label (chaîne de cacractère) : nom de l'espèce scientifique
-- scientificGear (Y,N) : Y si c'est un engin scientifique, N pour un engin professionel
+- **name** (chaîne de cacractère) : nom de l'espèce scientifique
+- **label** (chaîne de cacractère) : nom de l'espèce scientifique
+- **scientificGear** (Y,N) : Y si c'est un engin scientifique, N pour un engin professionel
Exemple
+++++++
@@ -159,8 +159,8 @@
Format des colonnes
+++++++++++++++++++
-- firstName (chaîne de cacractère) : prénom
-- lastName (chaîne de cacractère) : nom
+- **firstName** (chaîne de cacractère) : prénom
+- **lastName** (chaîne de cacractère) : nom
Exemple
+++++++
@@ -213,8 +213,8 @@
Format des colonnes
+++++++++++++++++++
-- *pmfmId* (entier) : identifiant
-- *pmfmType* (LENGTH_STEP,ENVIRONMENT,HYDROLOGY,GEAR) : écran où intervient la caractéristique
+- **pmfmId** (entier) : identifiant
+- **pmfmType** (LENGTH_STEP,ENVIRONMENT,HYDROLOGY,GEAR) : écran où intervient la caractéristique
- pmfmParameterName (chaîne de cacractère) : paramètre de la caractéristique
- pmfmMatrixName (chaîne de cacractère) : support de la caractérisque
- pmfmFractionName (chaîne de cacractère) : fraction de la caractérisque
@@ -255,22 +255,22 @@
Format des colonnes
+++++++++++++++++++
-- *speciesReferenceTaxonId* (entier) : identifiant du taxon de référence
+- **speciesReferenceTaxonId** (entier) : identifiant du taxon de référence
- speciesRefTaxCode (chaîne de cacractère) : identifiant du *refTax*
- speciesName (chaîne de cacractère) : nom de l'espèce
-- *speciesSurveyCode* (chaîne de cacractère) : code campagne de l'espèce
-- *lengthStepPmfmId* (chaîne de cacractère) : identifiant de la caractéristique de mesure des individus
+- **speciesSurveyCode** (chaîne de cacractère) : code campagne de l'espèce
+- **lengthStepPmfmId** (chaîne de cacractère) : identifiant de la caractéristique de mesure des individus
- lengthStepPmfmParameterName (chaîne de cacractère) : nom du paramètre de la caractéristique de mesure des individus
- lengthStepPmfmMatrixName (chaîne de cacractère) : nom du support de la caractéristique de mesure des individus
- lengthStepPmfmFractionName (chaîne de cacractère) : nom de la fraction de la caractéristique de mesure des individus
- lengthStepPmfmMethodName (chaîne de cacractère) : nom de la méthode de la caractéristique de mesure des individus
-- *sizeEnabled* (Y|N) : Catégorisation sur la classe de Tri pour cette espèces ?
-- *sexEnabled* (Y|N) : Catégorisation sur la classe deTri pour cette espèces ?
-- *maturityEnabled* (Y|N) : Catégorisation sur la maturité pour cette espèces ?
-- *ageEnabled* (Y|N) : Catégorisation sur l'age pour cette espèces ?
-- *weightEnabled* (Y|N) : Pesée pour cette espèces ?
-- *countIfNoFrequencyEnabled* (Y|N) : Dénombrement pour cette espèce ?
-- *calcifySampleEnabled* (Y|N) : Prélèvement de picèes calcifiées pour cette espèce ?
+- **sizeEnabled** (Y|N) : Catégorisation sur la classe de Tri pour cette espèces ?
+- **sexEnabled** (Y|N) : Catégorisation sur la classe deTri pour cette espèces ?
+- **maturityEnabled** (Y|N) : Catégorisation sur la maturité pour cette espèces ?
+- **ageEnabled** (Y|N) : Catégorisation sur l'age pour cette espèces ?
+- **weightEnabled** (Y|N) : Pesée pour cette espèces ?
+- **countIfNoFrequencyEnabled** (Y|N) : Dénombrement pour cette espèce ?
+- **calcifySampleEnabled** (Y|N) : Prélèvement de picèes calcifiées pour cette espèce ?
A noter que seules les colonnes identifiées en gras sont prise en compte lors
de l'import, les autres colonnes sont là à titre informatif pour faciliter
@@ -293,30 +293,46 @@
Une fois le protocole saisie dans *Tutti*, il est possible de l'exporter afin
de pouvoir le réimporter ensuite sur une autre machine.
-Pour ce faire, retourner sur l'écran de *Sélection d'une camapgne*, survoler
-le bouton *Editer* puis cliquer sur le bouton *Exporter*. Il vous sera alors
+Pour ce faire, retourner sur l'écran de **Sélection d'une campagne**, survoler
+le bouton *Editer* puis cliquer sur le bouton **Exporter**. Il vous sera alors
demander de spécifier l'emplacement de sauvegarde du protocole.
A noter que l'extension *.tuttiProtocol* sera ajouté au nom du fichier saisie.
-Remarque: Le format de ce fichier bien d'humainement compréhensible ne doit pas
+Remarque: Le format de ce fichier bien qu'humainement compréhensible ne doit pas
être modifié à la main.
Importer un protocole
~~~~~~~~~~~~~~~~~~~~~
-En survolant le bouton *Nouveau*, et en cliquant sur le bouton *Importer*, il
+En survolant le bouton **Nouveau**, et en cliquant sur le bouton **Importer**, il
vous sera demander de fournir une fichier de protocole
-(avec une extension *.tuttiProtocol*). Une fois votre fichier sélectionné, v
-ous arriverez sur l'écran de création - modification d'un protocole. Il faut
-faudra alors l'enregistrer pour finaliser l'import dans Tutti.
+(avec une extension *.tuttiProtocol*).
+Une fois votre fichier sélectionné, vous arriverez sur l'écran de
+*création - modification d'un protocole*.
+
+Il faut faudra alors l'enregistrer pour finaliser l'import dans Tutti.
+
Cloner un protocole
~~~~~~~~~~~~~~~~~~~
-TODO
+Une fois un protocole saisie dans *Tutti*, il est possible de le cloner.
+Pour ce faire, retourner sur l'écran de **Sélection d'une campagne**, survoler
+le bouton *Editer* puis cliquer sur le bouton **Cloner**.
+
+Le protocole sera alors dupliquer, vous arriverez sur l'écran de
+*création - modification d'un protocole*.
+
+Il faut faudra alors l'enregistrer pour finaliser la duplication du protocole.
+
Supprimer un protocole
~~~~~~~~~~~~~~~~~~~~~~
-TODO
+Une fois un protocole saisie dans *Tutti*, il est possible de le supprimer.
+
+Pour ce faire, retourner sur l'écran de **Sélection d'une campagne**, survoler
+le bouton *Editer* puis cliquer sur le bouton **Supprimer**. Il vous sera alors
+demander de confirmer la suppression du protocole.
+
1
0
r438 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing java/fr/ifremer/tutti/ui/swing/content/db java/fr/ifremer/tutti/ui/swing/content/protocol java/fr/ifremer/tutti/ui/swing/util/action resources/i18n
by tchemit@users.forge.codelutin.com 18 Feb '13
by tchemit@users.forge.codelutin.com 18 Feb '13
18 Feb '13
Author: tchemit
Date: 2013-02-18 08:40:56 +0100 (Mon, 18 Feb 2013)
New Revision: 438
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/438
Log:
- improve loading dialog position
- improve protocol cloned ui
- improve open-close db action
- continue user doc
- hide synchronisation menu (should delete it!)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/UpdateReferentialAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx 2013-02-18 07:40:56 UTC (rev 438)
@@ -79,7 +79,7 @@
<JMenuItem id='menuImportTemporaryReferential'/>
</JMenu>
- <JMenu id='menuSynchronisations'>
+ <!--JMenu id='menuSynchronisations'>
<JMenuItem id='menuSynchronisationImport'
onActionPerformed="getHandler().showImportScreen()"/>
@@ -87,7 +87,7 @@
onActionPerformed="getHandler().showExportScreen()"/>
<JMenuItem id='menuSynchronisationAllegro'
onActionPerformed="getHandler().showAllegroScreen()"/>
- </JMenu>
+ </JMenu-->
<JMenu id='menuHelp'>
<JMenuItem id='menuHelpSite'
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2013-02-18 07:40:56 UTC (rev 438)
@@ -136,7 +136,6 @@
// open tutti db
OpenDbAction openDbAction = createAction(OpenDbAction.class);
- openDbAction.setCheckDbContext(true);
openDbAction.actionPerformed(null);
}
}
@@ -200,18 +199,6 @@
context.setScreen(TuttiScreen.EDIT_FISHING_OPERATION);
}
- public void showImportScreen() {
-
- }
-
- public void showExportScreen() {
-
- }
-
- public void showAllegroScreen() {
-
- }
-
public void showAbout() {
ApplicationConfig applicationConfig =
@@ -289,6 +276,25 @@
return body.getHandler();
}
+ /**
+ * Reload the persistence service and set the new ne into the handler.
+ *
+ * @since 1.0
+ */
+ public void reloadPersistenceService() {
+ this.persistenceService = context.reloadPersistenceService();
+ }
+
+ /**
+ * Get the persistence service instance used by the handler.
+ *
+ * @return the persistence service instance used by the handler
+ * @since 1.0
+ */
+ public PersistenceService getPersistenceService() {
+ return persistenceService;
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
@@ -498,16 +504,4 @@
return title;
}
-
- public void reloadPersistenceService() {
-
- this.persistenceService = context.reloadPersistenceService();
-
- context.setProgramId(null);
- context.setProgramId(null);
- }
-
- public PersistenceService getPersistenceService() {
- return persistenceService;
- }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/UpdateReferentialAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/UpdateReferentialAction.java 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/UpdateReferentialAction.java 2013-02-18 07:40:56 UTC (rev 438)
@@ -87,13 +87,17 @@
progressionModel.setMessage("Rechargement de la base de données");
getContext().setDbLoaded(true);
- getHandler().reloadPersistenceService();
+ getContext().reloadPersistenceService();
} else {
sendMessage("Aucune mise à jour de base détectée.");
}
+ }
+ @Override
+ protected void releaseAction(ActionEvent event) {
getContext().getActionUI().getModel().setProgressionModel(null);
+ super.releaseAction(event);
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-02-18 07:40:56 UTC (rev 438)
@@ -70,6 +70,8 @@
getHandler().reloadPersistenceService();
+ getContext().clearDbContext();
+
sendMessage(String.format("La base de données '%s' est fermée.", jdbcUrl));
// goto the only screen possible in this state
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java 2013-02-18 07:40:56 UTC (rev 438)
@@ -88,7 +88,7 @@
new Runnable() {
@Override
public void run() {
- getContext().getMainUI().getBody().revalidate();
+ getContext().getMainUI().getBody().repaint();
}
}
);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-02-18 07:40:56 UTC (rev 438)
@@ -48,13 +48,6 @@
/** Logger. */
private static final Log log = LogFactory.getLog(OpenDbAction.class);
- /**
- * Flag to sanity or not the db context (and save it in config).
- *
- * @since 1.0
- */
- protected boolean checkDbContext;
-
public OpenDbAction(MainUIHandler handler) {
super(handler,
"openDb",
@@ -77,23 +70,10 @@
sendMessage(String.format("La base de données '%s' est ouverte.", jdbcUrl));
- if (checkDbContext) {
-
- if (log.isDebugEnabled()) {
- log.debug("Check db context");
- }
- getContext().checkDbContext();
+ if (log.isDebugEnabled()) {
+ log.debug("Check db context");
}
+ getContext().checkDbContext();
getContext().setScreen(TuttiScreen.SELECT_CRUISE);
}
-
- @Override
- protected void releaseAction(ActionEvent event) {
- checkDbContext = false;
- super.releaseAction(event);
- }
-
- public void setCheckDbContext(boolean checkDbContext) {
- this.checkDbContext = checkDbContext;
- }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-02-18 07:40:56 UTC (rev 438)
@@ -51,13 +51,12 @@
text: {getStringValue(model.getComment())};
}
-#warningContainer {
+#saveWarningContainer {
background: {new java.awt.Color(245, 218, 88)};
- visible: {model.isImported()};
+ visible: {model.isImported() || model.isCloned()};
}
-#importWarning {
- text: "tutti.label.import.warning";
+#saveWarning {
actionIcon: warning;
border: {new javax.swing.border.EmptyBorder(5, 10, 5, 10)};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2013-02-18 07:40:56 UTC (rev 438)
@@ -175,9 +175,9 @@
</tab>
</JTabbedPane>
- <JPanel id='warningContainer' layout='{new BorderLayout(10, 10)}'
+ <JPanel id='saveWarningContainer' layout='{new BorderLayout(10, 10)}'
constraints='BorderLayout.NORTH'>
- <JLabel id='importWarning' constraints='BorderLayout.CENTER'/>
+ <JLabel id='saveWarning' constraints='BorderLayout.CENTER'/>
</JPanel>
<JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'>
<JButton id='cancelButton'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-02-18 07:40:56 UTC (rev 438)
@@ -194,6 +194,7 @@
model.fromBean(protocol);
model.setImported(true);
+ ui.getSaveWarning().setText(_("tutti.label.protocol.import.warning"));
} else {
@@ -209,7 +210,10 @@
if (mustClone != null && mustClone) {
ui.setContextValue(false, MainUIHandler.CLONE_PROTOCOL);
model.setId(null);
+ model.setCloned(true);
+ ui.getSaveWarning().setText(_("tutti.label.protocol.clone.warning"));
+
} else {
log.debug(model.getExistingProtocols());
model.getExistingProtocols().remove(protocol);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-02-18 07:40:56 UTC (rev 438)
@@ -61,6 +61,8 @@
public static final String PROPERTY_IMPORTED = "imported";
+ public static final String PROPERTY_CLONED = "cloned";
+
protected String name;
protected String comment;
@@ -73,9 +75,21 @@
protected List<String> hydrologyPmfmId;
+ /**
+ * Flag when a incoming protocol is imported.
+ *
+ * @since 1.0
+ */
protected boolean imported;
/**
+ * Flag when a incoming protocol is cloned.
+ *
+ * @since 1.0
+ */
+ protected boolean cloned;
+
+ /**
* Can user remove a selected species?
*
* @since 0.3
@@ -205,6 +219,16 @@
firePropertyChange(PROPERTY_IMPORTED, oldValue, imported);
}
+ public boolean isCloned() {
+ return cloned;
+ }
+
+ public void setCloned(boolean cloned) {
+ Object oldValue = isCloned();
+ this.cloned = cloned;
+ firePropertyChange(PROPERTY_CLONED, oldValue, cloned);
+ }
+
public List<TuttiProtocol> getExistingProtocols() {
return existingProtocols;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionUIHandler.java 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionUIHandler.java 2013-02-18 07:40:56 UTC (rev 438)
@@ -29,12 +29,12 @@
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.MainUI;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.swing.SwingUtilities;
+import java.awt.Container;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -119,16 +119,19 @@
} else {
// starting action
- if (ui.getOwner() != null) {
- MainUI mainUI = getContext().getMainUI();
- if (mainUI != null) {
- SwingUtil.center(mainUI, ui);
- }
- }
// new action
- ui.getGlobalActionLabel().setText(_("tutti.message.action.running", action.getActionDescription()));
+ ui.getGlobalActionLabel().setText(
+ _("tutti.message.action.running", action.getActionDescription()));
ui.pack();
+
+ MainUI mainUI = getContext().getMainUI();
+ if (mainUI != null) {
+ Container component = mainUI.getBody();
+ int x = mainUI.getX() + (mainUI.getWidth() - component.getWidth());
+ int y = mainUI.getY() + (mainUI.getHeight() - component.getHeight());
+ ui.setLocation(x, y);
+ }
ui.setVisible(true);
}
}
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-17 20:23:04 UTC (rev 437)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-18 07:40:56 UTC (rev 438)
@@ -277,7 +277,6 @@
tutti.label.frequencyConfiguration.no.configuration=< Pas de configuration >
tutti.label.frequencyConfiguration.rafaleStep=Classe de taille à incrémenter
tutti.label.frequencyConfiguration.step=Pas de la classe de taille
-tutti.label.import.warning=Le protocole que vous venez d'importer ne sera sauvegardé que lorsque vous cliquerez sur le bouton "Enregistrer".
tutti.label.list.gear=Engin(s)
tutti.label.list.headOfMission=Chef(s) de mission
tutti.label.list.headOfSortRoom=Reponsable(s) de salle de tri
@@ -288,6 +287,8 @@
tutti.label.program.name=Nom
tutti.label.program.zone=Zone
tutti.label.protocol=Protocol de saisie
+tutti.label.protocol.clone.warning=Le protocole que vous venez de cloner ne sera sauvegardé que lorsque vous cliquerez sur le bouton "Enregistrer".
+tutti.label.protocol.import.warning=Le protocole que vous venez d'importer ne sera sauvegardé que lorsque vous cliquerez sur le bouton "Enregistrer".
tutti.label.referential.gear=Référentiel Engin
tutti.label.referential.person=Référentiel Personne
tutti.label.referential.species=Référentiel Espèce
1
0
Author: tchemit
Date: 2013-02-17 21:23:04 +0100 (Sun, 17 Feb 2013)
New Revision: 437
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/437
Log:
fix doc
Modified:
trunk/src/site/rst/features.rst
Modified: trunk/src/site/rst/features.rst
===================================================================
--- trunk/src/site/rst/features.rst 2013-02-16 10:02:14 UTC (rev 436)
+++ trunk/src/site/rst/features.rst 2013-02-17 20:23:04 UTC (rev 437)
@@ -26,6 +26,9 @@
Fonctionnalités
===============
+Abstract
+--------
+
Ce document décrit les fonctionnalités proposées par **Tutti**:
- `Gestionnaire de base`_
@@ -317,7 +320,3 @@
~~~~~~~~~~~~~~~~~~~~~~
TODO
-
-.. _Gestionnaire de base: ./features.html#gestionnaire_de_base
-.. _Gestionnaire de référentiel: ./features.html#gestionnaire_de_r_f_rentiel
-.. _Gestionnaire de protocole: ./features.html#gestionnaire_de_protocole
\ No newline at end of file
1
0
r436 - in trunk: src/site src/site/rst tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor tutti-ui-swing/src/main/resources/i18n tutti-ui-swing/src/main/resources/icons
by tchemit@users.forge.codelutin.com 16 Feb '13
by tchemit@users.forge.codelutin.com 16 Feb '13
16 Feb '13
Author: tchemit
Date: 2013-02-16 11:02:14 +0100 (Sat, 16 Feb 2013)
New Revision: 436
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/436
Log:
ajout documentation + fix some release stuff
Added:
trunk/src/site/rst/features.rst
Removed:
trunk/src/site/rst/protocol.rst
trunk/src/site/rst/temporaryReferential.rst
Modified:
trunk/src/site/rst/index.rst
trunk/src/site/site_fr.xml
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
trunk/tutti-ui-swing/src/main/resources/icons/action-export-db.png
Added: trunk/src/site/rst/features.rst
===================================================================
--- trunk/src/site/rst/features.rst (rev 0)
+++ trunk/src/site/rst/features.rst 2013-02-16 10:02:14 UTC (rev 436)
@@ -0,0 +1,323 @@
+.. -
+.. * #%L
+.. * Tutti
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2012 - 2013 Ifremer
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU General Public License as
+.. * published by the Free Software Foundation, either version 3 of the
+.. * License, or (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Public License for more details.
+.. *
+.. * You should have received a copy of the GNU General Public
+.. * License along with this program. If not, see
+.. * <http://www.gnu.org/licenses/gpl-3.0.html>.
+.. * #L%
+.. -
+
+===============
+Fonctionnalités
+===============
+
+Ce document décrit les fonctionnalités proposées par **Tutti**:
+
+- `Gestionnaire de base`_
+- `Gestionnaire de référentiel`_
+- `Gestionnaire de protocole`_
+
+Gestionnaire de base
+--------------------
+
+Tutti utilise une base de travail compatible **Allegro**, l'application permet
+de gérer ces bases, à savoir :
+
+* Installer une base à partir d'une url distante via le mécanisme de mise à jour
+ intégré.
+* Mise à jour automatique via le mécanisme de mise à jour intégré.
+* Exporter la base de travail (sous forme d'archive zip).
+
+Pour utiliser ces fonctionnalités, rendez-vous sur l'écran **Gestion des bases**
+(Menu fichier -> Gestionnaire de bases).
+
+Gestionnaire de référentiel
+---------------------------
+
+Tutti permet de gérer certains référentiels temporaires via des imports csv.
+Afin de faciliter l'utilisation du format des imports, il est possible d'exporter
+pour chaque type d'import un exemple de fichier avec le bon format.
+
+Pour import ces référentiels, rendez-vous sur l'écran **Import des référentiels
+temporaires** (Menu Administration -> Réferentiels temporaires).
+
+A noter que cet écran est protégé par un mot de passe pour mieux contrôler les
+ajouts de référentiels. (à partir de la version 2.0).
+
+On décrit les différents imports possibles et leur format.
+
+Import Espèces
+~~~~~~~~~~~~~~
+
+Colonnes requises
++++++++++++++++++
+
+::
+
+ name
+
+Format des colonnes
++++++++++++++++++++
+
+- name (chaîne de cacractère) : nom de l'espèce scientifique
+
+Exemple
++++++++
+
+::
+
+ name
+ Temporary Species name 1;
+ Temporary Species name 2;
+ Temporary Species name 3;
+
+Import Navire
+~~~~~~~~~~~~~
+
+Colonnes requises
++++++++++++++++++
+
+::
+
+ name;internationalRegistrationCode;scientificVessel
+
+Format des colonnes
++++++++++++++++++++
+
+- name (chaîne de cacractère) : nom de l'espèce scientifique
+- internationalRegistrationCode (chaîne de cacractère) : immatriculation du navire
+- scientificVessel (Y,N) : Y si c'est un navire scientifique, N pour un navire professionel
+
+Exemple
++++++++
+
+::
+
+ name;internationalRegistrationCode;scientificVessel
+ Temporary fishing vessel name 1;International registration code F1;N;
+ Temporary fishing vessel name 2;International registration code F2;N;
+ Temporary scientific vessel name 3;International registration code S3;Y;
+ Temporary scientific vessel name 4;International registration code S4;Y;
+
+Import Engin
+~~~~~~~~~~~~
+
+Colonnes requises
++++++++++++++++++
+
+::
+
+ name;label;scientificGear
+
+Format des colonnes
++++++++++++++++++++
+
+- name (chaîne de cacractère) : nom de l'espèce scientifique
+- label (chaîne de cacractère) : nom de l'espèce scientifique
+- scientificGear (Y,N) : Y si c'est un engin scientifique, N pour un engin professionel
+
+Exemple
++++++++
+
+::
+
+ name;label;scientificGear
+ Gear fishing name 1;Gear fishing label 1;N;
+ Gear fishing name 2;Gear fishing label 2;N;
+ Gear scientific name 3;Gear scientific label 3;Y;
+ Gear scientific name 4;Gear scientific label 4;Y;
+
+Import Personne
+~~~~~~~~~~~~~~~
+
+Colonnes requises
++++++++++++++++++
+
+::
+
+ firstName;lastName
+
+
+Format des colonnes
++++++++++++++++++++
+
+- firstName (chaîne de cacractère) : prénom
+- lastName (chaîne de cacractère) : nom
+
+Exemple
++++++++
+
+::
+
+ firstName;lastName
+ First name 1;Last name 1;
+ First name 2;Last name 2;
+ First name 3;Last name 3;
+
+Gestionnaire de protocole
+-------------------------
+
+Tutti permet de gérer un protocole léger est simple à mettre en application.
+
+Création d'un protocole
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Pour créer un nouveau protocole, rendez-vous sur l'écran **Sélection d'une
+campagne** (Menu Actions -> Sélectionner une campagne), sur la ligne
+Protocol de saisie, survoler le bouton *Nouveau* puis cliquez sur le bouton
+Nouveau qui apparaît dans la liste déroulante d'actions.
+
+Vous arrivez alors sur un formulaire qui permet la saisie du protocole
+organisé sous forme d'onglets.
+
+Import de données dans un protocole
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Il est possible dans le formulaire de création - mise à jour d'un protocole
+d'importer à partir de fichier au format csv. Plus précisement on peut importer
+
+- dans l'onglet *caractéristiques*, les caractéristiques *préférées* dans
+ les différents écrans de saisie.
+- dans l'onglet *espèces*, les espèces *préférées* à utiliser dans les écrans
+ de saisie.
+
+Import de caractéristiques
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Colonnes requises
++++++++++++++++++
+
+::
+
+ pmfmId;pmfmType;pmfmParameterName;pmfmMatrixName;pmfmFractionName;pmfmMethodName
+
+
+Format des colonnes
++++++++++++++++++++
+
+- *pmfmId* (entier) : identifiant
+- *pmfmType* (LENGTH_STEP,ENVIRONMENT,HYDROLOGY,GEAR) : écran où intervient la caractéristique
+- pmfmParameterName (chaîne de cacractère) : paramètre de la caractéristique
+- pmfmMatrixName (chaîne de cacractère) : support de la caractérisque
+- pmfmFractionName (chaîne de cacractère) : fraction de la caractérisque
+- pmfmMethodName (chaîne de cacractère) : méthode de la caractéristique
+
+A noter que seules les colonnes identifiées en gras sont prise en compte lors
+de l'import, les autres colonnes sont là à titre informatif pour faciliter
+l'élaboration du fichier d'import par les thématiciens.
+
+Exemple
++++++++
+
+::
+
+ pmfmId;pmfmType;pmfmParameterName;pmfmMatrixName;pmfmFractionName;pmfmMethodName
+ 211;LENGTH_STEP;Nombre de marées;navire;totale;Déclaration d'un professionnel;
+ 212;LENGTH_STEP;Déroulement de l'activité;navire;totale;Observation par un observateur;
+ 214;ENVIRONMENT;Temps indeterminé;opération;totale;"Calculé, méthode inconnue";
+ 215;ENVIRONMENT;Valorisation;produit;totale;Déclaration d'un professionnel;
+ 217;HYDROLOGY;Ouverture verticale (chalut ou drague);engin;totale;Déclaration d'un professionnel;
+ 218;HYDROLOGY;Ouverture verticale (chalut ou drague);engin;totale;Mesure d'un professionnel;
+ 219;GEAR;Poids;produit/lot;totale;Mesure d'un professionnel;
+ 220;GEAR;Poids;produit/lot;totale;Mesure par un observateur;
+
+Import d'espèces
+~~~~~~~~~~~~~~~~
+
+
+Colonnes requises
++++++++++++++++++
+
+::
+
+ speciesReferenceTaxonId;speciesRefTaxCode;speciesName;speciesSurveyCode;lengthStepPmfmId;lengthStepPmfmParameterName;lengthStepPmfmMatrixName;lengthStepPmfmFractionName;
+ lengthStepPmfmMethodName;sizeEnabled;sexEnabled;maturityEnabled;ageEnabled;weightEnabled;countIfNoFrequencyEnabled;calcifySampleEnabled
+
+
+Format des colonnes
++++++++++++++++++++
+
+- *speciesReferenceTaxonId* (entier) : identifiant du taxon de référence
+- speciesRefTaxCode (chaîne de cacractère) : identifiant du *refTax*
+- speciesName (chaîne de cacractère) : nom de l'espèce
+- *speciesSurveyCode* (chaîne de cacractère) : code campagne de l'espèce
+- *lengthStepPmfmId* (chaîne de cacractère) : identifiant de la caractéristique de mesure des individus
+- lengthStepPmfmParameterName (chaîne de cacractère) : nom du paramètre de la caractéristique de mesure des individus
+- lengthStepPmfmMatrixName (chaîne de cacractère) : nom du support de la caractéristique de mesure des individus
+- lengthStepPmfmFractionName (chaîne de cacractère) : nom de la fraction de la caractéristique de mesure des individus
+- lengthStepPmfmMethodName (chaîne de cacractère) : nom de la méthode de la caractéristique de mesure des individus
+- *sizeEnabled* (Y|N) : Catégorisation sur la classe de Tri pour cette espèces ?
+- *sexEnabled* (Y|N) : Catégorisation sur la classe deTri pour cette espèces ?
+- *maturityEnabled* (Y|N) : Catégorisation sur la maturité pour cette espèces ?
+- *ageEnabled* (Y|N) : Catégorisation sur l'age pour cette espèces ?
+- *weightEnabled* (Y|N) : Pesée pour cette espèces ?
+- *countIfNoFrequencyEnabled* (Y|N) : Dénombrement pour cette espèce ?
+- *calcifySampleEnabled* (Y|N) : Prélèvement de picèes calcifiées pour cette espèce ?
+
+A noter que seules les colonnes identifiées en gras sont prise en compte lors
+de l'import, les autres colonnes sont là à titre informatif pour faciliter
+l'élaboration du fichier d'import par les thématiciens.
+
+Exemple
++++++++
+
+::
+
+ speciesReferenceTaxonId;speciesRefTaxCode;speciesName;speciesSurveyCode;lengthStepPmfmId;lengthStepPmfmParameterName;lengthStepPmfmMatrixName;lengthStepPmfmFractionName;lengthStepPmfmMethodName;sizeEnabled;sexEnabled;maturityEnabled;ageEnabled;weightEnabled;countIfNoFrequencyEnabled;calcifySampleEnabled
+ 2184;OCNUPLA;Ocnus planci;OCNU;211;Nombre de marées;navire;totale;Déclaration d'un professionnel;Y;Y;Y;Y;Y;Y;Y;
+ 12367;KRYPMAR;Kryptolebias marmoratus;KRY;214;Temps indeterminé;opération;totale;"Calculé, méthode inconnue";Y;Y;Y;Y;Y;Y;Y;
+ 1699;DIPD;Diplodus;DIPDD;215;Valorisation;produit;totale;Déclaration d'un professionnel;Y;Y;Y;Y;Y;Y;Y;
+ 7702;MCRPBRA;Microphis brachyurus;MCRPB;217;Ouverture verticale (chalut ou drague);engin;totale;Déclaration d'un professionnel;Y;Y;Y;Y;Y;Y;Y;
+
+Export d'un protocole
+~~~~~~~~~~~~~~~~~~~~~
+
+Une fois le protocole saisie dans *Tutti*, il est possible de l'exporter afin
+de pouvoir le réimporter ensuite sur une autre machine.
+
+Pour ce faire, retourner sur l'écran de *Sélection d'une camapgne*, survoler
+le bouton *Editer* puis cliquer sur le bouton *Exporter*. Il vous sera alors
+demander de spécifier l'emplacement de sauvegarde du protocole.
+
+A noter que l'extension *.tuttiProtocol* sera ajouté au nom du fichier saisie.
+
+Remarque: Le format de ce fichier bien d'humainement compréhensible ne doit pas
+être modifié à la main.
+
+Importer un protocole
+~~~~~~~~~~~~~~~~~~~~~
+
+En survolant le bouton *Nouveau*, et en cliquant sur le bouton *Importer*, il
+vous sera demander de fournir une fichier de protocole
+(avec une extension *.tuttiProtocol*). Une fois votre fichier sélectionné, v
+ous arriverez sur l'écran de création - modification d'un protocole. Il faut
+faudra alors l'enregistrer pour finaliser l'import dans Tutti.
+
+Cloner un protocole
+~~~~~~~~~~~~~~~~~~~
+
+TODO
+
+Supprimer un protocole
+~~~~~~~~~~~~~~~~~~~~~~
+
+TODO
+
+.. _Gestionnaire de base: ./features.html#gestionnaire_de_base
+.. _Gestionnaire de référentiel: ./features.html#gestionnaire_de_r_f_rentiel
+.. _Gestionnaire de protocole: ./features.html#gestionnaire_de_protocole
\ No newline at end of file
Property changes on: trunk/src/site/rst/features.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2013-02-16 07:17:12 UTC (rev 435)
+++ trunk/src/site/rst/index.rst 2013-02-16 10:02:14 UTC (rev 436)
@@ -46,25 +46,38 @@
Pour télécharger l'application aller `ici
<http://forge.codelutin.com/projects/tutti/files>`_ .
-Après téléchargement, décompresser l'archive dans un dossier. Pour lancer
-l'application il vous faut Java JRE version 1.6 minimum.
+Après téléchargement, décompresser l'archive dans un dossier.
+Aucun pré-requis logiciel n'est nécessaire au lancement de Tutti. Nous
+préconisons cependant d'avoir au moins 1Go de mémoire.
+
Sous windows
~~~~~~~~~~~~
Lancement de l'application via **tutti.bat**
-1. Si ça ne marche pas, exécuter **cmd** dans le terminal, taper **java -version**.
- Si la version est inférieure à **1.6**, il faut installer une nouvelle version
- de java disponible sur `le site d'oracle
- <http://www.oracle.com/technetwork/java/javase/downloads/jre6-downloads-1637…>`_.
- Après l'installation vérifier que la version est bien maintenant celle voulu.
-2. Si ce n'est toujours pas le cas, vous pouvez modifier le fichier **tutti.bat**
- pour ajouter le chemin complet du **java.exe** de la nouvelle installation
- "c:\chemin complet de java\bin\java" (mettre le chemin entre " pour les
- espaces ou autres caractères spéciaux).
-
Sous linux
~~~~~~~~~~
Lancement de l'application via **tutti.sh**
+
+Première utilisation
+--------------------
+
+Lors d'une première utilisation, l'application démarre et affiche l'écran de
+gestion des bases de travail. Il suffit alors d'installer une base via l'action
+**Installer**. La dernière base disponible sera alors téléchargée puis installer.
+
+A noter que cette opération peut-être longue (temps du téléchargement), soyez
+patient.
+
+Une fois la base téléchargée puis installer l'application est pleinement
+fonctionnel.
+
+Fonctionnalités
+---------------
+
+Retrouvez l'ensemble des fonctionnalités de **Tutti** sur la page
+des `fonctionnalités`_.
+
+.. _fonctionnalités: ./features.html
Deleted: trunk/src/site/rst/protocol.rst
===================================================================
--- trunk/src/site/rst/protocol.rst 2013-02-16 07:17:12 UTC (rev 435)
+++ trunk/src/site/rst/protocol.rst 2013-02-16 10:02:14 UTC (rev 436)
@@ -1,30 +0,0 @@
-.. -
-.. * #%L
-.. * Tutti
-.. * $Id$
-.. * $HeadURL$
-.. * %%
-.. * Copyright (C) 2012 - 2013 Ifremer
-.. * %%
-.. * This program is free software: you can redistribute it and/or modify
-.. * it under the terms of the GNU General Public License as
-.. * published by the Free Software Foundation, either version 3 of the
-.. * License, or (at your option) any later version.
-.. *
-.. * This program is distributed in the hope that it will be useful,
-.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
-.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-.. * GNU General Public License for more details.
-.. *
-.. * You should have received a copy of the GNU General Public
-.. * License along with this program. If not, see
-.. * <http://www.gnu.org/licenses/gpl-3.0.html>.
-.. * #L%
-.. -
-
-
-====================
-Gestion du protocole
-====================
-
-TODO
\ No newline at end of file
Deleted: trunk/src/site/rst/temporaryReferential.rst
===================================================================
--- trunk/src/site/rst/temporaryReferential.rst 2013-02-16 07:17:12 UTC (rev 435)
+++ trunk/src/site/rst/temporaryReferential.rst 2013-02-16 10:02:14 UTC (rev 436)
@@ -1,30 +0,0 @@
-.. -
-.. * #%L
-.. * Tutti
-.. * $Id$
-.. * $HeadURL$
-.. * %%
-.. * Copyright (C) 2012 - 2013 Ifremer
-.. * %%
-.. * This program is free software: you can redistribute it and/or modify
-.. * it under the terms of the GNU General Public License as
-.. * published by the Free Software Foundation, either version 3 of the
-.. * License, or (at your option) any later version.
-.. *
-.. * This program is distributed in the hope that it will be useful,
-.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
-.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-.. * GNU General Public License for more details.
-.. *
-.. * You should have received a copy of the GNU General Public
-.. * License along with this program. If not, see
-.. * <http://www.gnu.org/licenses/gpl-3.0.html>.
-.. * #L%
-.. -
-
-
-====================================
-Gestion des référentiels temporaires
-====================================
-
-TODO
\ No newline at end of file
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2013-02-16 07:17:12 UTC (rev 435)
+++ trunk/src/site/site_fr.xml 2013-02-16 10:02:14 UTC (rev 436)
@@ -96,8 +96,7 @@
<menu name="Tutti">
<item name="Accueil" href="index.html"/>
- <item name="Gestion du protocole" href="./protocol.html"/>
- <item name="Référentiels temporaires" href="./temporaryReferential.html"/>
+ <item name="Fonctionnalités" href="./features.html"/>
<item name="Téléchargement"
href="http://forge.codelutin.com/projects/tutti/files"/>
<item name="Roadmap"
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx 2013-02-16 07:17:12 UTC (rev 435)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx 2013-02-16 10:02:14 UTC (rev 436)
@@ -94,7 +94,6 @@
onActionPerformed='getHandler().gotoSite()'/>
<JMenuItem id='menuHelpAbout'
onActionPerformed='getHandler().showAbout()'/>
- <JMenuItem id='menuUpdateApplication'/>
</JMenu>
</JMenuBar>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-02-16 07:17:12 UTC (rev 435)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-02-16 10:02:14 UTC (rev 436)
@@ -1,8 +1,8 @@
<!--
#%L
Tutti :: UI
- $Id:$
- $HeadURL:$
+ $Id$
+ $HeadURL$
%%
Copyright (C) 2012 - 2013 Ifremer
%%
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-02-16 07:17:12 UTC (rev 435)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-02-16 10:02:14 UTC (rev 436)
@@ -4,8 +4,8 @@
/*
* #%L
* Tutti :: UI
- * $Id:$
- * $HeadURL:$
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2012 - 2013 Ifremer
* %%
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-02-16 07:17:12 UTC (rev 435)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-02-16 10:02:14 UTC (rev 436)
@@ -3,8 +3,8 @@
/*
* #%L
* Tutti :: UI
- * $Id:$
- * $HeadURL:$
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2012 - 2013 Ifremer
* %%
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-16 07:17:12 UTC (rev 435)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-16 10:02:14 UTC (rev 436)
@@ -192,8 +192,8 @@
tutti.flash.information.species.imported.in.protocol=Espèces importées dans le protocole depuis le fichier %s.
tutti.flash.information.species.remove.from.protocol=L'espèce %s a été retirée du protocole
tutti.information.db.loaded=Tutti est connecté à une base de données
+tutti.information.no.db.exist=Aucune base détecté, vous pouvez installer la dernière disponible sur le réseau.
tutti.information.no.db.loaded=Tutti a détecté une base mais elle n'est pas actuellement ouverte.
-tutti.information.no.db.exist=Aucune base détecté, vous pouvez installer la dernière disponible sur le réseau.
tutti.label.attachmentEditor.file=Fichier
tutti.label.attachmentEditor.fileComment=Commentaire
tutti.label.attachmentEditor.fileName=Nom
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-export-db.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r435 - in trunk/tutti-ui-swing: . src/main/assembly/full src/main/assembly/min src/main/filtered-resources src/main/java/fr/ifremer/tutti/ui/swing/content/db src/main/resources src/main/resources/i18n
by tchemit@users.forge.codelutin.com 16 Feb '13
by tchemit@users.forge.codelutin.com 16 Feb '13
16 Feb '13
Author: tchemit
Date: 2013-02-16 08:17:12 +0100 (Sat, 16 Feb 2013)
New Revision: 435
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/435
Log:
fix i18n, fixes #2007: Gestion des logs dans dans le r?\195?\169pertoire de l'application
Added:
trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties
Removed:
trunk/tutti-ui-swing/src/main/resources/log4j.properties
Modified:
trunk/tutti-ui-swing/pom.xml
trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat
trunk/tutti-ui-swing/src/main/assembly/full/tutti.sh
trunk/tutti-ui-swing/src/main/assembly/min/launch.bat
trunk/tutti-ui-swing/src/main/assembly/min/launch.sh
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-02-15 21:01:33 UTC (rev 434)
+++ trunk/tutti-ui-swing/pom.xml 2013-02-16 07:17:12 UTC (rev 435)
@@ -76,6 +76,8 @@
target/${bundlePrefix}-full-linux-x64.zip
</redmine.releaseFiles>
+ <tutti.log.file>\$\{java.io.tmpdir\}\tutti-${project.version}.log</tutti.log.file>
+
</properties>
<build>
@@ -86,6 +88,7 @@
<filtering>true</filtering>
<includes>
<include>*.config</include>
+ <include>*.properties</include>
</includes>
</resource>
<resource>
@@ -185,7 +188,7 @@
<goals>
<goal>copy-dependencies</goal>
</goals>
- <phase>process-classes</phase>
+ <phase>prepare-package</phase>
<configuration>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
@@ -358,7 +361,22 @@
<profiles>
+
<profile>
+ <id>add-release-properties</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <properties>
+ <tutti.log.file>$\{tutti.log.file\}</tutti.log.file>
+ </properties>
+
+ </profile>
+
+ <profile>
<id>default-bundle</id>
<activation>
<property>
Modified: trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat
===================================================================
--- trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat 2013-02-15 21:01:33 UTC (rev 434)
+++ trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat 2013-02-16 07:17:12 UTC (rev 435)
@@ -3,20 +3,22 @@
set OLDDIR=%CD%
cd /d %~dp0%
-set REP=%CD%
-set JAVA_HOME=%REP%\jre
-set TUTTI_HOME=%REP%\tutti
+set TUTTI_BASEDIR=%CD%
+set JAVA_HOME=%TUTTI_BASEDIR%\jre
+set TUTTI_HOME=%TUTTI_BASEDIR%\tutti
set JAVA_COMMAND=%JAVA_HOME%\bin\java
+set TUTTI_LOG_FILE=%TUTTI_BASEDIR%\data\tutti-${project.version}.log
-echo "tutti basedir: %REP%"
+echo "tutti basedir: %TUTTI_BASEDIR%"
echo "tutti app home: %TUTTI_HOME%"
echo "tutti jre home: %JAVA_HOME%"
+echo "tutti log file: %TUTTI_LOG_FILE%"
copy %TUTTI_HOME%\update.bat .
call update.bat
del update.bat
copy tutti.config tutti
-call %TUTTI_HOME%\launch.bat --option tutti.launch.mode full --option tutti.basedir %REP%
+call %TUTTI_HOME%\launch.bat --option tutti.launch.mode full --option tutti.basedir %TUTTI_BASEDIR%
if errorlevel 88 goto start
cd %OLDDIR%
Modified: trunk/tutti-ui-swing/src/main/assembly/full/tutti.sh
===================================================================
--- trunk/tutti-ui-swing/src/main/assembly/full/tutti.sh 2013-02-15 21:01:33 UTC (rev 434)
+++ trunk/tutti-ui-swing/src/main/assembly/full/tutti.sh 2013-02-16 07:17:12 UTC (rev 435)
@@ -1,23 +1,25 @@
#!/bin/bash
-REP=$(pwd)
-export TUTTI_HOME=$REP/tutti
-export JAVA_HOME=$REP/jre
+export TUTTI_BASEDIR=$(pwd)
+export TUTTI_HOME=$TUTTI_BASEDIR/tutti
+export JAVA_HOME=$TUTTI_BASEDIR/jre
export JAVA_COMMAND=$JAVA_HOME/bin/java
+export TUTTI_LOG_FILE=$TUTTI_BASEDIR/data/tutti-${project.version}.log
-cd $REP
+cd $TUTTI_BASEDIR
-echo "tutti basedir: $REP"
+echo "tutti basedir: $TUTTI_BASEDIR"
echo "tutti app home: $TUTTI_HOME"
echo "tutti jre home: $JAVA_HOME"
+echo "tutti log file: $TUTTI_LOG_FILE"
while true; do
cp $TUTTI_HOME/update.sh .
./update.sh
rm -fv update.sh
- cp $REP/tutti.config $TUTTI_HOME
- ./tutti/launch.sh --option tutti.launch.mode full --option tutti.basedir $REP
+ cp $TUTTI_BASEDIR/tutti.config $TUTTI_HOME
+ ./tutti/launch.sh --option tutti.launch.mode full --option tutti.basedir $TUTTI_BASEDIR
exitcode=$?
if [ ! "$exitcode" -eq "88" ]; then
Modified: trunk/tutti-ui-swing/src/main/assembly/min/launch.bat
===================================================================
--- trunk/tutti-ui-swing/src/main/assembly/min/launch.bat 2013-02-15 21:01:33 UTC (rev 434)
+++ trunk/tutti-ui-swing/src/main/assembly/min/launch.bat 2013-02-16 07:17:12 UTC (rev 435)
@@ -4,7 +4,7 @@
cd /d %~dp0%
echo lauch java
-%JAVA_COMMAND% -Xmx1024M -jar ${project.build.finalName}.${project.packaging} %1 %2 %3 %4 %5 %6 %7 %8 %9
+%JAVA_COMMAND% -Xmx1024M -Dtutti.log.file=%TUTTI_LOG_FILE% -jar ${project.build.finalName}.${project.packaging} %1 %2 %3 %4 %5 %6 %7 %8 %9
set exitcode=%ERRORLEVEL%
echo Stop Tutti with exitcode: %exitcode%
cd %OLDDIR%
Modified: trunk/tutti-ui-swing/src/main/assembly/min/launch.sh
===================================================================
--- trunk/tutti-ui-swing/src/main/assembly/min/launch.sh 2013-02-15 21:01:33 UTC (rev 434)
+++ trunk/tutti-ui-swing/src/main/assembly/min/launch.sh 2013-02-16 07:17:12 UTC (rev 435)
@@ -9,7 +9,7 @@
echo "java command: $JAVA_COMMAND"
-$JAVA_COMMAND $MEMORY $TUTTI_JVM_OPTS -jar ${project.build.finalName}.${project.packaging} $*
+$JAVA_COMMAND $MEMORY $TUTTI_JVM_OPTS -Dtutti.log.file=$TUTTI_LOG_FILE -jar ${project.build.finalName}.${project.packaging} $*
exitcode=$?
echo "Stop Tutti with exitcode: $exitcode"
exit $exitcode
Copied: trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties (from rev 434, trunk/tutti-ui-swing/src/main/resources/log4j.properties)
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties (rev 0)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties 2013-02-16 07:17:12 UTC (rev 435)
@@ -0,0 +1,45 @@
+###
+# #%L
+# Tutti :: UI
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2012 Ifremer
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/gpl-3.0.html>.
+# #L%
+###
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout, file
+
+# Console output
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.file=${tutti.log.file}
+log4j.appender.file.MaxFileSize=10MB
+log4j.appender.file.MaxBackupIndex=4
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p [%t] %c - %m%n
+
+# tutti levels
+log4j.logger.fr.ifremer=INFO
+log4j.logger.fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler=WARN
+log4j.logger.fr.ifremer.tutti.ui.swing.util.table=WARN
+log4j.logger.org.nuiton.util=WARN
+log4j.logger.org.nuiton.util.ApplicationConfig=INFO
+log4j.logger.org.nuiton.util.ApplicationConfigHelper=INFO
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java 2013-02-15 21:01:33 UTC (rev 434)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java 2013-02-16 07:17:12 UTC (rev 435)
@@ -69,7 +69,7 @@
} else {
// db does not exist
- message = "tutti.information.no.db.exist";
+ message = _("tutti.information.no.db.exist");
ui.getInformationLabel().setText(_(message));
}
return message;
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-15 21:01:33 UTC (rev 434)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-16 07:17:12 UTC (rev 435)
@@ -109,7 +109,7 @@
tutti.action.importTemporaryVessel.tip=Importer un référentiel temporaire de navires
tutti.action.installDb=Installer
tutti.action.installDb.tip=Télécharger puis installer la base de données
-tutti.action.manageDb=Gestion base
+tutti.action.manageDb=Gestionnaire de base
tutti.action.manageDb.tip=Gérer la base de données utilisée par Tutti
tutti.action.newCruise=Nouveau
tutti.action.newCruise.tip=Créer une nouvelle campagne
@@ -193,6 +193,7 @@
tutti.flash.information.species.remove.from.protocol=L'espèce %s a été retirée du protocole
tutti.information.db.loaded=Tutti est connecté à une base de données
tutti.information.no.db.loaded=Tutti a détecté une base mais elle n'est pas actuellement ouverte.
+tutti.information.no.db.exist=Aucune base détecté, vous pouvez installer la dernière disponible sur le réseau.
tutti.label.attachmentEditor.file=Fichier
tutti.label.attachmentEditor.fileComment=Commentaire
tutti.label.attachmentEditor.fileName=Nom
@@ -467,7 +468,7 @@
tutti.title.noSelectedCruise=Pas de campagne sélectionné
tutti.title.noSelectedProgram=Pas de série de campagne sélectionné
tutti.title.noSelectedProtocol=Pas de protocol sélectionné
-tutti.title.nodb=Pas de base chargé
+tutti.title.nodb=Pas de base chargée
tutti.title.selectSpecies=Choisissez une espèce
tutti.title.selectedCruise=Campagne %s
tutti.title.selectedProgram=Série de campagne %s
Deleted: trunk/tutti-ui-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/log4j.properties 2013-02-15 21:01:33 UTC (rev 434)
+++ trunk/tutti-ui-swing/src/main/resources/log4j.properties 2013-02-16 07:17:12 UTC (rev 435)
@@ -1,45 +0,0 @@
-###
-# #%L
-# Tutti :: UI
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2012 Ifremer
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/gpl-3.0.html>.
-# #L%
-###
-# Global logging configuration
-log4j.rootLogger=ERROR, stdout, file
-
-# Console output
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
-
-log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.file=\${user.home}/.tutti/tutti.log
-log4j.appender.file.MaxFileSize=10MB
-log4j.appender.file.MaxBackupIndex=4
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p [%t] %c - %m%n
-
-# tutti levels
-log4j.logger.fr.ifremer=INFO
-log4j.logger.fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler=WARN
-log4j.logger.fr.ifremer.tutti.ui.swing.util.table=WARN
-log4j.logger.org.nuiton.util=WARN
-log4j.logger.org.nuiton.util.ApplicationConfig=INFO
-log4j.logger.org.nuiton.util.ApplicationConfigHelper=INFO
1
0
r434 - in trunk: . tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor
by tchemit@users.forge.codelutin.com 15 Feb '13
by tchemit@users.forge.codelutin.com 15 Feb '13
15 Feb '13
Author: tchemit
Date: 2013-02-15 22:01:33 +0100 (Fri, 15 Feb 2013)
New Revision: 434
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/434
Log:
fix site build + add missing license headers
Modified:
trunk/pom.xml
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-02-15 20:37:14 UTC (rev 433)
+++ trunk/pom.xml 2013-02-15 21:01:33 UTC (rev 434)
@@ -634,7 +634,7 @@
</reportSet>
</reportSets>
<configuration>
- <i18nBundleName>tutti-ui-swing</i18nBundleName>
+ <i18nBundleName>tutti-i18n</i18nBundleName>
</configuration>
</plugin>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-02-15 20:37:14 UTC (rev 433)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-02-15 21:01:33 UTC (rev 434)
@@ -1,3 +1,26 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id:$
+ $HeadURL:$
+ %%
+ Copyright (C) 2012 - 2013 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
<jaxx.runtime.swing.editor.NumberEditor>
<import>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-02-15 20:37:14 UTC (rev 433)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-02-15 21:01:33 UTC (rev 434)
@@ -1,6 +1,30 @@
package fr.ifremer.tutti.ui.swing.util.editor;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
import jaxx.runtime.JAXXUtil;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-02-15 20:37:14 UTC (rev 433)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-02-15 21:01:33 UTC (rev 434)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.util.editor;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
import jaxx.runtime.JAXXUtil;
1
0
Author: tchemit
Date: 2013-02-15 21:37:14 +0100 (Fri, 15 Feb 2013)
New Revision: 433
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/433
Log:
prepare release (make bundles)
Modified:
trunk/tutti-ui-swing/pom.xml
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-02-15 20:28:55 UTC (rev 432)
+++ trunk/tutti-ui-swing/pom.xml 2013-02-15 20:37:14 UTC (rev 433)
@@ -417,7 +417,7 @@
<executions>
<execution>
<id>get-linux-x64-jre</id>
- <phase>process-classes</phase>
+ <phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
@@ -446,7 +446,7 @@
</configuration>
<executions>
<execution>
- <id>assembly-full</id>
+ <id>assembly-full-linux-x64</id>
<phase>package</phase>
<goals>
<goal>single</goal>
@@ -512,7 +512,7 @@
</configuration>
<executions>
<execution>
- <id>assembly-full</id>
+ <id>assembly-full-linux-i586</id>
<phase>package</phase>
<goals>
<goal>single</goal>
@@ -549,7 +549,7 @@
<executions>
<execution>
<id>get-windows-i586-jre</id>
- <phase>process-classes</phase>
+ <phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
@@ -578,7 +578,7 @@
</configuration>
<executions>
<execution>
- <id>assembly-full</id>
+ <id>assembly-full-windows-i586</id>
<phase>package</phase>
<goals>
<goal>single</goal>
@@ -615,7 +615,7 @@
<executions>
<execution>
<id>get-windows-x64-jre</id>
- <phase>process-classes</phase>
+ <phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
@@ -644,7 +644,7 @@
</configuration>
<executions>
<execution>
- <id>assembly-full</id>
+ <id>assembly-full-windows-x64</id>
<phase>package</phase>
<goals>
<goal>single</goal>
1
0
15 Feb '13
Author: tchemit
Date: 2013-02-15 21:28:55 +0100 (Fri, 15 Feb 2013)
New Revision: 432
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/432
Log:
prepare release (reformat code, optimize dependencies, i18n)
Modified:
trunk/pom.xml
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplUpTodateTest.java
trunk/tutti-service/pom.xml
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDecorator.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/PersonModel.java
trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
trunk/tutti-ui-swing/pom.xml
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUI.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/pom.xml 2013-02-15 20:28:55 UTC (rev 432)
@@ -273,12 +273,6 @@
</dependency>
<dependency>
- <groupId>org.swinglabs.swingx</groupId>
- <artifactId>swingx-action</artifactId>
- <version>${swingXVersion}</version>
- </dependency>
-
- <dependency>
<groupId>com.ezware.oxbow</groupId>
<artifactId>swing-bits</artifactId>
<version>0.5.0</version>
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -53,7 +53,7 @@
LogFactory.getLog(AbstractPersistenceService.class);
private boolean debug = false;
-
+
/**
* Session factory.
*
@@ -157,19 +157,19 @@
}
protected <T extends Serializable> T load(Class<? extends T> clazz, Serializable id) {
- // TODO BLA : ajouter une annotation qui rejoue une méthode
- // avec debug=true. puis repasse à faux,
- // lorsqu'une erreur
- if (debug) {
- T load = (T) getCurrentSession().get(clazz, id);
- if (load == null) {
- throw new DataIntegrityViolationException("Unable to load entity " + clazz.getName() + " with id="+id+" : not found in database.");
- }
- }
+ // TODO BLA : ajouter une annotation qui rejoue une méthode
+ // avec debug=true. puis repasse à faux,
+ // lorsqu'une erreur
+ if (debug) {
+ T load = (T) getCurrentSession().get(clazz, id);
+ if (load == null) {
+ throw new DataIntegrityViolationException("Unable to load entity " + clazz.getName() + " with id=" + id + " : not found in database.");
+ }
+ }
T load = (T) getCurrentSession().load(clazz, id);
return load;
}
-
+
protected <T extends Serializable> T get(Class<? extends T> clazz, Serializable id) {
T load = (T) getCurrentSession().get(clazz, id);
return load;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -25,34 +25,8 @@
*/
-import static org.nuiton.i18n.I18n._;
-
-import java.io.Serializable;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.Resource;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.FlushMode;
-import org.hibernate.type.IntegerType;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.dao.DataIntegrityViolationException;
-import org.springframework.dao.DataRetrievalFailureException;
-import org.springframework.stereotype.Service;
-
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-
import fr.ifremer.adagio.core.dao.data.batch.Batch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
@@ -77,1246 +51,1262 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.service.measure.MeasurementPersistenceHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.FlushMode;
+import org.hibernate.type.IntegerType;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
@Service("batchPersistenceService")
-public class BatchPersistenceServiceImpl
- extends AbstractPersistenceService implements BatchPersistenceService, CatchBatchValidator
- {
+public class BatchPersistenceServiceImpl
+ extends AbstractPersistenceService implements BatchPersistenceService, CatchBatchValidator {
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(BatchPersistenceServiceImpl.class);
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(BatchPersistenceServiceImpl.class);
- @Resource(name = "referentialPersistenceService")
- protected ReferentialPersistenceService referentialService;
+ @Resource(name = "referentialPersistenceService")
+ protected ReferentialPersistenceService referentialService;
- @Resource(name = "denormalizedBatchDao")
- protected DenormalizedBatchDao denormalizedBatchDao;
+ @Resource(name = "denormalizedBatchDao")
+ protected DenormalizedBatchDao denormalizedBatchDao;
- @Resource(name = "sortingBatchDao")
- protected SortingBatchDao sortingBatchDao;
+ @Resource(name = "sortingBatchDao")
+ protected SortingBatchDao sortingBatchDao;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
+ @Resource(name = "catchBatchDao")
+ protected CatchBatchExtendDao catchBatchDao;
- @Resource(name = "measurementPersistenceHelper")
- protected MeasurementPersistenceHelper measurementHelper;
-
- @Override
- public void init() {
- super.init();
- catchBatchDao.registerCatchBatchValidator(this);
- }
-
- @Override
- public void close() {
- catchBatchDao.unregisterCatchBatchValidator(this);
- super.close();
- }
+ @Resource(name = "measurementPersistenceHelper")
+ protected MeasurementPersistenceHelper measurementHelper;
- @Override
- public boolean isEnable(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
- // Apply validation only on catch batch for fishingOperation
- return (catchBatch.getFishingOperation() != null);
- }
+ @Override
+ public void init() {
+ super.init();
+ catchBatchDao.registerCatchBatchValidator(this);
+ }
- @Override
- public List<CatchBatchValidationError> validate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
- List<CatchBatchValidationError> errors = Lists.newArrayList();
- validate(catchBatch.getChildBatchs(), errors, 1);
- return errors;
- }
-
- @Override
- public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) {
- Preconditions.checkNotNull(fishingOperationId);
-
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
+ @Override
+ public void close() {
+ catchBatchDao.unregisterCatchBatchValidator(this);
+ super.close();
+ }
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch source;
- try {
- source = catchBatchDao.loadFullTree(catchBatchId, true, true);
- } catch (CatchBatchValidationException e) {
- throw new DataRetrievalFailureException("Invalid batch tree structure, for fishing operation id=" + fishingOperationId, e);
- }
+ @Override
+ public boolean isEnable(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
+ // Apply validation only on catch batch for fishingOperation
+ return (catchBatch.getFishingOperation() != null);
+ }
- CatchBatch result = new CatchBatch();
- result.setId(source.getId().toString());
- result.setCatchTotalWeight(source.getWeight());
-
- // Vrac
- SortingBatch vracBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(),
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID);
- result.setCatchTotalSortedCarousselWeight(vracBatch.getWeight());
- result.setCatchTotalSortedTremisWeight(vracBatch.getWeightBeforeSampling());
- {
- // Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(vracBatch.getChildBatchs(),
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ @Override
+ public List<CatchBatchValidationError> validate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
+ List<CatchBatchValidationError> errors = Lists.newArrayList();
+ validate(catchBatch.getChildBatchs(), errors, 1);
+ return errors;
+ }
- result.setSpeciesTotalSampleSortedWeight(speciesBatch.getWeight());
- result.setSpeciesTotalSortedWeight(speciesBatch.getWeightBeforeSampling());
-
- {
- // Inert
- SortingBatch inertBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(),
- "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_INERT);
- result.setSpeciesTotalInertWeight(inertBatch.getWeight());
-
- // Alive no itemized
- SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(),
- "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_LIFE);
- result.setSpeciesTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight());
- }
-
- // TODO : Benthos, Plancton...
- }
-
- // Hors Vrac
- SortingBatch horsVracBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(),
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID);
- result.setCatchTotalUnsortedWeight(horsVracBatch.getWeight());
- {
- // Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(),
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ @Override
+ public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) {
+ Preconditions.checkNotNull(fishingOperationId);
- result.setSpeciesTotalUnsortedWeight(speciesBatch.getWeight());
-
- // TODO : Benthos, Plancton...
- }
+ Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
- // Non trié
- SortingBatch unsortedBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(),
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_UNSORTED_ID);
- result.setCatchTotalRejectedWeight(unsortedBatch.getWeight());
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch source;
+ try {
+ source = catchBatchDao.loadFullTree(catchBatchId, true, true);
+ } catch (CatchBatchValidationException e) {
+ throw new DataRetrievalFailureException("Invalid batch tree structure, for fishing operation id=" + fishingOperationId, e);
+ }
- return result;
- }
+ CatchBatch result = new CatchBatch();
+ result.setId(source.getId().toString());
+ result.setCatchTotalWeight(source.getWeight());
- @Override
-
- public CatchBatch createCatchBatch(CatchBatch bean) {
- Preconditions.checkNotNull(bean);
- Preconditions.checkArgument(bean.getId() == null);
- Preconditions.checkNotNull(bean.getFishingOperation());
- Preconditions.checkNotNull(bean.getFishingOperation().getId());
+ // Vrac
+ SortingBatch vracBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID);
+ result.setCatchTotalSortedCarousselWeight(vracBatch.getWeight());
+ result.setCatchTotalSortedTremisWeight(vracBatch.getWeightBeforeSampling());
+ {
+ // Species
+ SortingBatch speciesBatch = catchBatchDao.getSortingBatch(vracBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = fr.ifremer.adagio.core.dao.data.batch.CatchBatch.Factory.newInstance();
- beanToEntity(bean, catchBatch, true);
- catchBatch = catchBatchDao.create(catchBatch);
- bean.setId(String.valueOf(catchBatch.getId()));
+ result.setSpeciesTotalSampleSortedWeight(speciesBatch.getWeight());
+ result.setSpeciesTotalSortedWeight(speciesBatch.getWeightBeforeSampling());
- // Link to fishing operation
- getCurrentSession().flush();
- Integer fishingOperationId = Integer.valueOf(bean.getFishingOperation().getId());
- int rowUpdated = queryUpdate("updateFishingOperationCatchBatch",
- "fishingOperationId", IntegerType.INSTANCE, fishingOperationId,
- "catchBatchId", IntegerType.INSTANCE, catchBatch.getId());
- if (rowUpdated == 0) {
- throw new DataIntegrityViolationException("Could not attach catch batch to the given operation : operation was not found.");
- }
+ {
+ // Inert
+ SortingBatch inertBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(),
+ "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_INERT);
+ result.setSpeciesTotalInertWeight(inertBatch.getWeight());
- return bean;
- }
+ // Alive no itemized
+ SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(),
+ "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_LIFE);
+ result.setSpeciesTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight());
+ }
- @Override
- @CacheEvict(value = "batchTree", key="#bean.fishingOperation.id")
- public CatchBatch saveCatchBatch(CatchBatch bean) {
+ // TODO : Benthos, Plancton...
+ }
- Preconditions.checkNotNull(bean);
- Preconditions.checkNotNull(bean.getId());
+ // Hors Vrac
+ SortingBatch horsVracBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID);
+ result.setCatchTotalUnsortedWeight(horsVracBatch.getWeight());
+ {
+ // Species
+ SortingBatch speciesBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- getCurrentSession().enableFetchProfile("batch-with-childs");
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.load(Integer.valueOf(bean.getId()));
- if (catchBatch == null) {
- throw new DataRetrievalFailureException("Could not retrieve catch batch with id=" + bean.getId());
- }
+ result.setSpeciesTotalUnsortedWeight(speciesBatch.getWeight());
- beanToEntity(bean, catchBatch, true);
- catchBatchDao.update(catchBatch);
- getCurrentSession().flush();
-
- return bean;
- }
+ // TODO : Benthos, Plancton...
+ }
- @Override
- public List<SpeciesBatch> getAllRootSpeciesBatch(String fishingOperationId) {
-
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
- List<SpeciesBatch> result = new ArrayList<SpeciesBatch>();
-
- // Vrac / Species
- SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- for (Iterator<Batch> iterator = vracSpeciesBatch.getChildBatchs().iterator(); iterator.hasNext();) {
- SortingBatch source = (SortingBatch) iterator.next();
-
- // evict some special batches : Life (or Biota) and Inert
- if (source.getReferenceTaxon() != null
- && enumeration.REFERENCE_TAXON_ID_LIFE.equals(source.getReferenceTaxon().getId()) == false
- && enumeration.REFERENCE_TAXON_ID_INERT.equals(source.getReferenceTaxon().getId()) == false) {
- SpeciesBatch target = new SpeciesBatch();
-
- entityToBean(source, target);
- result.add(target);
- }
- }
-
- // Hors-Vrac / Species
- SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- for (Iterator<Batch> iterator = horsVracSpeciesBatch.getChildBatchs().iterator(); iterator.hasNext();) {
- SortingBatch source = (SortingBatch) iterator.next();
-
- SpeciesBatch target = new SpeciesBatch();
-
- entityToBean(source, target);
- result.add(target);
- }
+ // Non trié
+ SortingBatch unsortedBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_UNSORTED_ID);
+ result.setCatchTotalRejectedWeight(unsortedBatch.getWeight());
- return result;
- }
-
- protected SpeciesBatch entityToBean(SortingBatch source, SpeciesBatch target) {
+ return result;
+ }
- target.setId(source.getId().toString());
+ @Override
- // Individual count
- target.setNumber(source.getIndividualCount());
+ public CatchBatch createCatchBatch(CatchBatch bean) {
+ Preconditions.checkNotNull(bean);
+ Preconditions.checkArgument(bean.getId() == null);
+ Preconditions.checkNotNull(bean.getFishingOperation());
+ Preconditions.checkNotNull(bean.getFishingOperation().getId());
- // Convert database weight (and sampling ratio) into UI weight and sampleCategoryWeight
- if (source.getWeight() != null && source.getWeightBeforeSampling() == null) {
- target.setSampleCategoryWeight(source.getWeight());
- }
- else {
- target.setWeight(source.getWeight());
- target.setSampleCategoryWeight(source.getWeightBeforeSampling());
- }
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = fr.ifremer.adagio.core.dao.data.batch.CatchBatch.Factory.newInstance();
+ beanToEntity(bean, catchBatch, true);
+ catchBatch = catchBatchDao.create(catchBatch);
+ bean.setId(String.valueOf(catchBatch.getId()));
- // Comments
- target.setComment(source.getComments());
+ // Link to fishing operation
+ getCurrentSession().flush();
+ Integer fishingOperationId = Integer.valueOf(bean.getFishingOperation().getId());
+ int rowUpdated = queryUpdate("updateFishingOperationCatchBatch",
+ "fishingOperationId", IntegerType.INSTANCE, fishingOperationId,
+ "catchBatchId", IntegerType.INSTANCE, catchBatch.getId());
+ if (rowUpdated == 0) {
+ throw new DataIntegrityViolationException("Could not attach catch batch to the given operation : operation was not found.");
+ }
- // Sample category type (only one is applied)
- SortingMeasurement sm = null;
- if (source.getSortingMeasurements().size() == 1) {
- sm = source.getSortingMeasurements().iterator().next();
- }
- else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null){
- sm = measurementHelper.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
- }
- if (sm != null) {
- SampleCategoryEnum sampleCategory = referentialService.getSampleCategoryByPmfmId(sm.getPmfm().getId());
- if (sampleCategory != null) {
- setSampleCategoryQualitative(target, sm.getPmfm().getId(), sm.getNumericalValue(), sm.getAlphanumericalValue(), sm.getQualitativeValue().getId());
- }
- }
-
- // Species
- Integer referenceTaxonId = source.getInheritedReferenceTaxonId();
- if (referenceTaxonId == null && source.getReferenceTaxon() != null) {
- referenceTaxonId = source.getReferenceTaxon().getId();
- }
- if (referenceTaxonId != null) {
- // TODO : add cache on getSpeciesByReferenceTaxonId
- Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxonId);
- target.setSpecies(species);
- }
-
- if (target.getSampleCategoryType() != null && source.getChildBatchs().size() > 0) {
- List<SpeciesBatch> targetChilds = Lists.newArrayList();
- for (Iterator<Batch> iterator = source.getChildBatchs().iterator(); iterator.hasNext();) {
- SortingBatch sourceChild = (SortingBatch) iterator.next();
- SpeciesBatch targetChild = new SpeciesBatch();
- entityToBean(sourceChild, targetChild);
- if (targetChild.getSampleCategoryValue() != null) {
- targetChilds.add(targetChild);
- targetChild.setParentBatch(target);
- }
- }
- target.setChildBatchs(targetChilds);
- }
+ return bean;
+ }
- return target;
- }
+ @Override
+ @CacheEvict(value = "batchTree", key = "#bean.fishingOperation.id")
+ public CatchBatch saveCatchBatch(CatchBatch bean) {
- @Override
- public SpeciesBatch createSpeciesBatch(SpeciesBatch bean,
- String parentBatchId) {
- Preconditions.checkNotNull(bean);
- Preconditions.checkArgument(bean.getId() == null);
- Preconditions.checkNotNull(bean.getSpecies());
- Preconditions.checkNotNull(bean.getSpecies().getId());
- Preconditions.checkNotNull(bean.getFishingOperation());
- Preconditions.checkNotNull(bean.getFishingOperation().getId());
+ Preconditions.checkNotNull(bean);
+ Preconditions.checkNotNull(bean.getId());
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- // Load full batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(bean.getFishingOperation().getId()));
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ getCurrentSession().enableFetchProfile("batch-with-childs");
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.load(Integer.valueOf(bean.getId()));
+ if (catchBatch == null) {
+ throw new DataRetrievalFailureException("Could not retrieve catch batch with id=" + bean.getId());
+ }
- SortingBatch batch = SortingBatch.Factory.newInstance();
- beanToEntity(bean, batch, parentBatchId, catchBatch, true);
- batch = sortingBatchDao.create(batch);
+ beanToEntity(bean, catchBatch, true);
+ catchBatchDao.update(catchBatch);
+ getCurrentSession().flush();
- bean.setId(String.valueOf(batch.getId()));
+ return bean;
+ }
- getCurrentSession().flush();
+ @Override
+ public List<SpeciesBatch> getAllRootSpeciesBatch(String fishingOperationId) {
- return bean;
- }
+ // Load batch tree
+ Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- @Override
- public SpeciesBatch saveSpeciesBatch(SpeciesBatch bean) {
- Preconditions.checkNotNull(bean);
- Preconditions.checkNotNull(bean.getId());
+ List<SpeciesBatch> result = new ArrayList<SpeciesBatch>();
- // Load full batch tree
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(bean.getId()));
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ // Vrac / Species
+ SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ for (Iterator<Batch> iterator = vracSpeciesBatch.getChildBatchs().iterator(); iterator.hasNext(); ) {
+ SortingBatch source = (SortingBatch) iterator.next();
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- SortingBatch batch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(bean.getId()));
- String parentBatchId = null;
- if (bean.getParentBatch() != null) {
- parentBatchId = bean.getParentBatch().getId();
- }
- beanToEntity(bean, batch, parentBatchId, catchBatch, true);
- sortingBatchDao.update(batch);
- getCurrentSession().flush();
+ // evict some special batches : Life (or Biota) and Inert
+ if (source.getReferenceTaxon() != null
+ && enumeration.REFERENCE_TAXON_ID_LIFE.equals(source.getReferenceTaxon().getId()) == false
+ && enumeration.REFERENCE_TAXON_ID_INERT.equals(source.getReferenceTaxon().getId()) == false) {
+ SpeciesBatch target = new SpeciesBatch();
- return bean;
- }
+ entityToBean(source, target);
+ result.add(target);
+ }
+ }
- @Override
- public void deleteSpeciesBatch(String id) {
- Preconditions.checkNotNull(id);
+ // Hors-Vrac / Species
+ SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ for (Iterator<Batch> iterator = horsVracSpeciesBatch.getChildBatchs().iterator(); iterator.hasNext(); ) {
+ SortingBatch source = (SortingBatch) iterator.next();
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
+ SpeciesBatch target = new SpeciesBatch();
- catchBatchDao.removeWithChildren(Integer.valueOf(id));
+ entityToBean(source, target);
+ result.add(target);
+ }
- getCurrentSession().flush();
- }
+ return result;
+ }
- public void deleteSpeciesSubBatch(String id) {
- deleteSpeciesBatch(id);
- }
+ protected SpeciesBatch entityToBean(SortingBatch source, SpeciesBatch target) {
- public void changeSpeciesBatchSpecies(String batchId, Species species) {
- Preconditions.checkNotNull(batchId);
- Preconditions.checkNotNull(species);
- Preconditions.checkNotNull(species.getReferenceTaxonId());
+ target.setId(source.getId().toString());
- if (log.isDebugEnabled()) {
- log.debug("Changing species for batch id=" + batchId);
- }
+ // Individual count
+ target.setNumber(source.getIndividualCount());
- int rowUpdated = queryUpdate("updateBatchSpecies",
- "batchId", IntegerType.INSTANCE, Integer.valueOf(batchId),
- "referenceTaxonId", IntegerType.INSTANCE, species.getReferenceTaxonId());
- Preconditions.checkArgument(rowUpdated == 1, "Unable to update operation, to be linked with catch batch.");
- }
+ // Convert database weight (and sampling ratio) into UI weight and sampleCategoryWeight
+ if (source.getWeight() != null && source.getWeightBeforeSampling() == null) {
+ target.setSampleCategoryWeight(source.getWeight());
+ } else {
+ target.setWeight(source.getWeight());
+ target.setSampleCategoryWeight(source.getWeightBeforeSampling());
+ }
- public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(
- String speciesBatchId) {
- List<SpeciesBatchFrequency> results = Lists.newArrayList();
-
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(speciesBatchId));
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
- if (catchBatchId == null) {
- return results;
- }
-
- SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(speciesBatchId));
-
- for (Iterator<Batch> iterator = sortingBatch.getChildBatchs().iterator(); iterator.hasNext();) {
- SortingBatch source = (SortingBatch) iterator.next();
- SpeciesBatchFrequency target = new SpeciesBatchFrequency();
-
- entityToBean(source, target);
- results.add(target);
- }
- return results;
- }
-
- protected void entityToBean(SortingBatch source, SpeciesBatchFrequency target) {
+ // Comments
+ target.setComment(source.getComments());
- target.setId(source.getId().toString());
+ // Sample category type (only one is applied)
+ SortingMeasurement sm = null;
+ if (source.getSortingMeasurements().size() == 1) {
+ sm = source.getSortingMeasurements().iterator().next();
+ } else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) {
+ sm = measurementHelper.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
+ }
+ if (sm != null) {
+ SampleCategoryEnum sampleCategory = referentialService.getSampleCategoryByPmfmId(sm.getPmfm().getId());
+ if (sampleCategory != null) {
+ setSampleCategoryQualitative(target, sm.getPmfm().getId(), sm.getNumericalValue(), sm.getAlphanumericalValue(), sm.getQualitativeValue().getId());
+ }
+ }
- target.setNumber(source.getIndividualCount());
- target.setWeight(source.getWeight());
- target.setComment(source.getComments());
+ // Species
+ Integer referenceTaxonId = source.getInheritedReferenceTaxonId();
+ if (referenceTaxonId == null && source.getReferenceTaxon() != null) {
+ referenceTaxonId = source.getReferenceTaxon().getId();
+ }
+ if (referenceTaxonId != null) {
+ // TODO : add cache on getSpeciesByReferenceTaxonId
+ Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxonId);
+ target.setSpecies(species);
+ }
- // Length step category
- if (source.getSortingMeasurements().size() == 1) {
- SortingMeasurement sm = source.getSortingMeasurements().iterator().next();
- if (sm.getPmfm() != null && sm.getPmfm().getId() != null) {
- Caracteristic lengthStepCaracteristic = referentialService.getCaracteristic(sm.getPmfm().getId());
- target.setLengthStepCaracteristic(lengthStepCaracteristic);
- }
-
- // Length
- target.setLengthStep(sm.getNumericalValue());
- }
- }
+ if (target.getSampleCategoryType() != null && source.getChildBatchs().size() > 0) {
+ List<SpeciesBatch> targetChilds = Lists.newArrayList();
+ for (Iterator<Batch> iterator = source.getChildBatchs().iterator(); iterator.hasNext(); ) {
+ SortingBatch sourceChild = (SortingBatch) iterator.next();
+ SpeciesBatch targetChild = new SpeciesBatch();
+ entityToBean(sourceChild, targetChild);
+ if (targetChild.getSampleCategoryValue() != null) {
+ targetChilds.add(targetChild);
+ targetChild.setParentBatch(target);
+ }
+ }
+ target.setChildBatchs(targetChilds);
+ }
- public List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(
- String speciesBatchId, List<SpeciesBatchFrequency> frequencies) {
- Preconditions.checkNotNull(speciesBatchId);
- Preconditions.checkNotNull(frequencies);
+ return target;
+ }
- if (frequencies.size() == 0) {
- return frequencies;
- }
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(speciesBatchId));
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ @Override
+ public SpeciesBatch createSpeciesBatch(SpeciesBatch bean,
+ String parentBatchId) {
+ Preconditions.checkNotNull(bean);
+ Preconditions.checkArgument(bean.getId() == null);
+ Preconditions.checkNotNull(bean.getSpecies());
+ Preconditions.checkNotNull(bean.getSpecies().getId());
+ Preconditions.checkNotNull(bean.getFishingOperation());
+ Preconditions.checkNotNull(bean.getFishingOperation().getId());
- if (catchBatch == null) {
- return frequencies;
- }
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
- // Retrieve parent
- SortingBatch parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(speciesBatchId));
-
- // Remember child ids, to remove unchanged item (see at bottom in this method)
- List<Integer> notUpdatedChildIds = Lists.newArrayList();
- for (Iterator<Batch> iterator = parentBatch.getChildBatchs().iterator(); iterator.hasNext();) {
- SortingBatch sortingBatch = (SortingBatch) iterator.next();
- notUpdatedChildIds.add(sortingBatch.getId());
- }
+ // Load full batch tree
+ Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(bean.getFishingOperation().getId()));
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- short rankOrder = 0;
- String pmfmId = null;
- List<SortingBatch> batchsToUpdate = Lists.newArrayList();
- for (SpeciesBatchFrequency source : frequencies) {
- rankOrder++;
+ SortingBatch batch = SortingBatch.Factory.newInstance();
+ beanToEntity(bean, batch, parentBatchId, catchBatch, true);
+ batch = sortingBatchDao.create(batch);
- // Check that all frequencies have the same length PMFM
- if (pmfmId == null) {
- source.getLengthStepCaracteristic().getId();
- } else if (!pmfmId.equals(source.getLengthStepCaracteristic().getId())) {
- throw new DataIntegrityViolationException("Batch frequencies under one Speciesbatch must have all the same lengthStepCaracteristic");
- }
+ bean.setId(String.valueOf(batch.getId()));
- // Not existing batch
- SortingBatch target = null;
- if (source.getId() == null) {
- target = SortingBatch.Factory.newInstance();
+ getCurrentSession().flush();
- // Fill the sorting batch from the source
- beanToEntity(source, target, parentBatch, rankOrder, true);
+ return bean;
+ }
- // Create the targeted batch, then update the source id
- sortingBatchDao.create(target);
- source.setId(target.getId().toString());
- }
+ @Override
+ public SpeciesBatch saveSpeciesBatch(SpeciesBatch bean) {
+ Preconditions.checkNotNull(bean);
+ Preconditions.checkNotNull(bean.getId());
- // Existing batch
- else {
- target = sortingBatchDao.load(Integer.valueOf(source.getId()));
+ // Load full batch tree
+ Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(bean.getId()));
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- // Fill the sorting batch from the source
- beanToEntity(source, target, parentBatch, rankOrder, true);
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
- // Add the batch into a list (will be update later, using this list)
- batchsToUpdate.add(target);
-
- notUpdatedChildIds.remove(target.getId());
- }
- }
+ SortingBatch batch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(bean.getId()));
+ String parentBatchId = null;
+ if (bean.getParentBatch() != null) {
+ parentBatchId = bean.getParentBatch().getId();
+ }
+ beanToEntity(bean, batch, parentBatchId, catchBatch, true);
+ sortingBatchDao.update(batch);
+ getCurrentSession().flush();
- // If some batchs need to be update, do it
- if (batchsToUpdate.size() > 0) {
- sortingBatchDao.update(batchsToUpdate);
- }
-
- if (notUpdatedChildIds.size() > 0) {
- for (Iterator<Integer> iterator = notUpdatedChildIds.iterator(); iterator.hasNext();) {
- Integer batchId = iterator.next();
- catchBatchDao.removeWithChildren(batchId);
- }
- }
-
- getCurrentSession().flush();
+ return bean;
+ }
- return frequencies;
- }
+ @Override
+ public void deleteSpeciesBatch(String id) {
+ Preconditions.checkNotNull(id);
- // ------------------------------------------------------------------------//
- // -- Internal methods --//
- // ------------------------------------------------------------------------//
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
- protected void validate(Collection<Batch> batchs, List<CatchBatchValidationError> errors, int treeLevel) {
-
- List<Integer> expectedPmfms = null;
- boolean expectedReferenceTaxon = false;
- // First tree level : should have pmfm SORTED (Vrac, Hors Vrac, Non trié)
- if (treeLevel == 1) {
- expectedPmfms = Lists.newArrayList(enumeration.PMFM_ID_SORTED_UNSORTED);
- }
- // Second tree level : should have pmfm SORTING_TYPE (Species, Benthos...)
- else if (treeLevel == 2) {
- expectedPmfms = Lists.newArrayList(enumeration.PMFM_ID_SORTING_TYPE);
- }
- else if (treeLevel == 3) {
- expectedReferenceTaxon = true;
- }
- else if (treeLevel > 3) {
- expectedPmfms = referentialService.getSampleCategoryIds();
- expectedPmfms.remove(enumeration.PMFM_ID_SORTED_UNSORTED);
- }
-
- // First level : should be only PMFM=SORTED
- for (Iterator<Batch> iterator = batchs.iterator(); iterator.hasNext();) {
- SortingBatch batch = (SortingBatch) iterator.next();
- boolean batchHasError = false;
-
- // For all sorting measurements
- if (batch.getSortingMeasurements() != null && batch.getSortingMeasurements().size() > 0) {
- for (Iterator<SortingMeasurement> iterator2 = batch.getSortingMeasurements().iterator(); iterator2.hasNext();) {
- SortingMeasurement sm = iterator2.next();
- Integer pmfmId = sm.getPmfm().getId();
- if (expectedReferenceTaxon) {
- CatchBatchValidationError error = new CatchBatchValidationError(
- "tutti.persistence.batch.validation.onlyTaxonButPmfmFound",
- _("tutti.persistence.batch.validation.onlyTaxonButPmfmFound", batch.getId(), pmfmId),
- CatchBatchValidationError.GRAVITY_ERROR);
- errors.add(error);
- }
- else if (expectedPmfms.contains(pmfmId) == false) {
- if (sm.getNumericalValue() == null || batch.getChildBatchs().size() > 0) {
- batchHasError = true;
- CatchBatchValidationError error = new CatchBatchValidationError(
- "tutti.persistence.batch.validation.pmfmNotFound",
- _("tutti.persistence.batch.validation.pmfmNotFound",
- batch.getId(), Arrays.toString(expectedPmfms.toArray()), pmfmId),
- CatchBatchValidationError.GRAVITY_ERROR);
- errors.add(error);
- }
- }
- }
- }
- else if (expectedPmfms != null && expectedPmfms.size() > 0){
- batchHasError = true;
- CatchBatchValidationError error = new CatchBatchValidationError(
- "tutti.persistence.batch.validation.pmfmNotFound",
- _("tutti.persistence.batch.validation.pmfmNotFound",
- batch.getId(), Arrays.toString(expectedPmfms.toArray()), "null"),
- CatchBatchValidationError.GRAVITY_ERROR);
- errors.add(error);
- }
-
- if (!batchHasError && expectedReferenceTaxon == true && batch.getReferenceTaxon() == null) {
- CatchBatchValidationError error = new CatchBatchValidationError(
- "tutti.persistence.batch.validation.referenceTaxonNotFound",
- _("tutti.persistence.batch.validation.referenceTaxonNotFound", batch.getId()),
- CatchBatchValidationError.GRAVITY_ERROR);
- errors.add(error);
- }
-
- if (!batchHasError) {
- validate(batch.getChildBatchs(), errors, treeLevel+1);
- }
- }
- }
-
- protected void beanToEntity(SpeciesBatch source,
- SortingBatch target,
- String parentBatchId,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
- boolean copyIfNull) {
- Preconditions.checkNotNull(source.getFishingOperation());
- Preconditions.checkNotNull(source.getFishingOperation().getId());
+ catchBatchDao.removeWithChildren(Integer.valueOf(id));
- // Retrieve recorder department
- Integer recorderDepartmentId = getRecorderDepartmentId();
+ getCurrentSession().flush();
+ }
- // Create lists to store all updates, then remove not updated items
- Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
- if (target.getQuantificationMeasurements() != null) {
- notChangedQuantificationMeasurements.addAll(target.getQuantificationMeasurements());
- }
- Set<SortingMeasurement> notChangedSortingMeasurements = new HashSet<SortingMeasurement>();
- if (target.getSortingMeasurements() != null) {
- notChangedSortingMeasurements.addAll(target.getSortingMeasurements());
- }
+ public void deleteSpeciesSubBatch(String id) {
+ deleteSpeciesBatch(id);
+ }
- // If parent and root need to be set
- if (target.getId() == null
- || target.getRootBatch() == null
- || (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) {
- setBatchParents(source, target, parentBatchId, catchBatch);
- }
+ public void changeSpeciesBatchSpecies(String batchId, Species species) {
+ Preconditions.checkNotNull(batchId);
+ Preconditions.checkNotNull(species);
+ Preconditions.checkNotNull(species.getReferenceTaxonId());
- // RankOrder (initialize once, at creation)
- if (target.getRankOrder() == null) {
- // Start rank order at 3, because of special batches 'Biota' and 'Inert'
- short rankOrder = (short) 3;
- if (source.getParentBatch() != null && source.getParentBatch().getChildBatchs() != null) {
- // TODO BL : vérifier cela (est-ce que l'item est ajouté à son père AVANT d'être passé au service ?)
- rankOrder += (short) source.getParentBatch().getChildBatchs().size();
- }
- target.setRankOrder(rankOrder);
- }
-
- // Force subgroup count to '1', as Allegro
- target.setSubgroupCount(1f);
+ if (log.isDebugEnabled()) {
+ log.debug("Changing species for batch id=" + batchId);
+ }
- // Weight or SampleCategoryWeight
- if (copyIfNull && source.getWeight() == null && source.getSampleCategoryWeight() == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- } else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- }
+ int rowUpdated = queryUpdate("updateBatchSpecies",
+ "batchId", IntegerType.INSTANCE, Integer.valueOf(batchId),
+ "referenceTaxonId", IntegerType.INSTANCE, species.getReferenceTaxonId());
+ Preconditions.checkArgument(rowUpdated == 1, "Unable to update operation, to be linked with catch batch.");
+ }
- // Sampling Ratio
- if (copyIfNull && (source.getSampleCategoryWeight() == null || source.getWeight() == null)) {
- target.setSamplingRatio(null);
- target.setSamplingRatioText(null);
- } else if (source.getSampleCategoryWeight() != null && source.getWeight() != null) {
- String samplingRatioText = source.getWeight() + "/" + source.getSampleCategoryWeight();
- samplingRatioText = samplingRatioText.replaceAll(",", ".");
- target.setSamplingRatioText(samplingRatioText);
- target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight());
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- }
+ public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(
+ String speciesBatchId) {
+ List<SpeciesBatchFrequency> results = Lists.newArrayList();
- // Sorting measurement
- if (copyIfNull && (source.getSampleCategoryType() == null || source.getSampleCategoryValue() == null)) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else if (source.getSampleCategoryType() != null && source.getSampleCategoryValue() != null) {
- Integer pmfmId = measurementHelper.sampleCategory2PmfmId(source.getSampleCategoryType());
- // Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
- if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
- SortingMeasurement sortingMeasurement = measurementHelper.setSortingMeasurement(target, recorderDepartmentId,
- source.getSampleCategoryType(), source.getSampleCategoryValue());
- notChangedSortingMeasurements.remove(sortingMeasurement);
- }
- }
+ Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(speciesBatchId));
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- // Individual count
- if (copyIfNull && source.getNumber() == null) {
- target.setIndividualCount(null);
- } else if (source.getNumber() != null) {
- target.setIndividualCount(source.getNumber());
- }
+ if (catchBatchId == null) {
+ return results;
+ }
- // Species
- if (copyIfNull && (source.getSpecies() == null || parentBatchId != null)) {
- target.setReferenceTaxon(null);
- } else if (source.getSpecies() != null && parentBatchId == null) {
- ReferenceTaxon referenceTaxon = load(ReferenceTaxonImpl.class, source.getSpecies().getReferenceTaxonId());
- target.setReferenceTaxon(referenceTaxon);
- }
+ SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(speciesBatchId));
- // QualityFlag
- if (source.isSpeciesToConfirm()) {
- target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_DOUBTFUL));
- } else {
- target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
- }
+ for (Iterator<Batch> iterator = sortingBatch.getChildBatchs().iterator(); iterator.hasNext(); ) {
+ SortingBatch source = (SortingBatch) iterator.next();
+ SpeciesBatchFrequency target = new SpeciesBatchFrequency();
- // Comments
- if (copyIfNull && source.getComment() == null) {
- target.setComments(null);
- } else if (source.getComment() != null) {
- target.setComments(source.getComment());
- }
-
- // Exhaustive inventory (always true under a species batch)
- target.setExhaustiveInventory(true);
+ entityToBean(source, target);
+ results.add(target);
+ }
+ return results;
+ }
- // Removed not changed measurements (in sorting and quantification measurement lists)
- if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
- for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
- target.getQuantificationMeasurements().remove(qm);
- }
- }
- if (target.getSortingMeasurements() != null && notChangedSortingMeasurements.size() > 0) {
- for (SortingMeasurement sm : notChangedSortingMeasurements) {
- target.getSortingMeasurements().remove(sm);
- }
- }
- }
+ protected void entityToBean(SortingBatch source, SpeciesBatchFrequency target) {
- public void setBatchParents(SpeciesBatch source, SortingBatch target, String parentBatchIdStr,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
+ target.setId(source.getId().toString());
- Preconditions.checkNotNull(target);
- Preconditions.checkNotNull(source.getFishingOperation());
- Preconditions.checkNotNull(source.getFishingOperation().getId());
+ target.setNumber(source.getIndividualCount());
+ target.setWeight(source.getWeight());
+ target.setComment(source.getComments());
- // Load existing parent and root
- SortingBatch parentBatch = null;
- if (parentBatchIdStr != null) {
- parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
- }
-
- // Or retrieve parent batch, from pmfm id
- else {
- // Retrieve category type
- Integer pmfmId = measurementHelper.sampleCategory2PmfmId(source.getSampleCategoryType());
- if (pmfmId == null || !pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
- throw new DataIntegrityViolationException(MessageFormat.format(
- "A species batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
- SampleCategoryEnum.sortedUnsorted.name(),
- enumeration.PMFM_ID_SORTED_UNSORTED));
- }
- Integer qualitativeValueId = convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue());
-
- parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
- "pmfmId", pmfmId, qualitativeValueId,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ // Length step category
+ if (source.getSortingMeasurements().size() == 1) {
+ SortingMeasurement sm = source.getSortingMeasurements().iterator().next();
+ if (sm.getPmfm() != null && sm.getPmfm().getId() != null) {
+ Caracteristic lengthStepCaracteristic = referentialService.getCaracteristic(sm.getPmfm().getId());
+ target.setLengthStepCaracteristic(lengthStepCaracteristic);
+ }
- // Parent Batch
- target.setParentBatch(parentBatch);
- }
+ // Length
+ target.setLengthStep(sm.getNumericalValue());
+ }
+ }
-
- if (parentBatch == null) {
- throw new DataIntegrityViolationException(
- "Could not retrieve parent batch, for a given speciesBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a SpeciesBatch.");
- }
-
- // Parent Batch
- target.setParentBatch(parentBatch);
- target.setRootBatch(catchBatch);
- }
+ public List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(
+ String speciesBatchId, List<SpeciesBatchFrequency> frequencies) {
+ Preconditions.checkNotNull(speciesBatchId);
+ Preconditions.checkNotNull(frequencies);
- Integer convertSampleCategoryValueIntoQualitativeId(Serializable value) {
- if (value == null)
- return null;
- Integer qualitativeValueId = null;
- if (value instanceof CaracteristicQualitativeValue) {
- CaracteristicQualitativeValue cqValue = (CaracteristicQualitativeValue) value;
- qualitativeValueId = Integer.valueOf(cqValue.getId());
- } else if (value instanceof String) {
- qualitativeValueId = Integer.valueOf((String) value);
- }
- return qualitativeValueId;
- }
+ if (frequencies.size() == 0) {
+ return frequencies;
+ }
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
- protected void setSampleCategoryQualitative(SpeciesBatch target, Integer pmfmId, Float numericalvalue, String alphanumericalValue,
- Integer qualitativeValueId) {
- // skip if null or corresponding to the SORTING_TYPE PMFM (Expèce, Benthos, Plancton, etc.)
- if (pmfmId == null || pmfmId.equals(enumeration.PMFM_ID_SORTING_TYPE)) {
- return;
- }
+ Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(speciesBatchId));
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- SampleCategoryEnum sampleCategory = referentialService.getSampleCategoryByPmfmId(pmfmId);
- Preconditions.checkNotNull(sampleCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId);
+ if (catchBatch == null) {
+ return frequencies;
+ }
- target.setSampleCategoryType(sampleCategory);
- if (numericalvalue != null) {
- target.setSampleCategoryValue(numericalvalue);
- return;
- }
- if (alphanumericalValue != null) {
- target.setSampleCategoryValue(alphanumericalValue);
- return;
- }
+ // Retrieve parent
+ SortingBatch parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(speciesBatchId));
- Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
- if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
- return;
- }
- CaracteristicQualitativeValue value = null;
- for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
- if (qualitativeValueId == Integer.parseInt(qv.getId())) {
- value = qv;
- break;
- }
- }
- target.setSampleCategoryValue(value);
- }
+ // Remember child ids, to remove unchanged item (see at bottom in this method)
+ List<Integer> notUpdatedChildIds = Lists.newArrayList();
+ for (Iterator<Batch> iterator = parentBatch.getChildBatchs().iterator(); iterator.hasNext(); ) {
+ SortingBatch sortingBatch = (SortingBatch) iterator.next();
+ notUpdatedChildIds.add(sortingBatch.getId());
+ }
- protected void beanToEntity(SpeciesBatchFrequency source, SortingBatch target, SortingBatch parentBatch, short rankOrder, boolean copyIfNull) {
- Preconditions.checkNotNull(source.getBatch());
- Preconditions.checkNotNull(source.getBatch().getId());
+ short rankOrder = 0;
+ String pmfmId = null;
+ List<SortingBatch> batchsToUpdate = Lists.newArrayList();
+ for (SpeciesBatchFrequency source : frequencies) {
+ rankOrder++;
- // Retrieve recorder department
- Integer recorderDepartmentId = getRecorderDepartmentId();
+ // Check that all frequencies have the same length PMFM
+ if (pmfmId == null) {
+ source.getLengthStepCaracteristic().getId();
+ } else if (!pmfmId.equals(source.getLengthStepCaracteristic().getId())) {
+ throw new DataIntegrityViolationException("Batch frequencies under one Speciesbatch must have all the same lengthStepCaracteristic");
+ }
- // Create lists to store all updates, then remove not updated items
- Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
- if (target.getQuantificationMeasurements() != null) {
- notChangedQuantificationMeasurements.addAll(target.getQuantificationMeasurements());
- }
- Set<SortingMeasurement> notChangedSortingMeasurements = new HashSet<SortingMeasurement>();
- if (target.getSortingMeasurements() != null) {
- notChangedSortingMeasurements.addAll(target.getSortingMeasurements());
- }
+ // Not existing batch
+ SortingBatch target = null;
+ if (source.getId() == null) {
+ target = SortingBatch.Factory.newInstance();
- // If parent and root need to be set
- if (target.getId() == null
- || target.getRootBatch() == null
- || (target.getParentBatch() != null && !target.getParentBatch().getId().equals(parentBatch.getId()))) {
+ // Fill the sorting batch from the source
+ beanToEntity(source, target, parentBatch, rankOrder, true);
- target.setParentBatch(parentBatch);
- target.setRootBatch(parentBatch.getRootBatch());
- }
+ // Create the targeted batch, then update the source id
+ sortingBatchDao.create(target);
+ source.setId(target.getId().toString());
+ }
- // RankOrder
- target.setRankOrder(rankOrder);
+ // Existing batch
+ else {
+ target = sortingBatchDao.load(Integer.valueOf(source.getId()));
- // Weight or SampleCategoryWeight
- if (copyIfNull && source.getWeight() == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else if (source.getWeight() != null) {
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- }
+ // Fill the sorting batch from the source
+ beanToEntity(source, target, parentBatch, rankOrder, true);
- // Sorting measurement
- if (copyIfNull && (source.getLengthStepCaracteristic() == null || source.getLengthStep() == null)) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else if (source.getLengthStepCaracteristic() != null && source.getLengthStep() != null) {
- Integer pmfmId = Integer.valueOf(source.getLengthStepCaracteristic().getId());
- SortingMeasurement sortingMeasurement = measurementHelper.setSortingMeasurement(target, recorderDepartmentId, pmfmId,
- source.getLengthStep());
- notChangedSortingMeasurements.remove(sortingMeasurement);
- }
+ // Add the batch into a list (will be update later, using this list)
+ batchsToUpdate.add(target);
- // Individual count
- if (copyIfNull && source.getNumber() == null) {
- target.setIndividualCount(null);
- } else if (source.getNumber() != null) {
- target.setIndividualCount(source.getNumber());
- }
+ notUpdatedChildIds.remove(target.getId());
+ }
+ }
- // Species
- target.setReferenceTaxon(null);
+ // If some batchs need to be update, do it
+ if (batchsToUpdate.size() > 0) {
+ sortingBatchDao.update(batchsToUpdate);
+ }
- // QualityFlag
- target.setQualityFlag(parentBatch.getQualityFlag());
+ if (notUpdatedChildIds.size() > 0) {
+ for (Iterator<Integer> iterator = notUpdatedChildIds.iterator(); iterator.hasNext(); ) {
+ Integer batchId = iterator.next();
+ catchBatchDao.removeWithChildren(batchId);
+ }
+ }
- // Comments
- if (copyIfNull && source.getComment() == null) {
- target.setComments(null);
- } else if (source.getComment() != null) {
- target.setComments(source.getComment());
- }
-
- // Exhaustive inventory (always true under a species batch)
- target.setExhaustiveInventory(true);
+ getCurrentSession().flush();
- // Removed not changed measurements (in sorting and quantification measurement lists)
- if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
- for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
- target.getQuantificationMeasurements().remove(qm);
- }
- }
- if (target.getSortingMeasurements() != null && notChangedSortingMeasurements.size() > 0) {
- for (SortingMeasurement sm : notChangedSortingMeasurements) {
- target.getSortingMeasurements().remove(sm);
- }
- }
- }
+ return frequencies;
+ }
- protected UIWeight convertDatabase2UI(Float weight, Float samplingRatio, String samplingRatioText) {
- UIWeight result = new UIWeight();
+ // ------------------------------------------------------------------------//
+ // -- Internal methods --//
+ // ------------------------------------------------------------------------//
- // Weight & sampleCategory Weight
- if (samplingRatio == null) {
- result.sampleCategoryWeight = weight;
- } else if (weight != null) {
- String startStr = weight.toString().replace(',', '.') + "/";
- if (samplingRatioText != null && samplingRatioText.startsWith(startStr)) {
- String weightStr = samplingRatioText.substring(startStr.length());
- if (weightStr != null && !weightStr.isEmpty()) {
- result.sampleCategoryWeight = Float.parseFloat(weightStr);
- result.weight = weight;
- }
- } else {
- result.sampleCategoryWeight = weight;
- }
- }
- return result;
- }
+ protected void validate(Collection<Batch> batchs, List<CatchBatchValidationError> errors, int treeLevel) {
- static class UIWeight {
- Float sampleCategoryWeight = null;
+ List<Integer> expectedPmfms = null;
+ boolean expectedReferenceTaxon = false;
+ // First tree level : should have pmfm SORTED (Vrac, Hors Vrac, Non trié)
+ if (treeLevel == 1) {
+ expectedPmfms = Lists.newArrayList(enumeration.PMFM_ID_SORTED_UNSORTED);
+ }
+ // Second tree level : should have pmfm SORTING_TYPE (Species, Benthos...)
+ else if (treeLevel == 2) {
+ expectedPmfms = Lists.newArrayList(enumeration.PMFM_ID_SORTING_TYPE);
+ } else if (treeLevel == 3) {
+ expectedReferenceTaxon = true;
+ } else if (treeLevel > 3) {
+ expectedPmfms = referentialService.getSampleCategoryIds();
+ expectedPmfms.remove(enumeration.PMFM_ID_SORTED_UNSORTED);
+ }
- Float weight = null;
- }
+ // First level : should be only PMFM=SORTED
+ for (Iterator<Batch> iterator = batchs.iterator(); iterator.hasNext(); ) {
+ SortingBatch batch = (SortingBatch) iterator.next();
+ boolean batchHasError = false;
- protected void beanToEntity(CatchBatch source,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch target,
- boolean copyIfNull) {
- Preconditions.checkNotNull(source.getFishingOperation());
- Preconditions.checkNotNull(source.getFishingOperation().getId());
+ // For all sorting measurements
+ if (batch.getSortingMeasurements() != null && batch.getSortingMeasurements().size() > 0) {
+ for (Iterator<SortingMeasurement> iterator2 = batch.getSortingMeasurements().iterator(); iterator2.hasNext(); ) {
+ SortingMeasurement sm = iterator2.next();
+ Integer pmfmId = sm.getPmfm().getId();
+ if (expectedReferenceTaxon) {
+ CatchBatchValidationError error = new CatchBatchValidationError(
+ "tutti.persistence.batch.validation.onlyTaxonButPmfmFound",
+ _("tutti.persistence.batch.validation.onlyTaxonButPmfmFound", batch.getId(), pmfmId),
+ CatchBatchValidationError.GRAVITY_ERROR);
+ errors.add(error);
+ } else if (expectedPmfms.contains(pmfmId) == false) {
+ if (sm.getNumericalValue() == null || batch.getChildBatchs().size() > 0) {
+ batchHasError = true;
+ CatchBatchValidationError error = new CatchBatchValidationError(
+ "tutti.persistence.batch.validation.pmfmNotFound",
+ _("tutti.persistence.batch.validation.pmfmNotFound",
+ batch.getId(), Arrays.toString(expectedPmfms.toArray()), pmfmId),
+ CatchBatchValidationError.GRAVITY_ERROR);
+ errors.add(error);
+ }
+ }
+ }
+ } else if (expectedPmfms != null && expectedPmfms.size() > 0) {
+ batchHasError = true;
+ CatchBatchValidationError error = new CatchBatchValidationError(
+ "tutti.persistence.batch.validation.pmfmNotFound",
+ _("tutti.persistence.batch.validation.pmfmNotFound",
+ batch.getId(), Arrays.toString(expectedPmfms.toArray()), "null"),
+ CatchBatchValidationError.GRAVITY_ERROR);
+ errors.add(error);
+ }
- // Retrieve recorder department
- Integer recorderDepartmentId = getRecorderDepartmentId();
+ if (!batchHasError && expectedReferenceTaxon == true && batch.getReferenceTaxon() == null) {
+ CatchBatchValidationError error = new CatchBatchValidationError(
+ "tutti.persistence.batch.validation.referenceTaxonNotFound",
+ _("tutti.persistence.batch.validation.referenceTaxonNotFound", batch.getId()),
+ CatchBatchValidationError.GRAVITY_ERROR);
+ errors.add(error);
+ }
- // First initialization (when created)
- Integer fishingOperationId = Integer.valueOf(source.getFishingOperation().getId());
- target.setFishingOperation(load(FishingOperationImpl.class, fishingOperationId));
+ if (!batchHasError) {
+ validate(batch.getChildBatchs(), errors, treeLevel + 1);
+ }
+ }
+ }
- target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
- target.setRankOrder((short) 1);
- target.setSynchronizationStatus(SynchronizationStatus.DIRTY.getValue());
+ protected void beanToEntity(SpeciesBatch source,
+ SortingBatch target,
+ String parentBatchId,
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
+ boolean copyIfNull) {
+ Preconditions.checkNotNull(source.getFishingOperation());
+ Preconditions.checkNotNull(source.getFishingOperation().getId());
- // Create lists to store all updates, then remove not updated items
- Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
- if (target.getQuantificationMeasurements() != null) {
- notChangedQuantificationMeasurements.addAll(target.getQuantificationMeasurements());
- }
+ // Retrieve recorder department
+ Integer recorderDepartmentId = getRecorderDepartmentId();
- // Total Weight
- if (copyIfNull && source.getCatchTotalWeight() == null) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else if (source.getCatchTotalWeight() != null) {
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getCatchTotalWeight(), true);
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- }
+ // Create lists to store all updates, then remove not updated items
+ Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
+ if (target.getQuantificationMeasurements() != null) {
+ notChangedQuantificationMeasurements.addAll(target.getQuantificationMeasurements());
+ }
+ Set<SortingMeasurement> notChangedSortingMeasurements = new HashSet<SortingMeasurement>();
+ if (target.getSortingMeasurements() != null) {
+ notChangedSortingMeasurements.addAll(target.getSortingMeasurements());
+ }
- // Removed not changed measurements (in sorting and quantification measurement lists)
- if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
- for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
- target.getQuantificationMeasurements().remove(qm);
- }
- }
- Map<Integer, SortingBatch> catchBatchChilds = getChildsMap(target, enumeration.PMFM_ID_SORTED_UNSORTED);
+ // If parent and root need to be set
+ if (target.getId() == null
+ || target.getRootBatch() == null
+ || (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) {
+ setBatchParents(source, target, parentBatchId, catchBatch);
+ }
- // -----------------------------------------------------------------------------
- // Sorted Vrac
- // -----------------------------------------------------------------------------
- {
- SortingBatch batch = catchBatchChilds.get(enumeration.QUALITATIVE_VRAC_ID);
- if (batch == null) {
- batch = SortingBatch.Factory.newInstance();
- target.getChildBatchs().add(batch);
- }
- beanToEntitySortingBatch(target, target, batch, recorderDepartmentId,
- enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- source.getCatchTotalSortedCarousselWeight(), source.getCatchTotalSortedTremisWeight(),
- copyIfNull);
- batch.setRankOrder((short) 1);
+ // RankOrder (initialize once, at creation)
+ if (target.getRankOrder() == null) {
+ // Start rank order at 3, because of special batches 'Biota' and 'Inert'
+ short rankOrder = (short) 3;
+ if (source.getParentBatch() != null && source.getParentBatch().getChildBatchs() != null) {
+ // TODO BL : vérifier cela (est-ce que l'item est ajouté à son père AVANT d'être passé au service ?)
+ rankOrder += (short) source.getParentBatch().getChildBatchs().size();
+ }
+ target.setRankOrder(rankOrder);
+ }
- // Manage childs :
- {
- Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
+ // Force subgroup count to '1', as Allegro
+ target.setSubgroupCount(1f);
- // -----------------------------------------------------------------------------
- // Sorted Vrac / Species
- // -----------------------------------------------------------------------------
- SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- if (speciesBatch == null) {
- speciesBatch = SortingBatch.Factory.newInstance();
- if (batch.getChildBatchs() == null) {
- batch.setChildBatchs(Lists.newArrayList((Batch) speciesBatch));
- } else {
- batch.getChildBatchs().add(speciesBatch);
- }
- }
- beanToEntitySortingBatch(target, batch, speciesBatch, recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- source.getSpeciesTotalSampleSortedWeight(), source.getSpeciesTotalSortedWeight(),
- copyIfNull);
- speciesBatch.setRankOrder((short) 1);
+ // Weight or SampleCategoryWeight
+ if (copyIfNull && source.getWeight() == null && source.getSampleCategoryWeight() == null) {
+ // Nothing to do : will be removed later, using notChangedSortingMeasurements
+ } else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
+ QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
+ notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ } else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
+ QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ }
- {
-
- // -----------------------------------------------------------------------------
- // Sorted Vrac / Species / Alive not itemized
- // -----------------------------------------------------------------------------
- SortingBatch aliveNotItemizedBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(), "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_LIFE);
- if (aliveNotItemizedBatch == null) {
- aliveNotItemizedBatch = SortingBatch.Factory.newInstance();
- if (speciesBatch.getChildBatchs() == null) {
- speciesBatch.setChildBatchs(Lists.newArrayList((Batch) aliveNotItemizedBatch));
- } else {
- speciesBatch.getChildBatchs().add(aliveNotItemizedBatch);
- }
- }
- beanToEntityReferenceTaxonBatch(target, speciesBatch, aliveNotItemizedBatch, recorderDepartmentId,
- enumeration.REFERENCE_TAXON_ID_LIFE,
- source.getSpeciesTotalLivingNotItemizedWeight(), null,
- copyIfNull);
- aliveNotItemizedBatch.setRankOrder((short) 1);
+ // Sampling Ratio
+ if (copyIfNull && (source.getSampleCategoryWeight() == null || source.getWeight() == null)) {
+ target.setSamplingRatio(null);
+ target.setSamplingRatioText(null);
+ } else if (source.getSampleCategoryWeight() != null && source.getWeight() != null) {
+ String samplingRatioText = source.getWeight() + "/" + source.getSampleCategoryWeight();
+ samplingRatioText = samplingRatioText.replaceAll(",", ".");
+ target.setSamplingRatioText(samplingRatioText);
+ target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight());
+ QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ }
- // -----------------------------------------------------------------------------
- // Sorted Vrac / Species / Inert (not alive)
- // -----------------------------------------------------------------------------
- SortingBatch inertBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(), "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_INERT);
- if (inertBatch == null) {
- inertBatch = SortingBatch.Factory.newInstance();
- speciesBatch.getChildBatchs().add(inertBatch);
- }
- beanToEntityReferenceTaxonBatch(target, speciesBatch, inertBatch, recorderDepartmentId,
- enumeration.REFERENCE_TAXON_ID_INERT,
- source.getSpeciesTotalInertWeight(), null,
- copyIfNull);
- inertBatch.setRankOrder((short) 2);
- }
- }
- // TODO BL : benthos, plancton, macro déchet...
- }
+ // Sorting measurement
+ if (copyIfNull && (source.getSampleCategoryType() == null || source.getSampleCategoryValue() == null)) {
+ // Nothing to do : will be removed later, using notChangedSortingMeasurements
+ } else if (source.getSampleCategoryType() != null && source.getSampleCategoryValue() != null) {
+ Integer pmfmId = measurementHelper.sampleCategory2PmfmId(source.getSampleCategoryType());
+ // Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
+ if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
+ SortingMeasurement sortingMeasurement = measurementHelper.setSortingMeasurement(target, recorderDepartmentId,
+ source.getSampleCategoryType(), source.getSampleCategoryValue());
+ notChangedSortingMeasurements.remove(sortingMeasurement);
+ }
+ }
- // -----------------------------------------------------------------------------
- // Sorted Hors Vrac
- // -----------------------------------------------------------------------------
- {
- SortingBatch batch = catchBatchChilds.get(enumeration.QUALITATIVE_HORS_VRAC_ID);
- if (batch == null) {
- batch = SortingBatch.Factory.newInstance();
- target.getChildBatchs().add(batch);
- }
- beanToEntitySortingBatch(target, target, batch, recorderDepartmentId,
- enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
- source.getCatchTotalUnsortedWeight(), null,
- copyIfNull);
- batch.setRankOrder((short) 2);
+ // Individual count
+ if (copyIfNull && source.getNumber() == null) {
+ target.setIndividualCount(null);
+ } else if (source.getNumber() != null) {
+ target.setIndividualCount(source.getNumber());
+ }
- // Manage childs :
- {
- Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
+ // Species
+ if (copyIfNull && (source.getSpecies() == null || parentBatchId != null)) {
+ target.setReferenceTaxon(null);
+ } else if (source.getSpecies() != null && parentBatchId == null) {
+ ReferenceTaxon referenceTaxon = load(ReferenceTaxonImpl.class, source.getSpecies().getReferenceTaxonId());
+ target.setReferenceTaxon(referenceTaxon);
+ }
- // Species :
- SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- if (speciesBatch == null) {
- speciesBatch = SortingBatch.Factory.newInstance();
- if (batch.getChildBatchs() == null) {
- batch.setChildBatchs(Lists.newArrayList((Batch) speciesBatch));
- } else {
- batch.getChildBatchs().add(speciesBatch);
- }
- }
- beanToEntitySortingBatch(target, batch, speciesBatch, recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- source.getSpeciesTotalUnsortedWeight(), null,
- copyIfNull);
- speciesBatch.setRankOrder((short) 1);
- }
+ // QualityFlag
+ if (source.isSpeciesToConfirm()) {
+ target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_DOUBTFUL));
+ } else {
+ target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ }
- // TODO BL : benthos, plancton, macro déchet...
- }
+ // Comments
+ if (copyIfNull && source.getComment() == null) {
+ target.setComments(null);
+ } else if (source.getComment() != null) {
+ target.setComments(source.getComment());
+ }
- // -----------------------------------------------------------------------------
- // Unsorted (=rejected)
- // -----------------------------------------------------------------------------
- // Unsorted :
- SortingBatch unsortedBatch = catchBatchChilds.get(enumeration.QUALITATIVE_UNSORTED_ID);
- if (unsortedBatch == null) {
- unsortedBatch = SortingBatch.Factory.newInstance();
- target.getChildBatchs().add(unsortedBatch);
- }
- beanToEntitySortingBatch(target, target, unsortedBatch, recorderDepartmentId,
- enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_UNSORTED_ID,
- source.getCatchTotalRejectedWeight(), null,
- copyIfNull);
- unsortedBatch.setRankOrder((short) 3);
+ // Exhaustive inventory (always true under a species batch)
+ target.setExhaustiveInventory(true);
- }
+ // Removed not changed measurements (in sorting and quantification measurement lists)
+ if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
+ for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
+ target.getQuantificationMeasurements().remove(qm);
+ }
+ }
+ if (target.getSortingMeasurements() != null && notChangedSortingMeasurements.size() > 0) {
+ for (SortingMeasurement sm : notChangedSortingMeasurements) {
+ target.getSortingMeasurements().remove(sm);
+ }
+ }
+ }
- protected Map<Integer, SortingBatch> getChildsMap(Batch parentBatch, Integer pmfmId) {
- Map<Integer, SortingBatch> batchByQualitativeValueId = new HashMap<Integer, SortingBatch>();
- if (parentBatch.getChildBatchs() == null) {
- return batchByQualitativeValueId;
- }
- for (Batch childBatch : parentBatch.getChildBatchs()) {
- SortingBatch childSortingBatch = (SortingBatch) childBatch;
- SortingMeasurement sm = measurementHelper.getSortingMeasurement((SortingBatch) childBatch, pmfmId, null, false);
- if (sm != null && sm.getQualitativeValue() != null && sm.getQualitativeValue().getId() != null) {
- batchByQualitativeValueId.put(sm.getQualitativeValue().getId(), childSortingBatch);
- }
- }
- return batchByQualitativeValueId;
- }
+ public void setBatchParents(SpeciesBatch source, SortingBatch target, String parentBatchIdStr,
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
- /**
- * Retrieve child batchs if species is "Life" or "No life"
- * (need to retrieve: speciesTotalLivingNotItemizedWeight and speciesTotalInertWeight)
- *
- * @param parentBatch
- * @return
- */
- protected Map<Integer, SortingBatch> getChildAliveNotSortedOrInert(Batch parentBatch) {
- Map<Integer, SortingBatch> batchByQualitativeValueId = new HashMap<Integer, SortingBatch>();
- if (parentBatch.getChildBatchs() == null) {
- return batchByQualitativeValueId;
- }
- for (Batch childBatch : parentBatch.getChildBatchs()) {
- SortingBatch childSortingBatch = (SortingBatch) childBatch;
- if (childSortingBatch.getReferenceTaxon() != null && childSortingBatch.getId().intValue() < 0) {
- if (enumeration.REFERENCE_TAXON_ID_LIFE.equals(childSortingBatch.getId())) {
- batchByQualitativeValueId.put(enumeration.REFERENCE_TAXON_ID_LIFE, childSortingBatch);
- } else if (enumeration.REFERENCE_TAXON_ID_LIFE.equals(childSortingBatch.getId())) {
- batchByQualitativeValueId.put(enumeration.REFERENCE_TAXON_ID_LIFE, childSortingBatch);
- }
- }
- }
- return batchByQualitativeValueId;
- }
+ Preconditions.checkNotNull(target);
+ Preconditions.checkNotNull(source.getFishingOperation());
+ Preconditions.checkNotNull(source.getFishingOperation().getId());
- protected void beanToEntitySortingBatch(
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch,
- fr.ifremer.adagio.core.dao.data.batch.Batch parentBatch,
- fr.ifremer.adagio.core.dao.data.batch.SortingBatch target,
- Integer recorderDepartmentId,
- Integer sortingPmfmId,
- Integer sortingQualitativeValueId,
- Float weight,
- Float sampleWeight,
- boolean copyIfNull) {
+ // Load existing parent and root
+ SortingBatch parentBatch = null;
+ if (parentBatchIdStr != null) {
+ parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
+ }
- // Create lists to store all updates, then remove not updated items
- Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
- if (target.getQuantificationMeasurements() != null) {
- notChangedQuantificationMeasurements.addAll(target.getQuantificationMeasurements());
- }
- Set<SortingMeasurement> notChangedSortingMeasurements = new HashSet<SortingMeasurement>();
- if (target.getSortingMeasurements() != null) {
- notChangedSortingMeasurements.addAll(target.getSortingMeasurements());
- }
+ // Or retrieve parent batch, from pmfm id
+ else {
+ // Retrieve category type
+ Integer pmfmId = measurementHelper.sampleCategory2PmfmId(source.getSampleCategoryType());
+ if (pmfmId == null || !pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
+ throw new DataIntegrityViolationException(MessageFormat.format(
+ "A species batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
+ SampleCategoryEnum.sortedUnsorted.name(),
+ enumeration.PMFM_ID_SORTED_UNSORTED));
+ }
+ Integer qualitativeValueId = convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue());
- // Some mandatory properties :
- target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
- target.setRootBatch(rootBatch);
- target.setParentBatch(parentBatch);
- target.setExhaustiveInventory(true);
+ parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
+ "pmfmId", pmfmId, qualitativeValueId,
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- // No taxon or taxon group
- target.setReferenceTaxon(null);
- target.setTaxonGroup(null);
+ // Parent Batch
+ target.setParentBatch(parentBatch);
+ }
- // Sorting measurement
- if (copyIfNull && (sortingPmfmId == null || sortingQualitativeValueId == null)) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else if (sortingPmfmId != null && sortingQualitativeValueId != null) {
- SortingMeasurement sm = measurementHelper.setSortingMeasurement(target, recorderDepartmentId, sortingPmfmId, sortingQualitativeValueId);
- notChangedSortingMeasurements.remove(sm);
- }
- // Sampling Ratio
- if (copyIfNull && (sampleWeight == null || weight == null)) {
- target.setSamplingRatio(null);
- target.setSamplingRatioText(null);
- } else if (sampleWeight != null && weight != null) {
- String samplingRatioText = weight + "/" + sampleWeight;
- samplingRatioText = samplingRatioText.replaceAll(",", ".");
- target.setSamplingRatioText(samplingRatioText);
- target.setSamplingRatio(weight / sampleWeight);
- }
+ if (parentBatch == null) {
+ throw new DataIntegrityViolationException(
+ "Could not retrieve parent batch, for a given speciesBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a SpeciesBatch.");
+ }
- // Weight
- if (copyIfNull && (sampleWeight == null && weight == null)) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else if (sampleWeight != null || weight != null) {
- Float batchReferenceWeight = weight;
- if (batchReferenceWeight == null) {
- batchReferenceWeight = sampleWeight;
- }
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- }
+ // Parent Batch
+ target.setParentBatch(parentBatch);
+ target.setRootBatch(catchBatch);
+ }
- // Removed not changed measurements (in sorting and quantification measurement lists)
- if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
- for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
- target.getQuantificationMeasurements().remove(qm);
- }
- }
- if (target.getSortingMeasurements() != null && notChangedSortingMeasurements.size() > 0) {
- for (SortingMeasurement sm : notChangedSortingMeasurements) {
- target.getSortingMeasurements().remove(sm);
- }
- }
- }
+ Integer convertSampleCategoryValueIntoQualitativeId(Serializable value) {
+ if (value == null)
+ return null;
+ Integer qualitativeValueId = null;
+ if (value instanceof CaracteristicQualitativeValue) {
+ CaracteristicQualitativeValue cqValue = (CaracteristicQualitativeValue) value;
+ qualitativeValueId = Integer.valueOf(cqValue.getId());
+ } else if (value instanceof String) {
+ qualitativeValueId = Integer.valueOf((String) value);
+ }
+ return qualitativeValueId;
+ }
- protected void beanToEntityReferenceTaxonBatch(
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch,
- fr.ifremer.adagio.core.dao.data.batch.Batch parentBatch,
- fr.ifremer.adagio.core.dao.data.batch.SortingBatch target,
- Integer recorderDepartmentId,
- Integer referenceTaxonId,
- Float weight,
- Float sampleWeight,
- boolean copyIfNull) {
+ protected void setSampleCategoryQualitative(SpeciesBatch target, Integer pmfmId, Float numericalvalue, String alphanumericalValue,
+ Integer qualitativeValueId) {
+ // skip if null or corresponding to the SORTING_TYPE PMFM (Expèce, Benthos, Plancton, etc.)
+ if (pmfmId == null || pmfmId.equals(enumeration.PMFM_ID_SORTING_TYPE)) {
+ return;
+ }
- // Create lists to store all updates, then remove not updated items
- Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
- if (target.getQuantificationMeasurements() != null) {
- notChangedQuantificationMeasurements.addAll(target.getQuantificationMeasurements());
- }
- Set<SortingMeasurement> notChangedSortingMeasurements = new HashSet<SortingMeasurement>();
- if (target.getSortingMeasurements() != null) {
- notChangedSortingMeasurements.addAll(target.getSortingMeasurements());
- }
+ SampleCategoryEnum sampleCategory = referentialService.getSampleCategoryByPmfmId(pmfmId);
+ Preconditions.checkNotNull(sampleCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId);
- // Some mandatory properties :
- target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
- target.setRootBatch(rootBatch);
- target.setParentBatch(parentBatch);
- target.setExhaustiveInventory(true);
+ target.setSampleCategoryType(sampleCategory);
+ if (numericalvalue != null) {
+ target.setSampleCategoryValue(numericalvalue);
+ return;
+ }
+ if (alphanumericalValue != null) {
+ target.setSampleCategoryValue(alphanumericalValue);
+ return;
+ }
- // Reference taxon
- target.setReferenceTaxon(load(ReferenceTaxonImpl.class, referenceTaxonId));
- target.setTaxonGroup(null);
+ Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
+ if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
+ return;
+ }
+ CaracteristicQualitativeValue value = null;
+ for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
+ if (qualitativeValueId == Integer.parseInt(qv.getId())) {
+ value = qv;
+ break;
+ }
+ }
+ target.setSampleCategoryValue(value);
+ }
- // Sampling Ratio
- if (copyIfNull && (sampleWeight == null || weight == null)) {
- target.setSamplingRatio(null);
- target.setSamplingRatioText(null);
- } else if (sampleWeight != null && weight != null) {
- String samplingRatioText = weight + "/" + sampleWeight;
- samplingRatioText = samplingRatioText.replaceAll(",", ".");
- target.setSamplingRatioText(samplingRatioText);
- target.setSamplingRatio(weight / sampleWeight);
- }
+ protected void beanToEntity(SpeciesBatchFrequency source, SortingBatch target, SortingBatch parentBatch, short rankOrder, boolean copyIfNull) {
+ Preconditions.checkNotNull(source.getBatch());
+ Preconditions.checkNotNull(source.getBatch().getId());
- // Weight
- if (copyIfNull && (sampleWeight == null && weight == null)) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else if (sampleWeight != null || weight != null) {
- Float batchReferenceWeight = weight;
- if (batchReferenceWeight == null) {
- batchReferenceWeight = sampleWeight;
- }
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- }
+ // Retrieve recorder department
+ Integer recorderDepartmentId = getRecorderDepartmentId();
- // Removed not changed measurements (in sorting and quantification measurement lists)
- if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
- for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
- target.getQuantificationMeasurements().remove(qm);
- }
- }
- if (target.getSortingMeasurements() != null && notChangedSortingMeasurements.size() > 0) {
- for (SortingMeasurement sm : notChangedSortingMeasurements) {
- target.getSortingMeasurements().remove(sm);
- }
- }
- }
-
- protected Integer getRecorderDepartmentId() {
- // TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?)
- return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
- }
+ // Create lists to store all updates, then remove not updated items
+ Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
+ if (target.getQuantificationMeasurements() != null) {
+ notChangedQuantificationMeasurements.addAll(target.getQuantificationMeasurements());
+ }
+ Set<SortingMeasurement> notChangedSortingMeasurements = new HashSet<SortingMeasurement>();
+ if (target.getSortingMeasurements() != null) {
+ notChangedSortingMeasurements.addAll(target.getSortingMeasurements());
+ }
+
+ // If parent and root need to be set
+ if (target.getId() == null
+ || target.getRootBatch() == null
+ || (target.getParentBatch() != null && !target.getParentBatch().getId().equals(parentBatch.getId()))) {
+
+ target.setParentBatch(parentBatch);
+ target.setRootBatch(parentBatch.getRootBatch());
+ }
+
+ // RankOrder
+ target.setRankOrder(rankOrder);
+
+ // Weight or SampleCategoryWeight
+ if (copyIfNull && source.getWeight() == null) {
+ // Nothing to do : will be removed later, using notChangedSortingMeasurements
+ } else if (source.getWeight() != null) {
+ QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ }
+
+ // Sorting measurement
+ if (copyIfNull && (source.getLengthStepCaracteristic() == null || source.getLengthStep() == null)) {
+ // Nothing to do : will be removed later, using notChangedSortingMeasurements
+ } else if (source.getLengthStepCaracteristic() != null && source.getLengthStep() != null) {
+ Integer pmfmId = Integer.valueOf(source.getLengthStepCaracteristic().getId());
+ SortingMeasurement sortingMeasurement = measurementHelper.setSortingMeasurement(target, recorderDepartmentId, pmfmId,
+ source.getLengthStep());
+ notChangedSortingMeasurements.remove(sortingMeasurement);
+ }
+
+ // Individual count
+ if (copyIfNull && source.getNumber() == null) {
+ target.setIndividualCount(null);
+ } else if (source.getNumber() != null) {
+ target.setIndividualCount(source.getNumber());
+ }
+
+ // Species
+ target.setReferenceTaxon(null);
+
+ // QualityFlag
+ target.setQualityFlag(parentBatch.getQualityFlag());
+
+ // Comments
+ if (copyIfNull && source.getComment() == null) {
+ target.setComments(null);
+ } else if (source.getComment() != null) {
+ target.setComments(source.getComment());
+ }
+
+ // Exhaustive inventory (always true under a species batch)
+ target.setExhaustiveInventory(true);
+
+ // Removed not changed measurements (in sorting and quantification measurement lists)
+ if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
+ for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
+ target.getQuantificationMeasurements().remove(qm);
+ }
+ }
+ if (target.getSortingMeasurements() != null && notChangedSortingMeasurements.size() > 0) {
+ for (SortingMeasurement sm : notChangedSortingMeasurements) {
+ target.getSortingMeasurements().remove(sm);
+ }
+ }
+ }
+
+ protected UIWeight convertDatabase2UI(Float weight, Float samplingRatio, String samplingRatioText) {
+ UIWeight result = new UIWeight();
+
+ // Weight & sampleCategory Weight
+ if (samplingRatio == null) {
+ result.sampleCategoryWeight = weight;
+ } else if (weight != null) {
+ String startStr = weight.toString().replace(',', '.') + "/";
+ if (samplingRatioText != null && samplingRatioText.startsWith(startStr)) {
+ String weightStr = samplingRatioText.substring(startStr.length());
+ if (weightStr != null && !weightStr.isEmpty()) {
+ result.sampleCategoryWeight = Float.parseFloat(weightStr);
+ result.weight = weight;
+ }
+ } else {
+ result.sampleCategoryWeight = weight;
+ }
+ }
+ return result;
+ }
+
+ static class UIWeight {
+ Float sampleCategoryWeight = null;
+
+ Float weight = null;
+ }
+
+ protected void beanToEntity(CatchBatch source,
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch target,
+ boolean copyIfNull) {
+ Preconditions.checkNotNull(source.getFishingOperation());
+ Preconditions.checkNotNull(source.getFishingOperation().getId());
+
+ // Retrieve recorder department
+ Integer recorderDepartmentId = getRecorderDepartmentId();
+
+ // First initialization (when created)
+ Integer fishingOperationId = Integer.valueOf(source.getFishingOperation().getId());
+ target.setFishingOperation(load(FishingOperationImpl.class, fishingOperationId));
+
+ target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ target.setRankOrder((short) 1);
+ target.setSynchronizationStatus(SynchronizationStatus.DIRTY.getValue());
+
+ // Create lists to store all updates, then remove not updated items
+ Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
+ if (target.getQuantificationMeasurements() != null) {
+ notChangedQuantificationMeasurements.addAll(target.getQuantificationMeasurements());
+ }
+
+ // Total Weight
+ if (copyIfNull && source.getCatchTotalWeight() == null) {
+ // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
+ } else if (source.getCatchTotalWeight() != null) {
+ QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getCatchTotalWeight(), true);
+ notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ }
+
+ // Removed not changed measurements (in sorting and quantification measurement lists)
+ if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
+ for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
+ target.getQuantificationMeasurements().remove(qm);
+ }
+ }
+ Map<Integer, SortingBatch> catchBatchChilds = getChildsMap(target, enumeration.PMFM_ID_SORTED_UNSORTED);
+
+ // -----------------------------------------------------------------------------
+ // Sorted Vrac
+ // -----------------------------------------------------------------------------
+ {
+ SortingBatch batch = catchBatchChilds.get(enumeration.QUALITATIVE_VRAC_ID);
+ if (batch == null) {
+ batch = SortingBatch.Factory.newInstance();
+ target.getChildBatchs().add(batch);
+ }
+ beanToEntitySortingBatch(target, target, batch, recorderDepartmentId,
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ source.getCatchTotalSortedCarousselWeight(), source.getCatchTotalSortedTremisWeight(),
+ copyIfNull);
+ batch.setRankOrder((short) 1);
+
+ // Manage childs :
+ {
+ Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
+
+ // -----------------------------------------------------------------------------
+ // Sorted Vrac / Species
+ // -----------------------------------------------------------------------------
+ SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ if (speciesBatch == null) {
+ speciesBatch = SortingBatch.Factory.newInstance();
+ if (batch.getChildBatchs() == null) {
+ batch.setChildBatchs(Lists.newArrayList((Batch) speciesBatch));
+ } else {
+ batch.getChildBatchs().add(speciesBatch);
+ }
+ }
+ beanToEntitySortingBatch(target, batch, speciesBatch, recorderDepartmentId,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ source.getSpeciesTotalSampleSortedWeight(), source.getSpeciesTotalSortedWeight(),
+ copyIfNull);
+ speciesBatch.setRankOrder((short) 1);
+
+ {
+
+ // -----------------------------------------------------------------------------
+ // Sorted Vrac / Species / Alive not itemized
+ // -----------------------------------------------------------------------------
+ SortingBatch aliveNotItemizedBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(), "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_LIFE);
+ if (aliveNotItemizedBatch == null) {
+ aliveNotItemizedBatch = SortingBatch.Factory.newInstance();
+ if (speciesBatch.getChildBatchs() == null) {
+ speciesBatch.setChildBatchs(Lists.newArrayList((Batch) aliveNotItemizedBatch));
+ } else {
+ speciesBatch.getChildBatchs().add(aliveNotItemizedBatch);
+ }
+ }
+ beanToEntityReferenceTaxonBatch(target, speciesBatch, aliveNotItemizedBatch, recorderDepartmentId,
+ enumeration.REFERENCE_TAXON_ID_LIFE,
+ source.getSpeciesTotalLivingNotItemizedWeight(), null,
+ copyIfNull);
+ aliveNotItemizedBatch.setRankOrder((short) 1);
+
+ // -----------------------------------------------------------------------------
+ // Sorted Vrac / Species / Inert (not alive)
+ // -----------------------------------------------------------------------------
+ SortingBatch inertBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(), "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_INERT);
+ if (inertBatch == null) {
+ inertBatch = SortingBatch.Factory.newInstance();
+ speciesBatch.getChildBatchs().add(inertBatch);
+ }
+ beanToEntityReferenceTaxonBatch(target, speciesBatch, inertBatch, recorderDepartmentId,
+ enumeration.REFERENCE_TAXON_ID_INERT,
+ source.getSpeciesTotalInertWeight(), null,
+ copyIfNull);
+ inertBatch.setRankOrder((short) 2);
+ }
+ }
+ // TODO BL : benthos, plancton, macro déchet...
+ }
+
+ // -----------------------------------------------------------------------------
+ // Sorted Hors Vrac
+ // -----------------------------------------------------------------------------
+ {
+ SortingBatch batch = catchBatchChilds.get(enumeration.QUALITATIVE_HORS_VRAC_ID);
+ if (batch == null) {
+ batch = SortingBatch.Factory.newInstance();
+ target.getChildBatchs().add(batch);
+ }
+ beanToEntitySortingBatch(target, target, batch, recorderDepartmentId,
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
+ source.getCatchTotalUnsortedWeight(), null,
+ copyIfNull);
+ batch.setRankOrder((short) 2);
+
+ // Manage childs :
+ {
+ Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
+
+ // Species :
+ SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ if (speciesBatch == null) {
+ speciesBatch = SortingBatch.Factory.newInstance();
+ if (batch.getChildBatchs() == null) {
+ batch.setChildBatchs(Lists.newArrayList((Batch) speciesBatch));
+ } else {
+ batch.getChildBatchs().add(speciesBatch);
+ }
+ }
+ beanToEntitySortingBatch(target, batch, speciesBatch, recorderDepartmentId,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ source.getSpeciesTotalUnsortedWeight(), null,
+ copyIfNull);
+ speciesBatch.setRankOrder((short) 1);
+ }
+
+ // TODO BL : benthos, plancton, macro déchet...
+ }
+
+ // -----------------------------------------------------------------------------
+ // Unsorted (=rejected)
+ // -----------------------------------------------------------------------------
+ // Unsorted :
+ SortingBatch unsortedBatch = catchBatchChilds.get(enumeration.QUALITATIVE_UNSORTED_ID);
+ if (unsortedBatch == null) {
+ unsortedBatch = SortingBatch.Factory.newInstance();
+ target.getChildBatchs().add(unsortedBatch);
+ }
+ beanToEntitySortingBatch(target, target, unsortedBatch, recorderDepartmentId,
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_UNSORTED_ID,
+ source.getCatchTotalRejectedWeight(), null,
+ copyIfNull);
+ unsortedBatch.setRankOrder((short) 3);
+
+ }
+
+ protected Map<Integer, SortingBatch> getChildsMap(Batch parentBatch, Integer pmfmId) {
+ Map<Integer, SortingBatch> batchByQualitativeValueId = new HashMap<Integer, SortingBatch>();
+ if (parentBatch.getChildBatchs() == null) {
+ return batchByQualitativeValueId;
+ }
+ for (Batch childBatch : parentBatch.getChildBatchs()) {
+ SortingBatch childSortingBatch = (SortingBatch) childBatch;
+ SortingMeasurement sm = measurementHelper.getSortingMeasurement((SortingBatch) childBatch, pmfmId, null, false);
+ if (sm != null && sm.getQualitativeValue() != null && sm.getQualitativeValue().getId() != null) {
+ batchByQualitativeValueId.put(sm.getQualitativeValue().getId(), childSortingBatch);
+ }
+ }
+ return batchByQualitativeValueId;
+ }
+
+ /**
+ * Retrieve child batchs if species is "Life" or "No life"
+ * (need to retrieve: speciesTotalLivingNotItemizedWeight and speciesTotalInertWeight)
+ *
+ * @param parentBatch
+ * @return
+ */
+ protected Map<Integer, SortingBatch> getChildAliveNotSortedOrInert(Batch parentBatch) {
+ Map<Integer, SortingBatch> batchByQualitativeValueId = new HashMap<Integer, SortingBatch>();
+ if (parentBatch.getChildBatchs() == null) {
+ return batchByQualitativeValueId;
+ }
+ for (Batch childBatch : parentBatch.getChildBatchs()) {
+ SortingBatch childSortingBatch = (SortingBatch) childBatch;
+ if (childSortingBatch.getReferenceTaxon() != null && childSortingBatch.getId().intValue() < 0) {
+ if (enumeration.REFERENCE_TAXON_ID_LIFE.equals(childSortingBatch.getId())) {
+ batchByQualitativeValueId.put(enumeration.REFERENCE_TAXON_ID_LIFE, childSortingBatch);
+ } else if (enumeration.REFERENCE_TAXON_ID_LIFE.equals(childSortingBatch.getId())) {
+ batchByQualitativeValueId.put(enumeration.REFERENCE_TAXON_ID_LIFE, childSortingBatch);
+ }
+ }
+ }
+ return batchByQualitativeValueId;
+ }
+
+ protected void beanToEntitySortingBatch(
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch,
+ fr.ifremer.adagio.core.dao.data.batch.Batch parentBatch,
+ fr.ifremer.adagio.core.dao.data.batch.SortingBatch target,
+ Integer recorderDepartmentId,
+ Integer sortingPmfmId,
+ Integer sortingQualitativeValueId,
+ Float weight,
+ Float sampleWeight,
+ boolean copyIfNull) {
+
+ // Create lists to store all updates, then remove not updated items
+ Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
+ if (target.getQuantificationMeasurements() != null) {
+ notChangedQuantificationMeasurements.addAll(target.getQuantificationMeasurements());
+ }
+ Set<SortingMeasurement> notChangedSortingMeasurements = new HashSet<SortingMeasurement>();
+ if (target.getSortingMeasurements() != null) {
+ notChangedSortingMeasurements.addAll(target.getSortingMeasurements());
+ }
+
+ // Some mandatory properties :
+ target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ target.setRootBatch(rootBatch);
+ target.setParentBatch(parentBatch);
+ target.setExhaustiveInventory(true);
+
+ // No taxon or taxon group
+ target.setReferenceTaxon(null);
+ target.setTaxonGroup(null);
+
+ // Sorting measurement
+ if (copyIfNull && (sortingPmfmId == null || sortingQualitativeValueId == null)) {
+ // Nothing to do : will be removed later, using notChangedSortingMeasurements
+ } else if (sortingPmfmId != null && sortingQualitativeValueId != null) {
+ SortingMeasurement sm = measurementHelper.setSortingMeasurement(target, recorderDepartmentId, sortingPmfmId, sortingQualitativeValueId);
+ notChangedSortingMeasurements.remove(sm);
+ }
+
+ // Sampling Ratio
+ if (copyIfNull && (sampleWeight == null || weight == null)) {
+ target.setSamplingRatio(null);
+ target.setSamplingRatioText(null);
+ } else if (sampleWeight != null && weight != null) {
+ String samplingRatioText = weight + "/" + sampleWeight;
+ samplingRatioText = samplingRatioText.replaceAll(",", ".");
+ target.setSamplingRatioText(samplingRatioText);
+ target.setSamplingRatio(weight / sampleWeight);
+ }
+
+ // Weight
+ if (copyIfNull && (sampleWeight == null && weight == null)) {
+ // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
+ } else if (sampleWeight != null || weight != null) {
+ Float batchReferenceWeight = weight;
+ if (batchReferenceWeight == null) {
+ batchReferenceWeight = sampleWeight;
+ }
+ QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
+ notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ }
+
+ // Removed not changed measurements (in sorting and quantification measurement lists)
+ if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
+ for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
+ target.getQuantificationMeasurements().remove(qm);
+ }
+ }
+ if (target.getSortingMeasurements() != null && notChangedSortingMeasurements.size() > 0) {
+ for (SortingMeasurement sm : notChangedSortingMeasurements) {
+ target.getSortingMeasurements().remove(sm);
+ }
+ }
+ }
+
+ protected void beanToEntityReferenceTaxonBatch(
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch,
+ fr.ifremer.adagio.core.dao.data.batch.Batch parentBatch,
+ fr.ifremer.adagio.core.dao.data.batch.SortingBatch target,
+ Integer recorderDepartmentId,
+ Integer referenceTaxonId,
+ Float weight,
+ Float sampleWeight,
+ boolean copyIfNull) {
+
+ // Create lists to store all updates, then remove not updated items
+ Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
+ if (target.getQuantificationMeasurements() != null) {
+ notChangedQuantificationMeasurements.addAll(target.getQuantificationMeasurements());
+ }
+ Set<SortingMeasurement> notChangedSortingMeasurements = new HashSet<SortingMeasurement>();
+ if (target.getSortingMeasurements() != null) {
+ notChangedSortingMeasurements.addAll(target.getSortingMeasurements());
+ }
+
+ // Some mandatory properties :
+ target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ target.setRootBatch(rootBatch);
+ target.setParentBatch(parentBatch);
+ target.setExhaustiveInventory(true);
+
+ // Reference taxon
+ target.setReferenceTaxon(load(ReferenceTaxonImpl.class, referenceTaxonId));
+ target.setTaxonGroup(null);
+
+ // Sampling Ratio
+ if (copyIfNull && (sampleWeight == null || weight == null)) {
+ target.setSamplingRatio(null);
+ target.setSamplingRatioText(null);
+ } else if (sampleWeight != null && weight != null) {
+ String samplingRatioText = weight + "/" + sampleWeight;
+ samplingRatioText = samplingRatioText.replaceAll(",", ".");
+ target.setSamplingRatioText(samplingRatioText);
+ target.setSamplingRatio(weight / sampleWeight);
+ }
+
+ // Weight
+ if (copyIfNull && (sampleWeight == null && weight == null)) {
+ // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
+ } else if (sampleWeight != null || weight != null) {
+ Float batchReferenceWeight = weight;
+ if (batchReferenceWeight == null) {
+ batchReferenceWeight = sampleWeight;
+ }
+ QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
+ notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ }
+
+ // Removed not changed measurements (in sorting and quantification measurement lists)
+ if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
+ for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
+ target.getQuantificationMeasurements().remove(qm);
+ }
+ }
+ if (target.getSortingMeasurements() != null && notChangedSortingMeasurements.size() > 0) {
+ for (SortingMeasurement sm : notChangedSortingMeasurements) {
+ target.getSortingMeasurements().remove(sm);
+ }
+ }
+ }
+
+ protected Integer getRecorderDepartmentId() {
+ // TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?)
+ return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
+ }
}
\ No newline at end of file
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -316,21 +316,21 @@
// Strata :
Integer strataId = (Integer) source[colIndex++];
if (strataId != null) {
- FishingOperationLocation strata = referentialService.getFishingOperationLocation(strataId.toString());
+ FishingOperationLocation strata = referentialService.getFishingOperationLocation(strataId.toString());
result.setStrata(strata);
}
// Sub Strata :
Integer subStrataId = (Integer) source[colIndex++];
if (subStrataId != null) {
- FishingOperationLocation subStrata = referentialService.getFishingOperationLocation(subStrataId.toString());
+ FishingOperationLocation subStrata = referentialService.getFishingOperationLocation(subStrataId.toString());
result.setSubStrata(subStrata);
}
// Localite :
Integer localiteId = (Integer) source[colIndex++];
if (localiteId != null) {
- FishingOperationLocation localite = referentialService.getFishingOperationLocation(localiteId.toString());
+ FishingOperationLocation localite = referentialService.getFishingOperationLocation(localiteId.toString());
result.setLocation(localite);
}
@@ -372,9 +372,9 @@
Preconditions.checkNotNull(bean.getId());
Preconditions.checkNotNull(bean.getCruise());
Preconditions.checkNotNull(bean.getCruise().getId());
-
+
if (bean.getGearShootingStartDate() != null && bean.getGearShootingEndDate() != null) {
- Preconditions.checkArgument(bean.getGearShootingStartDate().equals(bean.getGearShootingEndDate()) == false);
+ Preconditions.checkArgument(bean.getGearShootingStartDate().equals(bean.getGearShootingEndDate()) == false);
}
getCurrentSession().clear();
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -188,9 +188,9 @@
Caracteristic getCaracteristic(Integer pmfmId);
boolean isSortedQualitativeValue(CaracteristicQualitativeValue value);
-
+
List<Integer> getSampleCategoryIds();
-
+
/**
* Import given temporary species.
*
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -212,16 +212,16 @@
parentLocationLevelId);
return result;
}
-
+
@Override
public FishingOperationLocation getFishingOperationLocation(String id) {
- Object[] source = queryUnique(
+ Object[] source = queryUnique(
"fishingOperationLocationById",
"locationId", IntegerType.INSTANCE, Integer.valueOf(id)
- );
- if (source == null) {
- return null;
- }
+ );
+ if (source == null) {
+ return null;
+ }
FishingOperationLocation target = new FishingOperationLocation();
target.setId(String.valueOf(source[0]));
target.setLabel((String) source[1]);
@@ -822,10 +822,10 @@
*/
public List<Integer> getSampleCategoryIds() {
return Lists.newArrayList(enumeration.PMFM_ID_SORTED_UNSORTED
- , enumeration.PMFM_ID_SIZE_CATEGORY
- , enumeration.PMFM_ID_MATURITY
- , enumeration.PMFM_ID_SEX
- , enumeration.PMFM_ID_AGE);
+ , enumeration.PMFM_ID_SIZE_CATEGORY
+ , enumeration.PMFM_ID_MATURITY
+ , enumeration.PMFM_ID_SEX
+ , enumeration.PMFM_ID_AGE);
}
/**
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -193,7 +193,7 @@
@Value("${ReferenceTaxonId.INERT}")
public final Integer REFERENCE_TAXON_ID_INERT = null;
-
+
public void init() {
Field[] declaredFields = getClass().getDeclaredFields();
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -206,10 +206,10 @@
return sortingMeasurement;
}
-
+
public SortingMeasurement getInheritedSortingMeasurement(
SortingBatch sortingBatch, Integer pmfmId) {
- if (sortingBatch.getInheritedSortingMeasurements() != null) {
+ if (sortingBatch.getInheritedSortingMeasurements() != null) {
for (SortingMeasurement qm : sortingBatch
.getInheritedSortingMeasurements()) {
if (pmfmId.equals(qm.getPmfm().getId())) {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -94,9 +94,11 @@
protected final boolean withUpdateDateColumn;
public abstract String getCountDataToUpdateQueryWithNull();
+
public abstract String getDataToUpdateQueryWithNull();
public abstract String getCountDataToUpdateQuery();
+
public abstract String getDataToUpdateQuery();
public abstract boolean useUpdateDateColumn();
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -24,30 +24,28 @@
* #L%
*/
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-
+import com.google.common.collect.Maps;
import fr.ifremer.tutti.persistence.DatabaseResource;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-
import org.junit.Before;
import org.junit.ClassRule;
-import org.junit.Ignore;
import org.junit.Test;
import org.springframework.dao.DataRetrievalFailureException;
-import com.google.common.collect.Maps;
+import java.util.List;
+import java.util.Map;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
* To test {@link CatchBatchPersistenceService} for read operation.
*
@@ -60,14 +58,16 @@
public static final DatabaseResource dbResource = DatabaseResource.readDb();
protected BatchPersistenceService service;
+
protected FishingOperationPersistenceService fishingOperationService;
+
protected FishingOperation fishingOperation;
@Before
public void setUp() throws Exception {
service = TuttiPersistenceServiceLocator.getBatchPersistenceService();
fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
-
+
List<FishingOperation> fishingOperations = fishingOperationService.getAllFishingOperation(dbResource.getFixtures().cruiseId());
assertNotNull(fishingOperations);
assertTrue(fishingOperations.size() > 0);
@@ -79,15 +79,14 @@
@Test
public void getCatchBatchFromFishingOperation() throws Exception {
- try {
- CatchBatch catchBatch = service.getCatchBatchFromFishingOperation(fishingOperation.getId());
- fail("batch tree must be invalid (old CGFS tree structure), for fishing operation id=" + fishingOperation.getId());
- }
- catch(DataRetrievalFailureException drfe) {
- // success
- }
+ try {
+ CatchBatch catchBatch = service.getCatchBatchFromFishingOperation(fishingOperation.getId());
+ fail("batch tree must be invalid (old CGFS tree structure), for fishing operation id=" + fishingOperation.getId());
+ } catch (DataRetrievalFailureException drfe) {
+ // success
+ }
}
-
+
@Test
public void getAllRootSpeciesBatch(/*String fishingOperationId*/) {
}
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -24,6 +24,8 @@
* #L%
*/
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import fr.ifremer.tutti.persistence.DatabaseResource;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
@@ -37,13 +39,9 @@
import fr.ifremer.tutti.persistence.entities.referential.Species;
import org.junit.Before;
import org.junit.ClassRule;
-import org.junit.Ignore;
import org.junit.Test;
import org.springframework.dao.DataRetrievalFailureException;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -51,8 +49,10 @@
import java.util.Map;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
/**
* To test {@link CatchBatchPersistenceService} for write operation.
@@ -70,29 +70,29 @@
protected CruisePersistenceService cruiseService;
protected FishingOperationPersistenceService fishingOperationService;
-
+
protected CatchBatchPersistenceService catchBatchService;
-
+
protected ReferentialPersistenceService referentialService;
protected Cruise cruise;
protected FishingOperation fishingOperationNoCatchBatch;
-
+
protected FishingOperation fishingOperationWithEmptyBatch;
-
+
protected CatchBatch catchBacth;
-
+
protected List<Species> species;
-
+
protected Caracteristic sortedUnsortedPMFM;
protected CaracteristicQualitativeValue horsVracQualitativeValue;
protected CaracteristicQualitativeValue vracQualitativeValue;
-
+
protected Caracteristic maturityPMFM;
-
+
protected CaracteristicQualitativeValue firstMaturityQualitativeValue;
protected Caracteristic sexPMFM;
@@ -143,7 +143,7 @@
calendar.set(Calendar.MILLISECOND, 0);
fishingOperationNoCatchBatch.setGearShootingEndDate(calendar.getTime());
fishingOperationNoCatchBatch = fishingOperationService.createFishingOperation(fishingOperationNoCatchBatch);
-
+
// Create a second operation, with no cacth batch : to test CatchBatch insert/update :
fishingOperationWithEmptyBatch = fishingOperations.get(1);
fishingOperationWithEmptyBatch = fishingOperationService.getFishingOperation(fishingOperationWithEmptyBatch.getId());
@@ -162,7 +162,7 @@
catchBacth = new CatchBatch();
catchBacth.setFishingOperation(fishingOperationWithEmptyBatch);
catchBacth = catchBatchService.createCatchBatch(catchBacth);
-
+
sortedUnsortedPMFM = referentialService.getSortedUnsortedCaracteristic();
horsVracQualitativeValue = sortedUnsortedPMFM.getQualitativeValue(0);
vracQualitativeValue = sortedUnsortedPMFM.getQualitativeValue(1);
@@ -172,7 +172,7 @@
maleQualitativeValue = sexPMFM.getQualitativeValue(1);
femaleQualitativeValue = sexPMFM.getQualitativeValue(2);
unkQualitativeValue = sexPMFM.getQualitativeValue(3);
-
+
List<Caracteristic> cara = referentialService.getAllCaracteristic();
for (Caracteristic caracteristic : cara) {
if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER
@@ -234,7 +234,7 @@
catchBatch.setCatchTotalRejectedWeight(15f);
// Create and reload (test round trip)
- assertCreateAndReloadCatchBatch(catchBatch, fishingOperationNoCatchBatch.getId());
+ assertCreateAndReloadCatchBatch(catchBatch, fishingOperationNoCatchBatch.getId());
// -----------------------------------------------------------------------------
// 2. Test save after modification
@@ -245,10 +245,10 @@
catchBatch.setSpeciesTotalSampleSortedWeight(null);
catchBatch.setCatchTotalUnsortedWeight(null);
catchBatch.setSpeciesTotalUnsortedWeight(null);
-
- assertSaveAndReloadCatchBatch(catchBatch, fishingOperationNoCatchBatch.getId());
+
+ assertSaveAndReloadCatchBatch(catchBatch, fishingOperationNoCatchBatch.getId());
}
-
+
@Test
public void createAndSaveSpeciesBatchAndFrequencies() {
SpeciesBatch esp1Batch = null;
@@ -409,7 +409,7 @@
}
}
// And remove the last item (should be deleted in DB)
- createdFrequencies.remove(createdFrequencies.size()-1);
+ createdFrequencies.remove(createdFrequencies.size() - 1);
List<SpeciesBatchFrequency> savedFrequencies = service.saveSpeciesBatchFrequency(frequenciesParentBatch.getId(), frequencies);
assertBatchFrequencies(createdFrequencies, savedFrequencies, true);
}
@@ -475,16 +475,16 @@
batch.setId(createdBatch.getId());
}
-
+
protected void assertCreateAndReloadCatchBatch(CatchBatch catchBatch, String fishingOperationId) {
CatchBatch createdCatchBatch = service.createCatchBatch(catchBatch);
assertNotNull(createdCatchBatch);
assertNotNull(createdCatchBatch.getId());
assertCatchBatch(catchBatch, createdCatchBatch, false);
-
+
CatchBatch reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
assertCatchBatch(createdCatchBatch, reloadedCatchBatch, true);
-
+
catchBatch.setId(createdCatchBatch.getId());
}
@@ -493,20 +493,20 @@
assertNotNull(savedCatchBatch);
assertNotNull(savedCatchBatch.getId());
assertCatchBatch(catchBatch, savedCatchBatch, false);
-
+
CatchBatch reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
assertCatchBatch(savedCatchBatch, reloadedCatchBatch, true);
}
-
- protected void assertCatchBatch(CatchBatch expectedCatchBatch,CatchBatch actualCatchBatch, boolean assertIdEquals) {
- if (expectedCatchBatch == null) {
- assertNull(actualCatchBatch);
- return;
- }
-
+
+ protected void assertCatchBatch(CatchBatch expectedCatchBatch, CatchBatch actualCatchBatch, boolean assertIdEquals) {
+ if (expectedCatchBatch == null) {
+ assertNull(actualCatchBatch);
+ return;
+ }
+
assertNotNull(actualCatchBatch);
if (assertIdEquals) {
- assertEquals(expectedCatchBatch.getId(), actualCatchBatch.getId());
+ assertEquals(expectedCatchBatch.getId(), actualCatchBatch.getId());
}
assertEquals(expectedCatchBatch.getCatchTotalWeight(), actualCatchBatch.getCatchTotalWeight());
assertEquals(expectedCatchBatch.getCatchTotalSortedCarousselWeight(), actualCatchBatch.getCatchTotalSortedCarousselWeight());
@@ -519,7 +519,7 @@
assertEquals(expectedCatchBatch.getSpeciesTotalInertWeight(), actualCatchBatch.getSpeciesTotalInertWeight());
assertEquals(expectedCatchBatch.getSpeciesTotalLivingNotItemizedWeight(), actualCatchBatch.getSpeciesTotalLivingNotItemizedWeight());
}
-
+
protected void assertSpeciesBatch(SpeciesBatch expectedBatch, SpeciesBatch actualBatch, boolean assertIdEquals) {
assertNotNull(actualBatch);
assertNotNull(actualBatch.getId());
@@ -550,6 +550,7 @@
assertEquals(expectedBatch.getSpecies().getId(), actualBatch.getSpecies().getId());
}
}
+
protected List<SpeciesBatchFrequency> assertCreateAndReloadSpeciesBatchFrequency(List<SpeciesBatchFrequency> frequencies, String parentBatchId) {
// Create batch
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplUpTodateTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplUpTodateTest.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplUpTodateTest.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -38,7 +38,6 @@
import org.springframework.jdbc.support.JdbcUtils;
import javax.swing.JDialog;
-import java.awt.GraphicsEnvironment;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
@@ -93,7 +92,7 @@
@After
public void tearDown() throws Exception {
- if (dialog!=null) {
+ if (dialog != null) {
dialog.setVisible(false);
}
service = null;
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-service/pom.xml 2013-02-15 20:28:55 UTC (rev 432)
@@ -79,6 +79,11 @@
</dependency>
<dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -107,7 +107,7 @@
decoratorProvider = new DecoratorProvider() {
@Override
protected void loadDecorators() {
-
+
registerTuttiDecorator(Zone.class, "${label}$s#${name}$s", SEPARATOR, " - ");
registerTuttiDecorator(Cruise.class, "${name}$s", SEPARATOR, " - ");
registerTuttiDecorator(TuttiProtocol.class, "${name}$s", SEPARATOR, " - ");
@@ -226,6 +226,7 @@
return result;
}
}
+
public static class ProgramDecorator extends TuttiDecorator<Program> implements Cloneable {
private static final long serialVersionUID = 1L;
@@ -243,6 +244,7 @@
return result;
}
}
+
public static class VesselDecorator extends TuttiDecorator<Vessel> implements Cloneable {
private static final long serialVersionUID = 1L;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -52,7 +52,6 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.List;
@@ -324,25 +323,21 @@
}
@Override
- @Transactional(readOnly = false)
public List<Species> importTemporarySpecies(List<Species> species) {
return driver.importTemporarySpecies(species);
}
@Override
- @Transactional(readOnly = false)
public List<Vessel> importTemporaryVessel(List<Vessel> vessels) {
return driver.importTemporaryVessel(vessels);
}
@Override
- @Transactional(readOnly = false)
public List<Person> importTemporaryPerson(List<Person> persons) {
return driver.importTemporaryPerson(persons);
}
@Override
- @Transactional(readOnly = false)
public List<Gear> importTemporaryGear(List<Gear> gears) {
return driver.importTemporaryGear(gears);
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDecorator.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDecorator.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDecorator.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -70,9 +70,9 @@
}
protected TuttiDecorator(Class<O> internalClass,
- String expression,
- String separator,
- String separatorReplacement) throws IllegalArgumentException, NullPointerException {
+ String expression,
+ String separator,
+ String separatorReplacement) throws IllegalArgumentException, NullPointerException {
super(internalClass,
expression,
separator,
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/PersonModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/PersonModel.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/PersonModel.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -25,7 +25,6 @@
*/
import fr.ifremer.tutti.persistence.entities.referential.Person;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.TuttiCsvUtil;
/**
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-02-15 20:28:55 UTC (rev 432)
@@ -1,4 +1,4 @@
-tutti.option.basedir.description=
+tutti.option.basedir.description=Répertoire principale
tutti.option.csv.separator.description=Caractère séparateur pour les import / export de fichier au format csv.
tutti.option.data.directory.description=Répertoire de données de l'application. Vous pouvez utiliser l'expression ${tutti.data.directory} pour le référence dans d'autres propriétés de configuration (ex\: ${tutti.data.directory}/tmp).
tutti.option.inceptionYear.description=Année de démarrage du projet.
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/pom.xml 2013-02-15 20:28:55 UTC (rev 432)
@@ -331,11 +331,6 @@
</dependency>
<dependency>
- <groupId>org.swinglabs.swingx</groupId>
- <artifactId>swingx-action</artifactId>
- </dependency>
-
- <dependency>
<groupId>com.ezware.oxbow</groupId>
<artifactId>swing-bits</artifactId>
</dependency>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -32,7 +32,7 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUIModel;
import jaxx.runtime.SwingUtil;
-import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.beans.AbstractBean;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -34,7 +34,6 @@
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.UIMessageNotifier;
import fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor;
-import java.awt.Color;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.editor.NumberEditor;
@@ -43,7 +42,7 @@
import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.reflect.ConstructorUtils;
+import org.apache.commons.lang3.reflect.ConstructorUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXDatePicker;
@@ -61,11 +60,13 @@
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
+import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.text.JTextComponent;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
@@ -82,9 +83,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.swing.JTextField;
-import javax.swing.UIManager;
-import org.apache.commons.lang3.ArrayUtils;
import static org.nuiton.i18n.I18n._;
@@ -293,13 +291,13 @@
Object component = entry.getValue();
if (component instanceof NumberEditor) {
initNumberEditor((NumberEditor) component);
-
+
} else if (component instanceof JXDatePicker) {
initDatePicker((JXDatePicker) component);
-
+
} else if (component instanceof SimpleTimeEditor) {
initTimeEditor((SimpleTimeEditor) component);
-
+
} else if (component instanceof JLabel) {
JLabel jLabel = (JLabel) component;
Boolean strongStyle = (Boolean) jLabel.getClientProperty("strongStyle");
@@ -315,7 +313,7 @@
}
jLabel.setText("<html>" + text + "</html>");
}
-
+
} else if (component instanceof JTextField) {
JTextField jTextField = (JTextField) component;
Boolean computed = (Boolean) jTextField.getClientProperty("computed");
@@ -326,7 +324,7 @@
jTextField.setEnabled(!computed);
jTextField.setDisabledTextColor(Color.BLUE);
}
-
+
} else if (component instanceof AbstractButton) {
AbstractButton abstractButton = (AbstractButton) component;
Class<? extends AbstractTuttiAction> actionName = (Class<? extends AbstractTuttiAction>) abstractButton.getClientProperty("tuttiAction");
@@ -581,11 +579,11 @@
}
});
}
-
+
protected Set<String> getPropertiesToIgnore() {
return Sets.newHashSet(
- AbstractTuttiBeanUIModel.PROPERTY_MODIFY,
- AbstractTuttiBeanUIModel.PROPERTY_VALID);
+ AbstractTuttiBeanUIModel.PROPERTY_MODIFY,
+ AbstractTuttiBeanUIModel.PROPERTY_VALID);
}
public <B> void selectFirstInCombo(BeanComboBox<B> combo) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUI.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUI.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUI.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -24,10 +24,11 @@
* #L%
*/
-import java.awt.Font;
-import javax.swing.UIManager;
import jaxx.runtime.JAXXObject;
+import javax.swing.UIManager;
+import java.awt.Font;
+
/**
* Contract to place on each generated jaxx ui.
*
@@ -119,7 +120,7 @@
* @since 0.1
*/
public static final String DECIMAL3_PATTERN = "\\d{0,6}|\\d{1,6}\\.\\d{0,3}";
-
+
/**
* Pattern to use for decimal numeric values with 2 digits + 3 decimal digits in
* editors.
@@ -129,6 +130,6 @@
public static final String DECIMAL2_3_PATTERN = "\\d{0,2}|\\d{1,2}\\.\\d{0,3}";
public static final Font TEXTFIELD_NORMAL_FONT = UIManager.getDefaults().getFont("TextField.font");
-
+
public static final Font TEXTFIELD_COMPUTED_FONT = UIManager.getDefaults().getFont("TextField.font").deriveFont(Font.ITALIC);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -40,7 +40,6 @@
import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUI;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.decorator.Decorator;
@@ -152,12 +151,12 @@
}
protected EditFishingOperationAction(FishingOperationsUIHandler handler,
- String name,
- String icon,
- String text,
- String tip,
- boolean hideBody) {
- super(handler, name,icon,text,tip,hideBody);
+ String name,
+ String icon,
+ String text,
+ String tip,
+ boolean hideBody) {
+ super(handler, name, icon, text, tip, hideBody);
}
public void setFishingOperation(FishingOperation fishingOperation) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -36,17 +36,15 @@
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType;
+import org.nuiton.util.DateUtil;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n.n_;
-import org.nuiton.util.DateUtil;
/**
* Model for UI {@link EditFishingOperationUI}.
@@ -799,5 +797,5 @@
setTrawlDistance(distance.floatValue());
}
}
-
+
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -32,34 +32,36 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.util.List;
-import java.util.Map;
-import javax.swing.JOptionPane;
-import javax.swing.JTextField;
import jaxx.runtime.JAXXUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.JOptionPane;
+import javax.swing.JTextField;
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.util.List;
+import java.util.Map;
+
import static org.nuiton.i18n.I18n._;
/**
- *
* @author kmorin <kmorin(a)codelutin.com>
* @since 1.0
*/
public class ComputeWeightsAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
private static final long serialVersionUID = 1L;
-
+
private static final Log log = LogFactory.getLog(ComputeWeightsAction.class);
protected String errorMessage;
+
protected String errorTitle;
+
protected Component errorComponent;
-
+
protected enum Weights {
UNSORTED, SAMPLE_SORTED, SORTED, TOTAL
}
@@ -76,29 +78,29 @@
@Override
protected void doAction(ActionEvent event) throws Exception {
Map<Weights, Float> speciesWeights = computeSpeciesBatches();
-
+
EditCatchesUI ui = getUI();
setComputedValue(ui.getCatchTotalUnsortedWeightField(),
- speciesWeights.get(Weights.UNSORTED));
+ speciesWeights.get(Weights.UNSORTED));
setComputedValue(ui.getCatchTotalSortedWeightField(),
- speciesWeights.get(Weights.SORTED));
-
+ speciesWeights.get(Weights.SORTED));
+
EditCatchesUIModel model = getModel();
Float totalWeight = model.getCatchTotalWeight();
Float rejectedWeight = model.getCatchTotalRejectedWeight();
-
+
if (rejectedWeight == null && totalWeight != null) {
if (!totalWeight.equals(speciesWeights.get(Weights.UNSORTED)
- + speciesWeights.get(Weights.SORTED))) {
+ + speciesWeights.get(Weights.SORTED))) {
errorMessage = _("tutti.action.computeWeights.error.incoherentTotal");
errorTitle = _("tutti.action.computeWeights.error.incoherentTotal.title");
errorComponent = ui.getCatchTotalWeightField();
-
+
} else {
-
- model.setCatchTotalRejectedComputedWeight(totalWeight
- - speciesWeights.get(Weights.UNSORTED)
- - speciesWeights.get(Weights.SORTED));
+
+ model.setCatchTotalRejectedComputedWeight(totalWeight
+ - speciesWeights.get(Weights.UNSORTED)
+ - speciesWeights.get(Weights.SORTED));
}
} else if (totalWeight == null) {
@@ -106,34 +108,34 @@
rejectedWeight = 0f;
}
model.setCatchTotalComputedWeight(speciesWeights.get(Weights.UNSORTED)
- + speciesWeights.get(Weights.SORTED)+ rejectedWeight);
-
- } else if (rejectedWeight != null
- && !totalWeight.equals(speciesWeights.get(Weights.UNSORTED)
- + speciesWeights.get(Weights.SORTED) + rejectedWeight)) {
+ + speciesWeights.get(Weights.SORTED) + rejectedWeight);
+
+ } else if (rejectedWeight != null
+ && !totalWeight.equals(speciesWeights.get(Weights.UNSORTED)
+ + speciesWeights.get(Weights.SORTED) + rejectedWeight)) {
errorMessage = _("tutti.action.computeWeights.error.incoherentTotal");
errorTitle = _("tutti.action.computeWeights.error.incoherentTotal.title");
errorComponent = ui.getCatchTotalWeightField();
}
-
+
}
-
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
-
+
protected Map<Weights, Float> computeSpeciesBatches() {
Map<Weights, Float> result = Maps.newEnumMap(Weights.class);
-
+
PersistenceService persistenceService =
getService(PersistenceService.class);
EditCatchesUIModel model = getModel();
-
+
Float totalSortedWeight = 0f;
Float totalUnsortedWeight = 0f;
SpeciesBatchUI speciesUI = getUI().getSpeciesTabContent();
EditCatchesUI ui = getUI();
-
+
List<SpeciesBatchRowModel> roots = getUI().getSpeciesTabContent().getModel().getRows();
for (SpeciesBatchRowModel row : roots) {
if (row.isBatchRoot()) {
@@ -163,23 +165,23 @@
if (livingNotItemizedWeight != null) {
totalSortedWeight += livingNotItemizedWeight.floatValue();
}
-
+
setComputedValue(speciesUI.getSpeciesTotalSampleSortedWeightField(),
- totalSortedWeight);
+ totalSortedWeight);
setComputedValue(ui.getSpeciesTotalSampleSortedWeightField(),
- totalSortedWeight);
+ totalSortedWeight);
result.put(Weights.SAMPLE_SORTED, totalSortedWeight);
-
+
Float speciesTotalSortedWeight = model.getSpeciesTotalSortedWeight();
if (speciesTotalSortedWeight == null) {
speciesTotalSortedWeight = totalSortedWeight;
model.setSpeciesTotalSortedComputedWeight(totalSortedWeight);
-
+
} else if (speciesTotalSortedWeight < totalSortedWeight) {
errorMessage = _("tutti.action.computeWeights.error.incoherentSpeciesTotalSorted");
errorTitle = _("tutti.action.computeWeights.error.incoherentSpeciesTotalSorted.title");
errorComponent = ui.getSpeciesTotalSortedWeightField();
-
+
} else if (speciesTotalSortedWeight < 1.05 * totalSortedWeight) {
// TODO Si le "Poids total VRAC" est saisi est que sa valeur
// est supérieure de moins de x% (x en configuration)
@@ -188,32 +190,32 @@
// sinon la remplacer par le "Poids total Vrac trié"
}
result.put(Weights.SORTED, speciesTotalSortedWeight);
-
+
setComputedValue(speciesUI.getSpeciesTotalUnsortedWeightField(),
- totalUnsortedWeight);
+ totalUnsortedWeight);
setComputedValue(ui.getSpeciesTotalUnsortedWeightField(),
- totalUnsortedWeight);
+ totalUnsortedWeight);
result.put(Weights.UNSORTED, totalUnsortedWeight);
-
+
Float totalWeight = totalUnsortedWeight + speciesTotalSortedWeight;
setComputedValue(speciesUI.getSpeciesTotalWeightField(),
- totalWeight);
+ totalWeight);
setComputedValue(ui.getSpeciesTotalWeightField(),
- totalWeight);
+ totalWeight);
result.put(Weights.TOTAL, speciesTotalSortedWeight);
-
+
speciesUI.getTable().repaint();
-
+
return result;
}
protected Float computeSpeciesBatch(SpeciesBatchRowModel row) {
SampleCategory finestCategory = row.getFinestCategory();
-
+
Float result = null;
Float categoryWeight = finestCategory.getCategoryWeight();
Float rowWeight = row.getWeight();
-
+
List<SpeciesBatchRowModel> children = row.getChildBatch();
// if the row is not a leaf
if (!row.isBatchLeaf()) {
@@ -227,19 +229,19 @@
}
sum += weight;
}
-
+
if (sum != null) {
if (categoryWeight == null) {
finestCategory.setComputedWeight(sum);
for (SpeciesBatchRowModel child : children) {
child.getFinestCategory().setSubSample(false);
}
-
+
} else if (categoryWeight < sum) {
errorMessage = _("tutti.action.computeWeights.error.incoherentParentCategoryWeight");
errorTitle = _("tutti.action.computeWeights.error.incoherentParentCategoryWeight.title");
errorComponent = null;
-
+
} else {
boolean subSample = categoryWeight > sum;
for (SpeciesBatchRowModel child : children) {
@@ -248,12 +250,12 @@
}
result = sum;
}
-
+
} else {// the row is a leaf
row.setComputedWeight(null);
-
+
List<SpeciesFrequencyRowModel> frequency = row.getFrequency();
-
+
if (CollectionUtils.isNotEmpty(frequency)) {
// if there are frequencies, then compute their weight
Float frequencyWeight = 0f;
@@ -264,35 +266,35 @@
// can't sum when a null value appears
frequencyWeight = null;
break;
-
+
} else if (frequencyWeight != null) {
// still can sum weights
frequencyWeight += w;
}
}
-
+
if (categoryWeight == null && rowWeight != null) {
errorMessage = _("tutti.action.computeWeights.error.incoherentRowWeightCategory");
errorTitle = _("tutti.action.computeWeights.error.incoherentRowWeightCategory.title");
errorComponent = null;
-
+
} else if (categoryWeight == null && frequencyWeight != null) {
// if the category weight is null and the frequencies have a weight,
// then this weight is the result
finestCategory.setComputedWeight(frequencyWeight);
result = frequencyWeight;
-
- } else if (frequencyWeight != null
- && !frequencyWeight.equals(categoryWeight)) {
-
+
+ } else if (frequencyWeight != null
+ && !frequencyWeight.equals(categoryWeight)) {
+
// if the weight of the frequencies is different from the category
// weight, then set the weight of the sample
if (categoryWeight != null && frequencyWeight > categoryWeight) {
errorMessage = _("tutti.action.computeWeights.error.incoherentCategoryWeight");
errorTitle = _("tutti.action.computeWeights.error.incoherentCategoryWeight.title");
errorComponent = null;
-
+
} else if (rowWeight == null) {
row.setComputedWeight(frequencyWeight);
@@ -302,11 +304,11 @@
errorComponent = null;
}
result = categoryWeight;
-
+
} else {
result = categoryWeight;
}
-
+
} else {
result = categoryWeight;
}
@@ -314,7 +316,7 @@
return result;
}
-
+
protected void setComputedValue(JTextField textField, Float value) {
String textValue;
if (value != null) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-02-15 20:28:55 UTC (rev 432)
@@ -37,7 +37,7 @@
fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI
fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
-
+
org.jdesktop.swingx.JXTitledPanel
jaxx.runtime.swing.CardLayout2Ext
@@ -73,10 +73,10 @@
<BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
<field name='catchTotalWeight' component='catchTotalWeightField'/>
-<!-- <field name='catchTotalSortedTremisWeight'
- component='catchTotalSortedTremisWeightField'/>
- <field name='catchTotalSortedCarousselWeight'
- component='catchTotalSortedCarousselWeightField'/>-->
+ <!-- <field name='catchTotalSortedTremisWeight'
+ component='catchTotalSortedTremisWeightField'/>
+ <field name='catchTotalSortedCarousselWeight'
+ component='catchTotalSortedCarousselWeightField'/>-->
<field name='catchTotalRejectedWeight'
component='catchTotalRejectedWeightField'/>
@@ -115,7 +115,7 @@
</cell>
<cell columns='4' weightx='1.0'>
<TuttiComputedOrNotDataEditor id='catchTotalWeightField'
- constructorParams='this'/>
+ constructorParams='this'/>
</cell>
</row>
<!-- Poids total trié balance tremie / caroussel-->
@@ -126,20 +126,20 @@
<cell columns='4' weightx='1.0'>
<JTextField id='catchTotalSortedWeightField'/>
</cell>
-<!-- <cell anchor='west'>
- <JLabel id='catchTotalSortedCarousselWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='catchTotalSortedCarousselWeightField'
- constructorParams='this'/>
- </cell>
- <cell anchor='west'>
- <JLabel id='catchTotalSortedTremisWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='catchTotalSortedTremisWeightField'
- constructorParams='this'/>
- </cell>-->
+ <!-- <cell anchor='west'>
+ <JLabel id='catchTotalSortedCarousselWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='catchTotalSortedCarousselWeightField'
+ constructorParams='this'/>
+ </cell>
+ <cell anchor='west'>
+ <JLabel id='catchTotalSortedTremisWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='catchTotalSortedTremisWeightField'
+ constructorParams='this'/>
+ </cell>-->
</row>
<!--Poids total hors vrac-->
<row>
@@ -156,8 +156,9 @@
<JLabel id='catchTotalRejectedWeightLabel'/>
</cell>
<cell columns='4' weightx='1.0'>
- <TuttiComputedOrNotDataEditor id='catchTotalRejectedWeightField'
- constructorParams='this'/>
+ <TuttiComputedOrNotDataEditor
+ id='catchTotalRejectedWeightField'
+ constructorParams='this'/>
</cell>
</row>
<row>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -141,7 +141,7 @@
EditCatchesUIModel.PROPERTY_CATCH_TOTAL_COMPUTED_WEIGHT,
EditCatchesUIModel.PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_COMPUTED_WEIGHT
- ));
+ ));
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -28,11 +28,12 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
import static org.nuiton.i18n.I18n._;
/**
@@ -44,7 +45,7 @@
private static final long serialVersionUID = 1L;
public static final String PROPERTY_CATCH_TOTAL_WEIGHT = "catchTotalWeight";
-
+
public static final String PROPERTY_CATCH_TOTAL_COMPUTED_WEIGHT = "catchTotalComputedWeight";
public static final String PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT = "catchTotalSortedTremisWeight";
@@ -52,11 +53,11 @@
public static final String PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT = "catchTotalSortedCarousselWeight";
public static final String PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT = "catchTotalRejectedWeight";
-
+
public static final String PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT = "catchTotalRejectedComputedWeight";
public static final String PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT = "speciesTotalSortedWeight";
-
+
public static final String PROPERTY_SPECIES_TOTAL_SORTED_COMPUTED_WEIGHT = "speciesTotalSortedComputedWeight";
public static final String PROPERTY_SPECIES_TOTAL_INERT_WEIGHT = "speciesTotalInertWeight";
@@ -157,32 +158,32 @@
public EditCatchesUIModel() {
super(CatchBatch.class, fromBeanBinder, toBeanBinder);
speciesTotalSortedComputedOrNotWeight.addPropertyChangeListener(
- TuttiComputedOrNotData.PROPERTY_DATA,
+ TuttiComputedOrNotData.PROPERTY_DATA,
new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- firePropertyChange(PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
- evt.getOldValue(), evt.getNewValue());
- }
- });
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
+ evt.getOldValue(), evt.getNewValue());
+ }
+ });
catchTotalComputedOrNotWeight.addPropertyChangeListener(
- TuttiComputedOrNotData.PROPERTY_DATA,
+ TuttiComputedOrNotData.PROPERTY_DATA,
new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- firePropertyChange(PROPERTY_CATCH_TOTAL_WEIGHT,
- evt.getOldValue(), evt.getNewValue());
- }
- });
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_CATCH_TOTAL_WEIGHT,
+ evt.getOldValue(), evt.getNewValue());
+ }
+ });
catchTotalRejectedComputedOrNotWeight.addPropertyChangeListener(
- TuttiComputedOrNotData.PROPERTY_DATA,
+ TuttiComputedOrNotData.PROPERTY_DATA,
new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- firePropertyChange(PROPERTY_CATCH_TOTAL_COMPUTED_WEIGHT,
- evt.getOldValue(), evt.getNewValue());
- }
- });
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_CATCH_TOTAL_COMPUTED_WEIGHT,
+ evt.getOldValue(), evt.getNewValue());
+ }
+ });
}
@Override
@@ -213,7 +214,7 @@
public TuttiComputedOrNotData<Float> getCatchTotalComputedOrNotWeight() {
return catchTotalComputedOrNotWeight;
}
-
+
public Float getCatchTotalWeight() {
return catchTotalComputedOrNotWeight.getData();
}
@@ -223,7 +224,7 @@
this.catchTotalComputedOrNotWeight.setData(catchTotalWeight);
firePropertyChange(PROPERTY_CATCH_TOTAL_WEIGHT, oldValue, catchTotalWeight);
}
-
+
public Float getCatchTotalComputedWeight() {
return catchTotalComputedOrNotWeight.getComputedData();
}
@@ -257,7 +258,7 @@
public TuttiComputedOrNotData<Float> getCatchTotalRejectedComputedOrNotWeight() {
return catchTotalRejectedComputedOrNotWeight;
}
-
+
public Float getCatchTotalRejectedWeight() {
return catchTotalRejectedComputedOrNotWeight.getData();
}
@@ -277,11 +278,11 @@
this.catchTotalRejectedComputedOrNotWeight.setComputedData(catchTotalRejectedComputedWeight);
firePropertyChange(PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT, oldValue, catchTotalRejectedComputedWeight);
}
-
+
public TuttiComputedOrNotData<Float> getSpeciesTotalSortedComputedOrNotWeight() {
return speciesTotalSortedComputedOrNotWeight;
}
-
+
public Float getSpeciesTotalSortedWeight() {
return speciesTotalSortedComputedOrNotWeight.getData();
}
@@ -291,7 +292,7 @@
this.speciesTotalSortedComputedOrNotWeight.setData(speciesTotalSortedWeight);
firePropertyChange(PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, oldValue, speciesTotalSortedWeight);
}
-
+
public Float getSpeciesTotalSortedComputedWeight() {
return speciesTotalSortedComputedOrNotWeight.getComputedData();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -65,19 +65,19 @@
* @since 1.0
*/
protected Float computedWeight;
-
+
/**
* Is this sample a subsample ?
* Available only if the category is the finest category of the row
- *
+ *
* @since 1.0
*/
protected boolean subSample;
-
+
/**
* Has the row only one frequency ?
* Available only if the category is the finest category of the row
- *
+ *
* @since 1.0
*/
protected boolean onlyOneFrequency;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -209,7 +209,7 @@
boolean hasFocus,
int row,
int column) {
-
+
SampleCategory<C> sampleCategory = (SampleCategory<C>) value;
String text = null;
@@ -222,7 +222,7 @@
Float computedNumber = sampleCategory.getComputedWeight();
text = "<html>" + categoryDecorator.toString(categoryValue) + " /";
-
+
if (sampleCategory.isSubSample()) {
text += "/";
}
@@ -230,14 +230,14 @@
if (number != null) {
text += String.format("%.3f", number);
-
+
} else if (computedNumber != null) {
if (sampleCategory.hasOnlyOneFrequency()) {
text += String.format("%.3f", computedNumber);
-
+
} else {
String blue = Integer.toHexString(Color.BLUE.getRGB()).substring(2);
- text += "<em style='color: #" + blue + "'>" +
+ text += "<em style='color: #" + blue + "'>" +
String.format("%.3f", computedNumber) + "</em>";
}
} else {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -34,15 +34,14 @@
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import org.apache.commons.collections.CollectionUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.Collections;
import java.util.List;
-import org.apache.commons.logging.LogFactory;
/**
* Represents a species batch (i.e a row in the batch table).
@@ -99,7 +98,7 @@
public static final String PROPERTY_FREQUENCY = "frequency";
public static final String PROPERTY_COMPUTED_NUMBER = "computedOrNotNumber";
-
+
public static final String PROPERTY_COMPUTED_WEIGHT = "computedOrNotWeight";
public static final String PROPERTY_ATTACHMENTS = "attachments";
@@ -242,40 +241,40 @@
sexCategory = SampleCategory.newSample(SampleCategoryType.sex);
maturityCategory = SampleCategory.newSample(SampleCategoryType.maturity);
ageCategory = SampleCategory.newSample(SampleCategoryType.age);
-
+
computedOrNotWeight.addPropertyChangeListener(
TuttiComputedOrNotData.PROPERTY_DATA,
new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- firePropertyChange(PROPERTY_WEIGHT, evt.getOldValue(), evt.getNewValue());
- }
- });
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_WEIGHT, evt.getOldValue(), evt.getNewValue());
+ }
+ });
computedOrNotWeight.addPropertyChangeListener(
TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA,
new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- firePropertyChange(PROPERTY_COMPUTED_WEIGHT, evt.getOldValue(), evt.getNewValue());
- }
- });
-
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_COMPUTED_WEIGHT, evt.getOldValue(), evt.getNewValue());
+ }
+ });
+
computedOrNotNumber.addPropertyChangeListener(
TuttiComputedOrNotData.PROPERTY_DATA,
new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- firePropertyChange(PROPERTY_NUMBER, evt.getOldValue(), evt.getNewValue());
- }
- });
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_NUMBER, evt.getOldValue(), evt.getNewValue());
+ }
+ });
computedOrNotNumber.addPropertyChangeListener(
TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA,
new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- firePropertyChange(PROPERTY_COMPUTED_NUMBER, evt.getOldValue(), evt.getNewValue());
- }
- });
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_COMPUTED_NUMBER, evt.getOldValue(), evt.getNewValue());
+ }
+ });
}
public SpeciesBatchRowModel(SpeciesBatch aBatch,
@@ -343,7 +342,7 @@
}
return finestCategory;
}
-
+
//------------------------------------------------------------------------//
//-- Species category --//
//------------------------------------------------------------------------//
@@ -620,7 +619,7 @@
public void setComputedNumber(Integer computedNumber) {
computedOrNotNumber.setComputedData(computedNumber);
}
-
+
public Float getComputedWeight() {
return computedOrNotWeight.getComputedData();
}
@@ -644,5 +643,5 @@
public void setComputedOrNotWeight(TuttiComputedOrNotData<Float> computedOrNotWeight) {
this.computedOrNotWeight = computedOrNotWeight;
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -33,7 +33,6 @@
import javax.swing.table.TableColumnModel;
import java.util.Set;
-import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n.n_;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-02-15 20:28:55 UTC (rev 432)
@@ -99,7 +99,7 @@
</cell>
<cell weightx='1.0'>
<TuttiComputedOrNotDataEditor id='speciesTotalSortedWeightField'
- constructorParams='this'/>
+ constructorParams='this'/>
</cell>
</row>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -420,7 +420,7 @@
}
List<Species> speciesList = persistenceService.getAllSpecies(protocol);
-
+
SPECIES_UNIVERSE_CONTEXT_ENTRY.setContextValue(ui, speciesList);
FREQUENCY_LENGTH_CONTEXT_ENTRY.setContextValue(ui, lengthCaracterics);
}
@@ -585,11 +585,11 @@
{ // Weight column
addColumnToModel(columnModel,
- TuttiComputedOrNotDataTableCell.newEditor(
- Float.class, false, true, 3),
- TuttiComputedOrNotDataTableCell.newRender(
- defaultRenderer, true, 3),
- SpeciesBatchTableModel.WEIGHT);
+ TuttiComputedOrNotDataTableCell.newEditor(
+ Float.class, false, true, 3),
+ TuttiComputedOrNotDataTableCell.newRender(
+ defaultRenderer, true, 3),
+ SpeciesBatchTableModel.WEIGHT);
}
{ // Number column (from frequencies)
@@ -864,7 +864,7 @@
SpeciesBatch catchBean = row.toBean();
catchBean.setFishingOperation(fishingOperation);
-
+
SpeciesBatchRowModel parent = row.getParentBatch();
if (parent != null) {
catchBean.setParentBatch(parent.toBean());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -149,7 +149,7 @@
public void setSpeciesTotalSortedWeight(Float speciesTotalSortedWeight) {
catchesUIModel.setSpeciesTotalSortedWeight(speciesTotalSortedWeight);
}
-
+
public Float getSpeciesTotalSortedComputedWeight() {
return catchesUIModel.getSpeciesTotalSortedComputedWeight();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -26,7 +26,6 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
@@ -47,7 +46,6 @@
import javax.swing.table.TableCellRenderer;
import java.awt.Color;
import java.awt.Component;
-import java.awt.Font;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
@@ -74,7 +72,7 @@
setHorizontalAlignment(CENTER);
setIcon(SwingUtil.createActionIcon("show-frequency"));
}
-
+
public void setComputedOrNotText(TuttiComputedOrNotData<Integer> data) {
String text;
@@ -82,8 +80,8 @@
text = String.valueOf(data.getData());
} else if (data != null
- && data.getComputedData() != null
- && data.getComputedData() != 0) {
+ && data.getComputedData() != null
+ && data.getComputedData() != 0) {
String blue = Integer.toHexString(Color.BLUE.getRGB()).substring(2);
text = "<html><em style='color: #" + blue + "'>" + data.getComputedData() + "</em></html>";
@@ -172,7 +170,7 @@
// at close, synch back frequencies
List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList();
-
+
if (frequencyModel.isSimpleCountingMode()) {
editRow.setNumber(frequencyModel.getSimpleCount());
@@ -226,7 +224,7 @@
}
TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value;
component.setComputedOrNotText(data);
-
+
rowIndex = row;
columnIndex = column;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -79,7 +79,7 @@
private Map<Integer, SpeciesProtocol> speciesProtocol;
private Map<String, Caracteristic> lengthStepCaracteristics;
-
+
protected Set<SpeciesFrequencyRowModel> withWeightRows = Sets.newHashSet();
public SpeciesFrequencyUIHandler(TuttiUIContext context,
@@ -120,13 +120,13 @@
Object newValue) {
boolean recomputeAllRows;
-
+
if (row.getWeight() != null) {
// check if no row had a weight, then if one of them now has a weight,
// the other ones must have one too to be valid
recomputeAllRows = withWeightRows.isEmpty();
withWeightRows.add(row);
-
+
} else {
withWeightRows.remove(row);
// check if no row has a weight, then if none of them now has a weight,
@@ -201,7 +201,7 @@
}
}
-
+
initBeanComboBox(ui.getLengthStepCaracteristicComboBox(),
lengthStepCaracterics,
model.getLengthStepCaracteristic());
@@ -278,7 +278,7 @@
initTable(table);
installTableKeyListener(columnModel, table);
-
+
listenValidatorValid(ui.getValidator(), model);
}
@@ -394,9 +394,9 @@
public void editBatch(SpeciesBatchRowModel speciesBatch, FrequencyCellEditor editor) {
withWeightRows.clear();
-
+
frequencyEditor = editor;
-
+
Caracteristic lengthStepCaracteristic = null;
Float lengthStep = 1f;
@@ -421,7 +421,7 @@
newRow.setNumber(rowModel.getNumber());
newRow.setWeight(rowModel.getWeight());
editFrequency.add(newRow);
-
+
if (newRow.getWeight() != null) {
withWeightRows.add(newRow);
}
@@ -440,7 +440,7 @@
lengthStep);
}
}
-
+
if (lengthStepCaracteristic == null && protocol != null) {
Species species = speciesBatch.getSpecies();
@@ -493,7 +493,7 @@
model.setRows(editFrequency);
model.setLengthStepCaracteristic(lengthStepCaracteristic);
-
+
// keep batch (will be used to push back editing entry)
model.setBatch(speciesBatch);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -27,25 +27,22 @@
* #L%
*/
-/**
- *
- * @author kmorin <kmorin(a)codelutin.com>
- */
+/** @author kmorin <kmorin(a)codelutin.com> */
public class TuttiComputedOrNotData<N extends Number> extends AbstractBean {
public static final String PROPERTY_DATA = "data";
-
+
public static final String PROPERTY_COMPUTED_DATA = "computedData";
-
+
protected N data;
-
+
protected N computedData;
-
+
public TuttiComputedOrNotData() {
data = null;
computedData = null;
}
-
+
public TuttiComputedOrNotData(N data, N computedData) {
this.data = data;
this.computedData = computedData;
@@ -70,7 +67,7 @@
this.computedData = computedData;
firePropertyChange(PROPERTY_COMPUTED_DATA, oldValue, computedData);
}
-
+
@Override
public String toString() {
String result = null;
@@ -81,5 +78,5 @@
}
return result;
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -325,21 +325,21 @@
}
return duration;
}
-
- public static int computeDistanceInMeters(Float startLatitude,
+
+ public static int computeDistanceInMeters(Float startLatitude,
Float startLongitude,
- Float endLatitude,
+ Float endLatitude,
Float endLongitude) {
-
+
double sLat = startLatitude * Math.PI / 180;
double sLong = startLongitude * Math.PI / 180;
double eLat = endLatitude * Math.PI / 180;
double eLong = endLongitude * Math.PI / 180;
-
+
Double d = 6378288 *
- (Math.PI/2 - Math.asin( Math.sin(eLat) * Math.sin(sLat)
- + Math.cos(eLong - sLong) * Math.cos(eLat) * Math.cos(sLat)));
+ (Math.PI / 2 - Math.asin(Math.sin(eLat) * Math.sin(sLat)
+ + Math.cos(eLong - sLong) * Math.cos(eLat) * Math.cos(sLat)));
return d.intValue();
-
+
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionUI.jaxx 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionUI.jaxx 2013-02-15 20:28:55 UTC (rev 432)
@@ -21,7 +21,8 @@
<http://www.gnu.org/licenses/gpl-3.0.html>.
#L%
-->
-<JDialog layout='{new BorderLayout()}' width='300' height='200' modal='true' undecorated='true'
+<JDialog layout='{new BorderLayout()}' width='300' height='200' modal='true'
+ undecorated='true'
implements='fr.ifremer.tutti.ui.swing.TuttiUI<TuttiActionUIModel, TuttiActionUIHandler>'>
<import>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -31,6 +31,22 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.ComponentMover;
+import jaxx.runtime.swing.ComponentResizer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.BorderFactory;
+import javax.swing.JDialog;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
import java.awt.Color;
import java.awt.Component;
import java.awt.Frame;
@@ -41,21 +57,6 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Collection;
-import javax.swing.AbstractCellEditor;
-import javax.swing.BorderFactory;
-import javax.swing.JDialog;
-import javax.swing.JTable;
-import javax.swing.border.LineBorder;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.ComponentMover;
-import jaxx.runtime.swing.ComponentResizer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.decorator.Decorator;
import static org.nuiton.i18n.I18n._;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-02-15 20:28:55 UTC (rev 432)
@@ -1,23 +1,23 @@
<jaxx.runtime.swing.editor.NumberEditor>
-
+
<import>
fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData
</import>
-
+
<String id='property' javaBean='TuttiComputedOrNotData.PROPERTY_DATA'/>
-
+
<TuttiComputedOrNotData id='bean' genericType='?' javaBean='null'/>
-
+
<!-- ui handler -->
<TuttiComputedOrNotDataEditorHandler id='handler' constructorParams='this'/>
-
+
<Integer id='decimalNumber' javaBean='null'/>
-
+
<script><![CDATA[
public void setProperty(String property) {
// cannot change the property
}
]]>
</script>
-
+
</jaxx.runtime.swing.editor.NumberEditor>
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -3,36 +3,32 @@
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.swing.editor.NumberEditorHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JTextField;
import java.awt.Color;
-import java.awt.Font;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.regex.Matcher;
-import javax.swing.JTextField;
-import javax.swing.UIManager;
-import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.swing.editor.NumberEditorHandler;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
- *
* @author kmorin <kmorin(a)codelutin.com>
* @since 1.0
*/
public class TuttiComputedOrNotDataEditorHandler extends NumberEditorHandler {
private static final Log log = LogFactory.getLog(TuttiComputedOrNotDataEditorHandler.class);
-
+
protected Integer decimalNumber;
-
+
public TuttiComputedOrNotDataEditorHandler(TuttiComputedOrNotDataEditor ui) {
super(ui);
}
-
+
@Override
public void init() {
final PropertyChangeListener l = new PropertyChangeListener() {
@@ -41,7 +37,7 @@
setComputedTextIfNullModel();
}
};
-
+
TuttiComputedOrNotData bean = (TuttiComputedOrNotData) editor.getBean();
if (bean != null) {
bean.addPropertyChangeListener(TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, l);
@@ -49,19 +45,19 @@
editor.addPropertyChangeListener(TuttiComputedOrNotDataEditor.PROPERTY_BEAN, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
-
+
TuttiComputedOrNotData bean = (TuttiComputedOrNotData) evt.getOldValue();
if (bean != null) {
bean.removePropertyChangeListener(TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, l);
}
-
+
bean = (TuttiComputedOrNotData) evt.getNewValue();
if (bean != null) {
bean.addPropertyChangeListener(TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, l);
}
}
});
-
+
editor.getTextField().addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
@@ -77,31 +73,31 @@
setComputedTextIfNullModel();
}
});
-
+
editor.addPropertyChangeListener(TuttiComputedOrNotDataEditor.PROPERTY_DECIMAL_NUMBER,
- new PropertyChangeListener() {
+ new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- decimalNumber = (Integer) evt.getNewValue();
- }
- });
+ public void propertyChange(PropertyChangeEvent evt) {
+ decimalNumber = (Integer) evt.getNewValue();
+ }
+ });
decimalNumber = ((TuttiComputedOrNotDataEditor) editor).getDecimalNumber();
-
+
super.init();
-
+
}
-
+
protected void setComputedTextIfNullModel() {
TuttiComputedOrNotData bean = (TuttiComputedOrNotData) editor.getBean();
if (bean != null && editor.getModel() == null) {
JTextField tf = editor.getTextField();
tf.setFont(TuttiUI.TEXTFIELD_COMPUTED_FONT);
tf.setForeground(Color.BLUE);
-
+
String modelText;
Number computedData = bean.getComputedData();
- if (editor.isUseFloat()
- && decimalNumber != null && computedData != null) {
+ if (editor.isUseFloat()
+ && decimalNumber != null && computedData != null) {
modelText = String.format("%." + decimalNumber + "f", computedData);
} else {
modelText = JAXXUtil.getStringValue(computedData);
@@ -109,5 +105,5 @@
tf.setText(modelText);
}
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-02-15 20:01:16 UTC (rev 431)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-02-15 20:28:55 UTC (rev 432)
@@ -2,11 +2,8 @@
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
+import jaxx.runtime.JAXXUtil;
+
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.SwingConstants;
@@ -17,7 +14,11 @@
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
-import jaxx.runtime.JAXXUtil;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
/**
* Editor for TuttiComputedOrNotData
@@ -30,8 +31,8 @@
public static TableCellRenderer newRender(TableCellRenderer renderer,
boolean useFloat,
Integer decimalNumber) {
-
- return new TuttiComputedOrNotDataTableCellRenderer(renderer,
+
+ return new TuttiComputedOrNotDataTableCellRenderer(renderer,
useFloat,
decimalNumber);
}
@@ -40,9 +41,9 @@
boolean useSign,
boolean useFloat,
Integer decimalNumber) {
-
- return new TuttiComputedOrNotDataTableCellEditor(type, useSign,
- useFloat, decimalNumber);
+
+ return new TuttiComputedOrNotDataTableCellEditor(type, useSign,
+ useFloat, decimalNumber);
}
public static class TuttiComputedOrNotDataTableCellEditor
@@ -50,17 +51,17 @@
implements TableCellEditor, FocusListener, AncestorListener {
private static final long serialVersionUID = 1L;
+
protected final TuttiComputedOrNotDataEditor numberEditor;
+
protected TuttiComputedOrNotData data;
- /**
- * constructor
- */
- public TuttiComputedOrNotDataTableCellEditor(Class type,
+ /** constructor */
+ public TuttiComputedOrNotDataTableCellEditor(Class type,
boolean useSign,
boolean useFloat,
Integer decimalNumber) {
-
+
numberEditor = new TuttiComputedOrNotDataEditor();
numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT);
numberEditor.getTextField().addFocusListener(this);
@@ -78,7 +79,7 @@
@Override
public Component getTableCellEditorComponent(JTable table, Object value,
- boolean isSelected, int row, int column) {
+ boolean isSelected, int row, int column) {
data = (TuttiComputedOrNotData) value;
numberEditor.setModel(data.getData());
@@ -145,33 +146,33 @@
return result;
}
}
-
+
public static class TuttiComputedOrNotDataTableCellRenderer<E>
- implements TableCellRenderer {
+ implements TableCellRenderer {
protected final TableCellRenderer delegate;
-
+
protected Integer decimalNumber;
-
+
protected boolean useFloat;
public TuttiComputedOrNotDataTableCellRenderer(
TableCellRenderer delegate,
boolean useFloat,
Integer decimalNumber) {
-
+
this.delegate = delegate;
this.useFloat = useFloat;
this.decimalNumber = decimalNumber;
}
-
- public Component getTableCellRendererComponent(JTable table,
- Object value,
- boolean isSelected,
- boolean hasFocus,
- int row,
- int column) {
-
+
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+
TuttiComputedOrNotData data = (TuttiComputedOrNotData) value;
Number dataValue = data.getData();
Font font;
@@ -180,7 +181,7 @@
dataValue = data.getComputedData();
font = TuttiUI.TEXTFIELD_COMPUTED_FONT;
foreground = Color.BLUE;
-
+
} else {
font = TuttiUI.TEXTFIELD_NORMAL_FONT;
foreground = Color.BLACK;
@@ -192,18 +193,18 @@
} else {
text = JAXXUtil.getStringValue(dataValue);
}
-
+
Component component = delegate.getTableCellRendererComponent(table,
- text,
- isSelected,
- hasFocus,
- row,
- column);
+ text,
+ isSelected,
+ hasFocus,
+ row,
+ column);
component.setFont(font);
component.setForeground(foreground);
-
+
return component;
}
-
+
}
}
1
0
r431 - in trunk: . tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing
by tchemit@users.forge.codelutin.com 15 Feb '13
by tchemit@users.forge.codelutin.com 15 Feb '13
15 Feb '13
Author: tchemit
Date: 2013-02-15 21:01:16 +0100 (Fri, 15 Feb 2013)
New Revision: 431
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/431
Log:
use last nuiton-utils version
Modified:
trunk/pom.xml
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-02-15 19:16:17 UTC (rev 430)
+++ trunk/pom.xml 2013-02-15 20:01:16 UTC (rev 431)
@@ -124,7 +124,7 @@
<!-- libraries version -->
- <nuitonUtilsVersion>2.6.8-SNAPSHOT</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.6.8</nuitonUtilsVersion>
<nuitonI18nVersion>2.5</nuitonI18nVersion>
<eugenePluginVersion>2.6.1</eugenePluginVersion>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-02-15 19:16:17 UTC (rev 430)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-02-15 20:01:16 UTC (rev 431)
@@ -29,6 +29,7 @@
import com.google.common.collect.Maps;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.service.synchro.ReferentialSynchronizeResult;
+import fr.ifremer.tutti.service.TuttiTechnicalException;
import fr.ifremer.tutti.service.referential.TuttiReferentialSynchronizeService;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
import org.apache.commons.io.FileUtils;
@@ -103,9 +104,9 @@
ApplicationUpdater.ApplicationInfo info = getInfo(UpdateType.DB, result);
if (info == null) {
- dbUpdated=false;
+ dbUpdated = false;
} else {
- dbUpdated=true;
+ dbUpdated = true;
}
}
return result;
@@ -302,11 +303,9 @@
} catch (IOException e) {
throw new RuntimeException("Could not delete temporary directory " + target, e);
}
-
}
protected void synchronizetDatabase(ApplicationUpdater.ApplicationInfo info) {
- //TODO synchro referential
if (log.isInfoEnabled()) {
log.info(String.format("A database update was downloaded (oldVersion: %s, newVersion: %s), will launch a referential synchronize operation ", info.oldVersion, info.newVersion));
}
@@ -317,5 +316,11 @@
TuttiActionUI actionUI = context.getActionUI();
actionUI.getModel().setProgressionModel(result.getProgressionModel());
service.prepare(dbDirectory, result);
+
+ if (!result.isSuccess()) {
+ throw new TuttiTechnicalException("Could not prepare synchro", result.getError());
+ }
+
+ service.synchronize(dbDirectory, result);
}
}
1
0