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
- 4058 discussions
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
r430 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation/catches java/fr/ifremer/tutti/ui/swing/content/operation/catches/species resources/i18n
by kmorin@users.forge.codelutin.com 15 Feb '13
by kmorin@users.forge.codelutin.com 15 Feb '13
15 Feb '13
Author: kmorin
Date: 2013-02-15 20:16:17 +0100 (Fri, 15 Feb 2013)
New Revision: 430
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/430
Log:
resolves #2003
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/EditCatchesUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.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/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 18:55:19 UTC (rev 429)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-02-15 19:16:17 UTC (rev 430)
@@ -32,6 +32,7 @@
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;
@@ -54,6 +55,10 @@
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
@@ -83,21 +88,32 @@
Float rejectedWeight = model.getCatchTotalRejectedWeight();
if (rejectedWeight == null && totalWeight != null) {
- model.setCatchTotalRejectedComputedWeight(totalWeight
- - speciesWeights.get(Weights.UNSORTED)
- - speciesWeights.get(Weights.SORTED));
-
+ if (!totalWeight.equals(speciesWeights.get(Weights.UNSORTED)
+ + 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));
+ }
+
} else if (totalWeight == null) {
if (rejectedWeight == null) {
rejectedWeight = 0f;
}
model.setCatchTotalComputedWeight(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)) {
- // TODO handle error
+ + speciesWeights.get(Weights.SORTED) + rejectedWeight)) {
+ errorMessage = _("tutti.action.computeWeights.error.incoherentTotal");
+ errorTitle = _("tutti.action.computeWeights.error.incoherentTotal.title");
+ errorComponent = ui.getCatchTotalWeightField();
}
}
@@ -160,7 +176,10 @@
model.setSpeciesTotalSortedComputedWeight(totalSortedWeight);
} else if (speciesTotalSortedWeight < totalSortedWeight) {
- // TODO handle error
+ 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)
@@ -217,7 +236,9 @@
}
} else if (categoryWeight < sum) {
- // handle error
+ errorMessage = _("tutti.action.computeWeights.error.incoherentParentCategoryWeight");
+ errorTitle = _("tutti.action.computeWeights.error.incoherentParentCategoryWeight.title");
+ errorComponent = null;
} else {
boolean subSample = categoryWeight > sum;
@@ -252,7 +273,9 @@
}
if (categoryWeight == null && rowWeight != null) {
- //TODO handle error
+ 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,
@@ -266,13 +289,17 @@
// if the weight of the frequencies is different from the category
// weight, then set the weight of the sample
if (categoryWeight != null && frequencyWeight > categoryWeight) {
- //TODO handle error
+ errorMessage = _("tutti.action.computeWeights.error.incoherentCategoryWeight");
+ errorTitle = _("tutti.action.computeWeights.error.incoherentCategoryWeight.title");
+ errorComponent = null;
} else if (rowWeight == null) {
row.setComputedWeight(frequencyWeight);
} else if (!rowWeight.equals(frequencyWeight)) {
- //TODO handle error
+ errorMessage = _("tutti.action.computeWeights.error.incoherentRowWeightFrequency");
+ errorTitle = _("tutti.action.computeWeights.error.incoherentRowWeightFrequency.title");
+ errorComponent = null;
}
result = categoryWeight;
@@ -297,4 +324,21 @@
}
textField.setText(textValue);
}
+
+ @Override
+ protected void releaseAction(ActionEvent event) {
+ if (errorMessage != null) {
+ JOptionPane.showMessageDialog(
+ getUI(),
+ errorMessage,
+ errorTitle,
+ JOptionPane.ERROR_MESSAGE);
+ }
+ if (errorComponent != null) {
+ errorComponent.requestFocus();
+ }
+ errorMessage = null;
+ errorComponent = null;
+ }
+
}
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 18:55:19 UTC (rev 429)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-02-15 19:16:17 UTC (rev 430)
@@ -28,6 +28,8 @@
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;
@@ -154,6 +156,33 @@
public EditCatchesUIModel() {
super(CatchBatch.class, fromBeanBinder, toBeanBinder);
+ speciesTotalSortedComputedOrNotWeight.addPropertyChangeListener(
+ TuttiComputedOrNotData.PROPERTY_DATA,
+ new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
+ evt.getOldValue(), evt.getNewValue());
+ }
+ });
+ catchTotalComputedOrNotWeight.addPropertyChangeListener(
+ TuttiComputedOrNotData.PROPERTY_DATA,
+ new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_CATCH_TOTAL_WEIGHT,
+ evt.getOldValue(), evt.getNewValue());
+ }
+ });
+ catchTotalRejectedComputedOrNotWeight.addPropertyChangeListener(
+ TuttiComputedOrNotData.PROPERTY_DATA,
+ new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_CATCH_TOTAL_COMPUTED_WEIGHT,
+ evt.getOldValue(), evt.getNewValue());
+ }
+ });
}
@Override
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 18:55:19 UTC (rev 429)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-15 19:16:17 UTC (rev 430)
@@ -41,7 +41,6 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
@@ -89,10 +88,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.swing.border.LineBorder;
-import jaxx.runtime.swing.JAXXWidgetUtil;
-import jaxx.runtime.swing.editor.cell.NumberCellEditor;
-import org.apache.commons.lang.reflect.ConstructorUtils;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
@@ -293,12 +288,9 @@
@Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor,
SpeciesBatchRowModel row) {
-log.debug("saveSelectedRowIfRequired");
if (row.isValid()) {
// there is a valid bean attached to the monitor
-log.debug("isValid");
if (rowMonitor.wasModified()) {
-log.debug("wasModified");
// monitored bean was modified, save it
if (log.isInfoEnabled()) {
@@ -315,7 +307,6 @@
rowMonitor.clearModified();
}
} else {
-log.debug("wasNotModified");
//FIXME See how to delete rows ? Or moreover how to save tehem...
if (log.isWarnEnabled()) {
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 18:55:19 UTC (rev 429)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-15 19:16:17 UTC (rev 430)
@@ -30,6 +30,18 @@
tutti.action.closeDb=Fermer
tutti.action.closeDb.tip=Fermer la base de données en cours d'utilisation
tutti.action.computeWeights=Elever les poids
+tutti.action.computeWeights.error.incoherentCategoryWeight=Le poids total des mensurations est supérieur au poids de la catégorie
+tutti.action.computeWeights.error.incoherentCategoryWeight.title=Incohérence
+tutti.action.computeWeights.error.incoherentParentCategoryWeight=Le poids de la catégorie est différent de la somme des poids de ses sous-catégories
+tutti.action.computeWeights.error.incoherentParentCategoryWeight.title=Incohérence
+tutti.action.computeWeights.error.incoherentRowWeightCategory=Le poids de la catégorie ne peut pas être nul si le poids de sous-échantillonage est renseigné
+tutti.action.computeWeights.error.incoherentRowWeightCategory.title=Incohérence
+tutti.action.computeWeights.error.incoherentRowWeightFrequency=Le poids total des mensurations est différent du poids du sous-échantillon
+tutti.action.computeWeights.error.incoherentRowWeightFrequency.title=Incohérence
+tutti.action.computeWeights.error.incoherentSpeciesTotalSorted=Le poids total Vrac des espèces est inférieur à la somme des poids Vrac triés, inerte trié et vivant non détaillé trié
+tutti.action.computeWeights.error.incoherentSpeciesTotalSorted.title=Incohérence
+tutti.action.computeWeights.error.incoherentTotal=Le poids total de la capture ne correspond pas à la somme des poids totaux Vrac, Hors Vrac et non triés
+tutti.action.computeWeights.error.incoherentTotal.title=Incohérence
tutti.action.computeWeights.tip=Elever les poids
tutti.action.configuration=Configuration
tutti.action.configuration.tip=Configurer Tutti
@@ -106,7 +118,6 @@
tutti.action.newProgram.tip=Créer une nouvelle série de campagne
tutti.action.newProtocol=Nouveau
tutti.action.newProtocol.tip=Créer un nouveau protocole
-tutti.action.ok=Fermer
tutti.action.openDb=Ouvrir
tutti.action.openDb.tip=Ouvrir la base de données détectée par Tutti
tutti.action.reload.actions=Recharger les actions
@@ -159,7 +170,6 @@
tutti.dialog.askCancelEditBeforeLeaving.cancelEditFishingOperation=Le trait modifié n'est pas valide. Voulez-vous annuler les modifications ?
tutti.dialog.askCancelEditBeforeLeaving.title=Modifications non enregistrées mais invalides
tutti.dialog.askSaveBeforeLeaving.createFishingOperation=Le trait n'a pas été créé. Voulez-vous l'enregistrer ?
-tutti.dialog.askSaveBeforeLeaving.message=Vous avez fait des modifications que vous n'avez pas enregistrées. Voulez-vous les enregistrer ?
tutti.dialog.askSaveBeforeLeaving.saveCatchBatch=La capture a été modifiée. Voulez-vous enregistrer les modifications ?
tutti.dialog.askSaveBeforeLeaving.saveCruise=La campagne a été modifiée. Voulez-vous enregistrer les modifications ?
tutti.dialog.askSaveBeforeLeaving.saveFishingOperation=Le trait a été modifié. Voulez-vous enregistrer les modifications ?
@@ -182,8 +192,6 @@
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.connected=Aucune base de données connectée à Tutti.
-tutti.information.no.db.exist=Tutti n'a pas trouvée de base à utiliser, vous pouvez l'installer.
tutti.information.no.db.loaded=Tutti a détecté une base mais elle n'est pas actuellement ouverte.
tutti.label.attachmentEditor.file=Fichier
tutti.label.attachmentEditor.fileComment=Commentaire
@@ -194,8 +202,6 @@
tutti.label.catches.benthosTotalWeight=Poids TOTAL (kg)
tutti.label.catches.catchThalassa=(*) uniquement sur Thalassa
tutti.label.catches.catchTotalRejectedWeight=Poids total NON TRIÉ (kg)
-tutti.label.catches.catchTotalSortedCarousselWeight=Caroussel Observé (*)
-tutti.label.catches.catchTotalSortedTremisWeight=Tremie (*)
tutti.label.catches.catchTotalSortedWeight=Poids total VRAC (kg)
tutti.label.catches.catchTotalUnsortedWeight=Poids total HORS VRAC (kg)
tutti.label.catches.catchTotalWeight=Poids TOTAL (kg)
@@ -327,8 +333,6 @@
tutti.menu.file.tip=Fichier
tutti.menu.help=Aide
tutti.menu.help.tip=Aide
-tutti.menu.referential=Référentiels
-tutti.menu.referential.tip=Gestion des référentiels
tutti.menu.synchronisationAllegro=Allégro
tutti.menu.synchronisationAllegro.tip=Synchronisation Allégro
tutti.menu.synchronisationExport=Export
1
0
r429 - 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/util/action resources/i18n
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 19:55:19 +0100 (Fri, 15 Feb 2013)
New Revision: 429
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/429
Log:
improve db actions + load db after ui is visible to use action api + improve db update behaviour
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/RunTutti.java
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/TuttiUIContext.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/DbManagerUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.jaxx
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/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/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2013-02-15 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2013-02-15 18:55:19 UTC (rev 429)
@@ -32,6 +32,7 @@
import fr.ifremer.tutti.ui.swing.config.TuttiConfigUI;
import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUI;
import fr.ifremer.tutti.ui.swing.content.db.DbManagerUI;
+import fr.ifremer.tutti.ui.swing.content.db.OpenDbAction;
import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.content.program.EditProgramUI;
@@ -124,17 +125,20 @@
JToolBar bar = ui.getBottomBar();
ui.getStatus().addWidget(bar, 0);
- TuttiScreen screen;
+ if (!context.isDbExist()) {
- if (context.isDbExist() && context.isDbLoaded()) {
+ // clean db context
+ context.clearDbContext();
- screen = TuttiScreen.SELECT_CRUISE;
+ // go to manage db screen (to install db)
+ context.setScreen(TuttiScreen.MANAGE_DB);
} else {
- screen = TuttiScreen.MANAGE_DB;
+ // open tutti db
+ OpenDbAction openDbAction = createAction(OpenDbAction.class);
+ openDbAction.setCheckDbContext(true);
+ openDbAction.actionPerformed(null);
}
-
- context.setScreen(screen);
}
@Override
@@ -431,60 +435,67 @@
protected String getSelectedCruiseTitle() {
- String programId = context.getProgramId();
String title;
- if (programId == null) {
+ if (context.isDbLoaded()) {
- // no program selected (so neither cruise)
+ String programId = context.getProgramId();
- title = _("tutti.title.noSelectedProgram");
+ if (programId == null) {
- } else {
+ // no program selected (so neither cruise)
- // selected program
+ title = _("tutti.title.noSelectedProgram");
- Program program = persistenceService.getProgram(programId);
+ } else {
- title = _("tutti.title.selectedProgram", program.getName()) + " / ";
+ // selected program
- String cruiseId = context.getCruiseId();
+ Program program = persistenceService.getProgram(programId);
- if (cruiseId == null) {
+ title = _("tutti.title.selectedProgram", program.getName()) + " / ";
- // no selected cruise
+ String cruiseId = context.getCruiseId();
- title += _("tutti.title.noSelectedCruise");
+ if (cruiseId == null) {
- } else {
+ // no selected cruise
- // selected cruise
- Cruise cruise;
- cruise = persistenceService.getCruise(cruiseId);
+ title += _("tutti.title.noSelectedCruise");
- title += _("tutti.title.selectedCruise", cruise.getName());
- }
+ } else {
- title += " / ";
+ // selected cruise
+ Cruise cruise;
+ cruise = persistenceService.getCruise(cruiseId);
- String protocolId = context.getProtocolId();
+ title += _("tutti.title.selectedCruise", cruise.getName());
+ }
- if (protocolId == null) {
+ title += " / ";
- // no selected protocol
+ String protocolId = context.getProtocolId();
- title += _("tutti.title.noSelectedProtocol");
+ if (protocolId == null) {
- } else {
+ // no selected protocol
- // selected protocol
- TuttiProtocol protocol = persistenceService.getProtocol(protocolId);
+ title += _("tutti.title.noSelectedProtocol");
- title += _("tutti.title.selectedProtocol", protocol.getName());
+ } else {
+
+ // selected protocol
+ TuttiProtocol protocol = persistenceService.getProtocol(protocolId);
+
+ title += _("tutti.title.selectedProtocol", protocol.getName());
+ }
+
}
+ } else {
+ title = _("tutti.title.nodb");
+ }
- }
return title;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-02-15 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-02-15 18:55:19 UTC (rev 429)
@@ -79,7 +79,7 @@
new UpdateApplicationAction(handler).doAction(null);
// try to update db
- new UpdateReferentialAction(handler).doAction(null);
+// new UpdateReferentialAction(handler).doAction(null);
}
// Prepare ui look&feel and load ui properties
@@ -117,7 +117,7 @@
ui.dispose();
if (exit) {
- System.exit(1);
+ System.exit(0);
}
}
}
\ No newline at end of file
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 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-02-15 18:55:19 UTC (rev 429)
@@ -67,6 +67,8 @@
protected ProgressionModel progressionModel;
+ protected boolean dbUpdated;
+
public TuttiApplicationUpdaterCallBack(TuttiUIContext context, ProgressionModel progressionModel) {
this.context = context;
this.progressionModel = progressionModel;
@@ -76,6 +78,10 @@
this.types = Lists.newArrayList(types);
}
+ public boolean isDbUpdated() {
+ return dbUpdated;
+ }
+
@Override
public Map<String, ApplicationUpdater.ApplicationInfo> updateToDo(Map<String, ApplicationUpdater.ApplicationInfo> appToUpdate) {
Map<String, ApplicationUpdater.ApplicationInfo> result = Maps.newHashMap();
@@ -97,8 +103,9 @@
ApplicationUpdater.ApplicationInfo info = getInfo(UpdateType.DB, result);
if (info == null) {
- String message = "Aucune mise à jour de base détectée.";
- context.showInformationMessage(message);
+ dbUpdated=false;
+ } else {
+ dbUpdated=true;
}
}
return result;
@@ -113,7 +120,6 @@
} else {
progressionModel.setMessage("Téléchargement et mise à jour de la base (version " + info.newVersion + ")");
}
-
}
if (UpdateType.JRE.name().toLowerCase().equals(info.name)) {
progressionModel.setMessage("Téléchargement et installation d'une nouvelle JRE (version " + info.newVersion + ")");
@@ -296,6 +302,7 @@
} catch (IOException e) {
throw new RuntimeException("Could not delete temporary directory " + target, e);
}
+
}
protected void synchronizetDatabase(ApplicationUpdater.ApplicationInfo info) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-02-15 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-02-15 18:55:19 UTC (rev 429)
@@ -455,80 +455,6 @@
setProgramId(null);
setCruiseId(null);
setDbLoaded(false);
-
- } else {
-
- setDbLoaded(true);
-
- //check if programId is sane
- PersistenceService service = getService(PersistenceService.class);
-
- if (isProtocolFilled()) {
-
- if (!service.isProtocolExist(protocolId)) {
-
- // not found in this db
-
- if (log.isWarnEnabled()) {
- log.warn("Remove invalid protocolId: " + protocolId);
- }
-
- setProtocolId(null);
- }
- }
-
- if (isProgramFilled()) {
-
- Program program = service.getProgram(programId);
- if (program == null) {
-
- // not found in this db
-
- if (log.isWarnEnabled()) {
- log.warn("Remove invalid programId: " + programId);
- }
-
- setProgramId(null);
- setCruiseId(null);
-
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("ProgramId valid: " + programId);
- }
-
- setProgramId(programId);
-
- // test cruiseId
- if (isCruiseFilled()) {
-
- Cruise cruise = service.getCruise(cruiseId);
-
- if (cruise != null &&
- !cruise.getProgram().getId().equals(programId)) {
-
- // not matchin program, reset cruise id
- cruise = null;
- }
-
- if (cruise == null) {
-
- // not found in this db
-
- if (log.isWarnEnabled()) {
- log.warn("Remove invalid cruiseId: " + cruiseId);
- }
- setCruiseId(null);
-
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("CruiseId valid: " + cruiseId);
- }
- }
- }
- }
- }
}
// save back to config
@@ -576,9 +502,6 @@
// close action ui
actionUI.getModel().setProgressionModel(null);
actionUI.getModel().setAction(null);
-
-// // hide it
-// actionUI.setVisible(false);
}
setActionUI(null);
}
@@ -624,4 +547,86 @@
public TuttiActionUI getActionUI() {
return actionUI;
}
+
+ public void clearDbContext() {
+ protocolId = null;
+ programId = null;
+ cruiseId = null;
+ saveContextToConfig();
+ }
+
+ public void checkDbContext() {
+
+ //check if programId is sane
+ PersistenceService service = getService(PersistenceService.class);
+
+ if (isProtocolFilled()) {
+
+ if (!service.isProtocolExist(protocolId)) {
+
+ // not found in this db
+
+ if (log.isWarnEnabled()) {
+ log.warn("Remove invalid protocolId: " + protocolId);
+ }
+
+ setProtocolId(null);
+ }
+ }
+
+ if (isProgramFilled()) {
+
+ Program program = service.getProgram(programId);
+ if (program == null) {
+
+ // not found in this db
+
+ if (log.isWarnEnabled()) {
+ log.warn("Remove invalid programId: " + programId);
+ }
+
+ setProgramId(null);
+ setCruiseId(null);
+
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("ProgramId valid: " + programId);
+ }
+
+ setProgramId(programId);
+
+ // test cruiseId
+ if (isCruiseFilled()) {
+
+ Cruise cruise = service.getCruise(cruiseId);
+
+ if (cruise != null &&
+ !cruise.getProgram().getId().equals(programId)) {
+
+ // not matchin program, reset cruise id
+ cruise = null;
+ }
+
+ if (cruise == null) {
+
+ // not found in this db
+
+ if (log.isWarnEnabled()) {
+ log.warn("Remove invalid cruiseId: " + cruiseId);
+ }
+ setCruiseId(null);
+
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("CruiseId valid: " + cruiseId);
+ }
+ }
+ }
+ }
+ }
+
+ saveContextToConfig();
+ }
}
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-15 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/UpdateReferentialAction.java 2013-02-15 18:55:19 UTC (rev 429)
@@ -82,11 +82,18 @@
false,
callback);
- progressionModel.setMessage("Rechargement de la base de données");
+ if (callback.isDbUpdated()) {
- getContext().setDbLoaded(true);
- getHandler().reloadPersistenceService();
+ progressionModel.setMessage("Rechargement de la base de données");
+ getContext().setDbLoaded(true);
+ getHandler().reloadPersistenceService();
+
+
+ } else {
+ sendMessage("Aucune mise à jour de base détectée.");
+ }
+
getContext().getActionUI().getModel().setProgressionModel(null);
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css 2013-02-15 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css 2013-02-15 18:55:19 UTC (rev 429)
@@ -27,28 +27,34 @@
horizontalAlignment: {JLabel.CENTER};
}
+#noDbActions {
+ visible: {!model.isDbExist()};
+}
+
#installDbButton {
- enabled: {!model.isDbExist()};
_tuttiAction: {InstallDbAction.class};
}
+#withDbActions {
+ visible: {model.isDbExist()};
+}
+
#openDbButton {
- enabled: {model.isDbExist() && !model.isDbLoaded()};
+ enabled: {!model.isDbLoaded()};
_tuttiAction: {OpenDbAction.class};
}
#upgradeDbButton {
- enabled: {model.isDbExist() && model.isDbLoaded()};
+ enabled: {model.isDbLoaded()};
_tuttiAction: {UpdateReferentialAction.class};
}
#closeDbButton {
- enabled: {model.isDbExist() && model.isDbLoaded()};
+ enabled: {model.isDbLoaded()};
_tuttiAction: {CloseDbAction.class};
}
#exportDbButton {
- enabled: false;
- /*enabled: {model.isDbExist() && model.isDbLoaded()};*/
+ enabled: {model.isDbLoaded()};
_tuttiAction: {ExportDbAction.class};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.jaxx 2013-02-15 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.jaxx 2013-02-15 18:55:19 UTC (rev 429)
@@ -53,11 +53,15 @@
<TuttiUIContext id='model'
initializer='getContextValue(TuttiUIContext.class)'/>
+ <JLabel id='informationLabel' constraints='BorderLayout.CENTER'/>
<JPanel id='centerPanel' layout='{new BorderLayout()}'
- constraints='BorderLayout.CENTER'>
- <JLabel id='informationLabel' constraints='BorderLayout.CENTER'/>
- <JPanel constraints='BorderLayout.SOUTH' layout='{new GridLayout(0, 1)}'>
+ constraints='BorderLayout.SOUTH'>
+ <JPanel id='noDbActions' constraints='BorderLayout.CENTER'
+ layout='{new GridLayout(0, 1)}'>
<JButton id='installDbButton'/>
+ </JPanel>
+ <JPanel id='withDbActions' constraints='BorderLayout.SOUTH'
+ layout='{new GridLayout(0, 1)}'>
<JButton id='openDbButton'/>
<JButton id='upgradeDbButton'/>
<JButton id='exportDbButton'/>
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 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java 2013-02-15 18:55:19 UTC (rev 429)
@@ -31,8 +31,6 @@
import org.apache.commons.logging.LogFactory;
import javax.swing.SwingUtilities;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import static org.nuiton.i18n.I18n._;
@@ -52,15 +50,6 @@
@Override
public void beforeInitUI() {
- context.addPropertyChangeListener(new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- String propertyName = evt.getPropertyName();
- String message;
-
-
- }
- });
}
public String updateMessage(boolean dbExist, boolean dbLoaded) {
@@ -91,16 +80,15 @@
initUI(ui);
- ui.applyDataBinding(DbManagerUI.BINDING_INSTALL_DB_BUTTON_ENABLED);
ui.applyDataBinding(DbManagerUI.BINDING_OPEN_DB_BUTTON_ENABLED);
- ui.applyDataBinding(DbManagerUI.BINDING_CLOSE_DB_BUTTON_ENABLED);
ui.applyDataBinding(DbManagerUI.BINDING_UPGRADE_DB_BUTTON_ENABLED);
+ ui.applyDataBinding(DbManagerUI.BINDING_EXPORT_DB_BUTTON_ENABLED);
SwingUtilities.invokeLater(
new Runnable() {
@Override
public void run() {
- ui.repaint();
+ getContext().getMainUI().getBody().revalidate();
}
}
);
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-15 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-02-15 18:55:19 UTC (rev 429)
@@ -46,9 +46,15 @@
private static final long serialVersionUID = 1L;
/** Logger. */
- private static final Log log =
- LogFactory.getLog(OpenDbAction.class);
+ 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",
@@ -61,6 +67,9 @@
@Override
protected void doAction(ActionEvent event) {
+ if (log.isDebugEnabled()) {
+ log.debug("Will open db...");
+ }
getContext().setDbLoaded(true);
getHandler().reloadPersistenceService();
@@ -68,6 +77,23 @@
sendMessage(String.format("La base de données '%s' est ouverte.", jdbcUrl));
+ if (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/util/action/TuttiActionUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionUIHandler.java 2013-02-15 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionUIHandler.java 2013-02-15 18:55:19 UTC (rev 429)
@@ -27,6 +27,7 @@
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
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;
@@ -120,7 +121,10 @@
// starting action
if (ui.getOwner() != null) {
- SwingUtil.center(ui.getOwner(), ui);
+ MainUI mainUI = getContext().getMainUI();
+ if (mainUI != null) {
+ SwingUtil.center(mainUI, ui);
+ }
}
// new action
ui.getGlobalActionLabel().setText(_("tutti.message.action.running", action.getActionDescription()));
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 18:24:40 UTC (rev 428)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-15 18:55:19 UTC (rev 429)
@@ -27,7 +27,7 @@
tutti.action.cloneProtocol=Cloner
tutti.action.cloneProtocol.tip=Dupliquer le protocole sélectionné
tutti.action.close=Fermer
-tutti.action.closeDb=Fermer la base
+tutti.action.closeDb=Fermer
tutti.action.closeDb.tip=Fermer la base de données en cours d'utilisation
tutti.action.computeWeights=Elever les poids
tutti.action.computeWeights.tip=Elever les poids
@@ -57,7 +57,7 @@
tutti.action.exit.tip=Quitter l'application
tutti.action.exportAllCaracteristic=Exporter toutes les caractéristiques
tutti.action.exportAllCaracteristic.tip=Exporter toutes les caractéristiques (sans les affecter à un écran)
-tutti.action.exportDb=Exporter la base
+tutti.action.exportDb=Exporter
tutti.action.exportDb.tip=Exporter la base de données au format zip
tutti.action.exportProtocol=Exporter
tutti.action.exportProtocol.tip=Exporter le protocole sélectionné
@@ -95,7 +95,7 @@
tutti.action.importTemporarySpecies.tip=Importer un référentiel temporaire d'espèces
tutti.action.importTemporaryVessel=Importer
tutti.action.importTemporaryVessel.tip=Importer un référentiel temporaire de navires
-tutti.action.installDb=Installer la base
+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.tip=Gérer la base de données utilisée par Tutti
@@ -107,7 +107,7 @@
tutti.action.newProtocol=Nouveau
tutti.action.newProtocol.tip=Créer un nouveau protocole
tutti.action.ok=Fermer
-tutti.action.openDb=Ouvrir la base
+tutti.action.openDb=Ouvrir
tutti.action.openDb.tip=Ouvrir la base de données détectée par Tutti
tutti.action.reload.actions=Recharger les actions
tutti.action.reload.application=Recharger l'application
@@ -139,9 +139,9 @@
tutti.action.site.tip=Accéder au site du projet Tutti
tutti.action.splitSpeciesBatch=Catégoriser le lot
tutti.action.splitSpeciesBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné)
-tutti.action.updateApplication=Mise à jour
-tutti.action.updateApplication.tip=Mettre à jour l'application si nécessaire
-tutti.action.updateReferential=Mise à jour
+tutti.action.updateApplication=Vérifier les mises à jour
+tutti.action.updateApplication.tip=Vérifier les mises à jour logicielles
+tutti.action.updateReferential=Vérifier les mises à jour
tutti.action.updateReferential.tip=Mettre à jour les référentiels si nécessaire
tutti.action.validate=Valider
tutti.action.validateCatches=Valider les captures
@@ -463,6 +463,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.selectSpecies=Choisissez une espèce
tutti.title.selectedCruise=Campagne %s
tutti.title.selectedProgram=Série de campagne %s
1
0
r428 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor
by kmorin@users.forge.codelutin.com 15 Feb '13
by kmorin@users.forge.codelutin.com 15 Feb '13
15 Feb '13
Author: kmorin
Date: 2013-02-15 19:24:40 +0100 (Fri, 15 Feb 2013)
New Revision: 428
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/428
Log:
refs #2003 [CAPTURE] ?\195?\137l?\195?\169vation des poids
remains error cases to treat
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.java
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.java 2013-02-15 18:24:13 UTC (rev 427)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.java 2013-02-15 18:24:40 UTC (rev 428)
@@ -1,10 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.util.editor;
-
-/**
- *
- * @author kmorin <kmorin(a)codelutin.com>
- */
-public class TuttiComputedOrNotDataEditor {
-
-}
1
0
15 Feb '13
Author: kmorin
Date: 2013-02-15 19:24:13 +0100 (Fri, 15 Feb 2013)
New Revision: 427
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/427
Log:
refs #2003 [CAPTURE] ?\195?\137l?\195?\169vation des poids
remains error cases to treat
Added:
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/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/TuttiApplicationUpdaterCallBack.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/catches/ComputeWeightsAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
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/SpeciesBatchUI.css
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/content/operation/catches/species/split/CreateSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.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/editor/TuttiComputedOrNotDataEditor.java
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-edit-warning-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-warning-validation.xml
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/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-02-15 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -34,6 +34,7 @@
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;
@@ -67,6 +68,7 @@
import javax.swing.text.JTextComponent;
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
@@ -80,6 +82,9 @@
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._;
@@ -288,10 +293,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");
@@ -307,6 +315,18 @@
}
jLabel.setText("<html>" + text + "</html>");
}
+
+ } else if (component instanceof JTextField) {
+ JTextField jTextField = (JTextField) component;
+ Boolean computed = (Boolean) jTextField.getClientProperty("computed");
+ if (computed != null && computed) {
+ Font font = jTextField.getFont().deriveFont(Font.ITALIC);
+ jTextField.setFont(font);
+ jTextField.setEditable(!computed);
+ 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");
@@ -551,9 +571,7 @@
protected void listModelIsModify(AbstractTuttiBeanUIModel model) {
model.addPropertyChangeListener(new PropertyChangeListener() {
- final Set<String> excludeProperties = Sets.newHashSet(
- AbstractTuttiBeanUIModel.PROPERTY_MODIFY,
- AbstractTuttiBeanUIModel.PROPERTY_VALID);
+ final Set<String> excludeProperties = getPropertiesToIgnore();
@Override
public void propertyChange(PropertyChangeEvent evt) {
@@ -563,6 +581,12 @@
}
});
}
+
+ protected Set<String> getPropertiesToIgnore() {
+ return Sets.newHashSet(
+ AbstractTuttiBeanUIModel.PROPERTY_MODIFY,
+ AbstractTuttiBeanUIModel.PROPERTY_VALID);
+ }
public <B> void selectFirstInCombo(BeanComboBox<B> combo) {
List<B> data = combo.getData();
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -104,7 +104,6 @@
return result;
}
- @Override
public void startUpdate(ApplicationUpdater.ApplicationInfo info) {
if (UpdateType.DB.name().toLowerCase().equals(info.name)) {
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUI.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -24,6 +24,8 @@
* #L%
*/
+import java.awt.Font;
+import javax.swing.UIManager;
import jaxx.runtime.JAXXObject;
/**
@@ -100,7 +102,7 @@
*
* @since 0.1
*/
- public static final String DECIMAL1_PATTERN = "\\d{0,6}|\\d{1,6}.\\d{0,1}";
+ public static final String DECIMAL1_PATTERN = "\\d{0,6}|\\d{1,6}\\.\\d{0,1}";
/**
* Pattern to use for decimal numeric values with 2 decimal digits in
@@ -108,7 +110,7 @@
*
* @since 0.1
*/
- public static final String DECIMAL2_PATTERN = "\\d{0,6}|\\d{1,6}.\\d{0,2}";
+ public static final String DECIMAL2_PATTERN = "\\d{0,6}|\\d{1,6}\\.\\d{0,2}";
/**
* Pattern to use for decimal numeric values with 3 decimal digits in
@@ -116,17 +118,9 @@
*
* @since 0.1
*/
- public static final String DECIMAL3_PATTERN = "\\d{0,6}|\\d{1,6}.\\d{0,3}";
+ public static final String DECIMAL3_PATTERN = "\\d{0,6}|\\d{1,6}\\.\\d{0,3}";
/**
- * Pattern to use for decimal numeric values with 3 decimal digits in
- * editors.
- *
- * @since 0.1
- */
- public static final String DECIMALFORCE3_PATTERN = "\\d{0,6}|\\d{1,6}.\\d{3}";
-
- /**
* Pattern to use for decimal numeric values with 2 digits + 3 decimal digits in
* editors.
*
@@ -134,4 +128,7 @@
*/
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/catches/ComputeWeightsAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-02-15 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -25,6 +25,7 @@
* #L%
*/
+import com.google.common.collect.Maps;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
@@ -33,8 +34,13 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
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 static org.nuiton.i18n.I18n._;
@@ -46,6 +52,12 @@
public class ComputeWeightsAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
private static final long serialVersionUID = 1L;
+
+ private static final Log log = LogFactory.getLog(ComputeWeightsAction.class);
+
+ protected enum Weights {
+ UNSORTED, SAMPLE_SORTED, SORTED, TOTAL
+ }
public ComputeWeightsAction(EditCatchesUIHandler handler) {
super(handler,
@@ -58,27 +70,61 @@
@Override
protected void doAction(ActionEvent event) throws Exception {
- computeSpeciesBatches();
+ Map<Weights, Float> speciesWeights = computeSpeciesBatches();
+
+ EditCatchesUI ui = getUI();
+ setComputedValue(ui.getCatchTotalUnsortedWeightField(),
+ speciesWeights.get(Weights.UNSORTED));
+ setComputedValue(ui.getCatchTotalSortedWeightField(),
+ speciesWeights.get(Weights.SORTED));
+
+ EditCatchesUIModel model = getModel();
+ Float totalWeight = model.getCatchTotalWeight();
+ Float rejectedWeight = model.getCatchTotalRejectedWeight();
+
+ if (rejectedWeight == null && totalWeight != null) {
+ model.setCatchTotalRejectedComputedWeight(totalWeight
+ - speciesWeights.get(Weights.UNSORTED)
+ - speciesWeights.get(Weights.SORTED));
+
+ } else if (totalWeight == null) {
+ if (rejectedWeight == null) {
+ 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)) {
+ // TODO handle error
+ }
+
}
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
- protected void computeSpeciesBatches() {
+ 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 ui = getUI().getSpeciesTabContent();
+ SpeciesBatchUI speciesUI = getUI().getSpeciesTabContent();
+ EditCatchesUI ui = getUI();
+
List<SpeciesBatchRowModel> roots = getUI().getSpeciesTabContent().getModel().getRows();
for (SpeciesBatchRowModel row : roots) {
if (row.isBatchRoot()) {
Float weight = computeSpeciesBatch(row);
if (weight == null) {
JOptionPane.showMessageDialog(
- ui,
+ speciesUI,
_("tutti.dialog.catches.species.computeWeight.error.message"),
_("tutti.dialog.catches.species.computeWeight.error.title"),
JOptionPane.ERROR_MESSAGE);
@@ -93,43 +139,57 @@
}
}
}
- Number inertWeight = ui.getSpeciesTotalInertWeightField().getModel();
+ Number inertWeight = speciesUI.getSpeciesTotalInertWeightField().getModel();
if (inertWeight != null) {
totalSortedWeight += inertWeight.floatValue();
}
- Number livingNotItemizedWeight = ui.getSpeciesTotalLivingNotItemizedWeightField().getModel();
+ Number livingNotItemizedWeight = speciesUI.getSpeciesTotalLivingNotItemizedWeightField().getModel();
if (livingNotItemizedWeight != null) {
totalSortedWeight += livingNotItemizedWeight.floatValue();
}
- ui.getSpeciesTotalSampleSortedWeightField()
- .setText(totalSortedWeight != null ? totalSortedWeight.toString() : "");
+ setComputedValue(speciesUI.getSpeciesTotalSampleSortedWeightField(),
+ totalSortedWeight);
+ setComputedValue(ui.getSpeciesTotalSampleSortedWeightField(),
+ totalSortedWeight);
+ result.put(Weights.SAMPLE_SORTED, totalSortedWeight);
- if (ui.getSpeciesTotalSortedWeightField().getModel() == null) {
- ui.getSpeciesTotalSortedWeightField().setModel(totalSortedWeight);
+ Float speciesTotalSortedWeight = model.getSpeciesTotalSortedWeight();
+ if (speciesTotalSortedWeight == null) {
+ speciesTotalSortedWeight = totalSortedWeight;
+ model.setSpeciesTotalSortedComputedWeight(totalSortedWeight);
+
+ } else if (speciesTotalSortedWeight < totalSortedWeight) {
+ // TODO handle error
+ } 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)
+ // du "Poids total Vrac trié", demander confirmation que
+ // le "Poids total VRAC" est bien une valeur observée
+ // sinon la remplacer par le "Poids total Vrac trié"
}
+ result.put(Weights.SORTED, speciesTotalSortedWeight);
- ui.getSpeciesTotalUnsortedWeightField()
- .setText(totalUnsortedWeight != null ? totalUnsortedWeight.toString() : "");
+ setComputedValue(speciesUI.getSpeciesTotalUnsortedWeightField(),
+ totalUnsortedWeight);
+ setComputedValue(ui.getSpeciesTotalUnsortedWeightField(),
+ totalUnsortedWeight);
+ result.put(Weights.UNSORTED, totalUnsortedWeight);
+
+ Float totalWeight = totalUnsortedWeight + speciesTotalSortedWeight;
+ setComputedValue(speciesUI.getSpeciesTotalWeightField(),
+ totalWeight);
+ setComputedValue(ui.getSpeciesTotalWeightField(),
+ totalWeight);
+ result.put(Weights.TOTAL, speciesTotalSortedWeight);
+
+ speciesUI.getTable().repaint();
+
+ return result;
}
protected Float computeSpeciesBatch(SpeciesBatchRowModel row) {
- SampleCategory finestCategory;
- if (row.getAgeCategory().isValid()) {
- finestCategory = row.getAgeCategory();
-
- } else if (row.getMaturityCategory().isValid()) {
- finestCategory = row.getMaturityCategory();
-
- } else if (row.getSexCategory().isValid()) {
- finestCategory = row.getSexCategory();
-
- } else if (row.getSizeCategory().isValid()) {
- finestCategory = row.getSizeCategory();
-
- } else {
- finestCategory = row.getSortedUnsortedCategory();
- }
+ SampleCategory finestCategory = row.getFinestCategory();
Float result = null;
Float categoryWeight = finestCategory.getCategoryWeight();
@@ -152,15 +212,27 @@
if (sum != null) {
if (categoryWeight == null) {
finestCategory.setComputedWeight(sum);
- } else if (categoryWeight != sum) {
+ for (SpeciesBatchRowModel child : children) {
+ child.getFinestCategory().setSubSample(false);
+ }
+
+ } else if (categoryWeight < sum) {
// handle error
+
+ } else {
+ boolean subSample = categoryWeight > sum;
+ for (SpeciesBatchRowModel child : children) {
+ child.getFinestCategory().setSubSample(subSample);
+ }
}
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;
@@ -178,7 +250,7 @@
frequencyWeight += w;
}
}
-
+
if (categoryWeight == null && rowWeight != null) {
//TODO handle error
@@ -188,18 +260,22 @@
finestCategory.setComputedWeight(frequencyWeight);
result = frequencyWeight;
- } else if (frequencyWeight != null && frequencyWeight != 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 (rowWeight == null) {
+ if (categoryWeight != null && frequencyWeight > categoryWeight) {
+ //TODO handle error
+
+ } else if (rowWeight == null) {
row.setComputedWeight(frequencyWeight);
- } else if (rowWeight != frequencyWeight) {
+ } else if (!rowWeight.equals(frequencyWeight)) {
//TODO handle error
}
result = categoryWeight;
-
} else {
result = categoryWeight;
}
@@ -211,4 +287,14 @@
return result;
}
+
+ protected void setComputedValue(JTextField textField, Float value) {
+ String textValue;
+ if (value != null) {
+ textValue = String.format("%.3f", value);
+ } else {
+ textValue = JAXXUtil.getStringValue(value);
+ }
+ textField.setText(textValue);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-02-15 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-02-15 18:24:13 UTC (rev 427)
@@ -27,8 +27,19 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
bean: {model};
showReset: true;
+ useFloat: true;
+ numberPattern: {DECIMAL3_PATTERN};
}
+TuttiComputedOrNotDataEditor {
+ autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
+ showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+ showReset: true;
+ useFloat: true;
+ numberPattern: {DECIMAL3_PATTERN};
+ decimalNumber: 3;
+}
+
#catchTable {
border: {BorderFactory.createTitledBorder(_("tutti.legend.catch.total"))};
}
@@ -40,16 +51,19 @@
}
#catchTotalWeightField {
- property: catchTotalWeight;
+ bean: {model.getCatchTotalComputedOrNotWeight()};
model: {model.getCatchTotalWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
}
#catchTotalSortedWeightLabel {
text: "tutti.label.catches.catchTotalSortedWeight";
+ labelFor: {catchTotalSortedWeightField};
}
+#catchTotalSortedWeightField {
+ _computed: true;
+}
+
#catchTotalSortedTremisWeightLabel {
text: "tutti.label.catches.catchTotalSortedTremisWeight";
labelFor: {catchTotalSortedTremisWeightField};
@@ -58,8 +72,6 @@
#catchTotalSortedTremisWeightField {
property: catchTotalSortedTremisWeight;
model: {model.getCatchTotalSortedTremisWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
}
#catchTotalSortedCarousselWeightLabel {
@@ -70,8 +82,6 @@
#catchTotalSortedCarousselWeightField {
property: catchTotalSortedCarousselWeight;
model: {model.getCatchTotalSortedCarousselWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
}
#catchTotalRejectedWeightLabel {
@@ -80,10 +90,8 @@
}
#catchTotalRejectedWeightField {
- property: catchTotalRejectedWeight;
+ bean: {model.getCatchTotalRejectedComputedOrNotWeight()};
model: {model.getCatchTotalRejectedWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
}
#catchTotalUnsortedWeightLabel {
@@ -92,9 +100,7 @@
}
#catchTotalUnsortedWeightField {
- editable: false;
- enabled: false;
- text: {getStringValue(model.getCatchTotalUnsortedWeight())};
+ _computed: true;
}
#catchThalassaLabel {
@@ -117,10 +123,7 @@
}
#speciesTotalWeightField {
- property: speciesTotalWeight;
- model: {model.getSpeciesTotalWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
+ _computed: true;
}
#speciesTotalSortedWeightLabel {
@@ -129,10 +132,12 @@
}
#speciesTotalSortedWeightField {
- property: speciesTotalSortedWeight;
- model: {model.getSpeciesTotalSortedWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
+ text: {getStringValue(model.getSpeciesTotalSortedWeight() != null ?
+ String.format("%.3f", model.getSpeciesTotalSortedWeight()) :
+ model.getSpeciesTotalSortedComputedWeight() != null ?
+ String.format("%.3f", model.getSpeciesTotalSortedComputedWeight()) :
+ null)};
+ _computed: true;
}
#speciesTotalSampleSortedWeightLabel {
@@ -142,10 +147,7 @@
}
#speciesTotalSampleSortedWeightField {
- property: speciesTotalSampleSortedWeight;
- model: {model.getSpeciesTotalSampleSortedWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
+ _computed: true;
}
#speciesTotalUnsortedWeightLabel {
@@ -154,9 +156,7 @@
}
#speciesTotalUnsortedWeightField {
- text: {getStringValue(model.getSpeciesTotalUnsortedWeight())};
- editable: false;
- enabled: false;
+ _computed: true;
}
#benthosTable {
@@ -170,10 +170,7 @@
}
#benthosTotalWeightField {
- property: benthosTotalWeight;
- model: {model.getBenthosTotalWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
+ _computed: true;
}
#benthosTotalSortedWeightLabel {
@@ -182,10 +179,7 @@
}
#benthosTotalSortedWeightField {
- property: benthosTotalSortedWeight;
- model: {model.getBenthosTotalSortedWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
+ _computed: true;
}
#benthosTotalSampleSortedWeightLabel {
@@ -195,10 +189,7 @@
}
#benthosTotalSampleSortedWeightField {
- property: benthosTotalSampleSortedWeight;
- model: {model.getBenthosTotalSampleSortedWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
+ _computed: true;
}
#benthosTotalUnsortedWeightLabel {
@@ -207,9 +198,7 @@
}
#benthosTotalUnsortedWeightField {
- text: {getStringValue(model.getBenthosTotalUnsortedWeight())};
- editable: false;
- enabled: false;
+ _computed: true;
}
#macroWasteTable {
@@ -223,10 +212,7 @@
}
#macroWasteTotalWeightField {
- property: macroWasteTotalWeight;
- model: {model.getMacroWasteTotalWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
+ _computed: true;
}
#importPupitriButton {
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-02-15 18:24:13 UTC (rev 427)
@@ -36,6 +36,8 @@
fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI
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
@@ -71,19 +73,15 @@
<BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
<field name='catchTotalWeight' component='catchTotalWeightField'/>
- <field name='catchTotalSortedTremisWeight'
+<!-- <field name='catchTotalSortedTremisWeight'
component='catchTotalSortedTremisWeightField'/>
<field name='catchTotalSortedCarousselWeight'
- component='catchTotalSortedCarousselWeightField'/>
+ component='catchTotalSortedCarousselWeightField'/>-->
<field name='catchTotalRejectedWeight'
component='catchTotalRejectedWeightField'/>
<field name='speciesTotalSortedWeight'
component='speciesTotalSortedWeightField'/>
- <field name='speciesTotalSampleSortedWeight'
- component='speciesTotalSampleSortedWeightField'/>
- <field name='speciesTotalUnsortedWeight'
- component='speciesTotalUnsortedWeightField'/>
<field name='benthosTotalSortedWeight'
component='benthosTotalSortedWeightField'/>
@@ -115,17 +113,20 @@
<cell anchor='west'>
<JLabel id='catchTotalWeightLabel'/>
</cell>
- <cell columns='4'>
- <NumberEditor id='catchTotalWeightField'
+ <cell columns='4' weightx='1.0'>
+ <TuttiComputedOrNotDataEditor id='catchTotalWeightField'
constructorParams='this'/>
</cell>
</row>
- <!-- Poids total trié balance tremis / caroussel-->
+ <!-- Poids total trié balance tremie / caroussel-->
<row>
<cell anchor='west'>
<JLabel id='catchTotalSortedWeightLabel'/>
</cell>
- <cell anchor='west'>
+ <cell columns='4' weightx='1.0'>
+ <JTextField id='catchTotalSortedWeightField'/>
+ </cell>
+<!-- <cell anchor='west'>
<JLabel id='catchTotalSortedCarousselWeightLabel'/>
</cell>
<cell weightx='1.0'>
@@ -138,14 +139,14 @@
<cell weightx='1.0'>
<NumberEditor id='catchTotalSortedTremisWeightField'
constructorParams='this'/>
- </cell>
+ </cell>-->
</row>
<!--Poids total hors vrac-->
<row>
<cell>
<JLabel id='catchTotalUnsortedWeightLabel'/>
</cell>
- <cell columns='4'>
+ <cell columns='4' weightx='1.0'>
<JTextField id='catchTotalUnsortedWeightField'/>
</cell>
</row>
@@ -154,8 +155,8 @@
<cell>
<JLabel id='catchTotalRejectedWeightLabel'/>
</cell>
- <cell columns='4'>
- <NumberEditor id='catchTotalRejectedWeightField'
+ <cell columns='4' weightx='1.0'>
+ <TuttiComputedOrNotDataEditor id='catchTotalRejectedWeightField'
constructorParams='this'/>
</cell>
</row>
@@ -177,8 +178,7 @@
<JLabel id='speciesTotalWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <NumberEditor id='speciesTotalWeightField'
- constructorParams='this'/>
+ <JTextField id='speciesTotalWeightField'/>
</cell>
</row>
<!-- Poids total vrac -->
@@ -187,8 +187,7 @@
<JLabel id='speciesTotalSortedWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <NumberEditor id='speciesTotalSortedWeightField'
- constructorParams='this'/>
+ <JTextField id='speciesTotalSortedWeightField'/>
</cell>
</row>
@@ -198,8 +197,7 @@
<JLabel id='speciesTotalSampleSortedWeightLabel'/>
</cell>
<cell>
- <NumberEditor id='speciesTotalSampleSortedWeightField'
- constructorParams='this'/>
+ <JTextField id='speciesTotalSampleSortedWeightField'/>
</cell>
</row>
<!-- Poids total hors vrac -->
@@ -223,8 +221,7 @@
<JLabel id='benthosTotalWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <NumberEditor id='benthosTotalWeightField'
- constructorParams='this'/>
+ <JTextField id='benthosTotalWeightField'/>
</cell>
</row>
<!-- Poids total vrac -->
@@ -233,8 +230,7 @@
<JLabel id='benthosTotalSortedWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <NumberEditor id='benthosTotalSortedWeightField'
- constructorParams='this'/>
+ <JTextField id='benthosTotalSortedWeightField'/>
</cell>
</row>
@@ -244,8 +240,7 @@
<JLabel id='benthosTotalSampleSortedWeightLabel'/>
</cell>
<cell>
- <NumberEditor id='benthosTotalSampleSortedWeightField'
- constructorParams='this'/>
+ <JTextField id='benthosTotalSampleSortedWeightField'/>
</cell>
</row>
<!-- Poids total hors vrac -->
@@ -270,8 +265,7 @@
<JLabel id='macroWasteTotalWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <NumberEditor id='macroWasteTotalWeightField'
- constructorParams='this'/>
+ <JTextField id='macroWasteTotalWeightField'/>
</cell>
</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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -24,6 +24,7 @@
* #L%
*/
+import com.google.common.collect.Sets;
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIHandler;
@@ -40,6 +41,7 @@
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import java.awt.event.ActionEvent;
+import java.util.Set;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
@@ -82,17 +84,8 @@
public EditCatchesUIHandler(FishingOperationsUI parentUi, EditCatchesUI ui) {
super(parentUi.getHandler().getContext(), ui);
this.parentUi = parentUi;
-// this.persistenceService = context.getService(PersistenceService.class);
this.catchBatchMonitor = new TuttiBeanMonitor<EditCatchesUIModel>(
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_WEIGHT,
- EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_PLANKTON_TOTAL_WEIGHT,
- EditCatchesUIModel.PROPERTY_PLANKTON_TOTAL_SAMPLE_WEIGHT,
- EditCatchesUIModel.PROPERTY_MACRO_WASTE_TOTAL_WEIGHT);
+ EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT);
}
//------------------------------------------------------------------------//
@@ -141,6 +134,16 @@
return ui.getValidator();
}
+ @Override
+ protected Set<String> getPropertiesToIgnore() {
+ Set<String> result = super.getPropertiesToIgnore();
+ result.addAll(Sets.newHashSet(
+ EditCatchesUIModel.PROPERTY_CATCH_TOTAL_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_COMPUTED_WEIGHT
+ ));
+ return result;
+ }
@Override
protected JTabbedPane getTabPanel() {
@@ -234,109 +237,6 @@
return getParentUi().getHandler();
}
- // public void selectFishingOperation(FishingOperation bean,
-// String fishingOperationText) {
-//
-// boolean empty = bean == null;
-// Preconditions.checkState(!empty, "can not edit a null fishing operation.");
-// boolean newOperation = TuttiEntities.isNew(bean);
-// boolean wasModified = fishingOperationMonitor.wasModified();
-//
-// // 1) Save any modification of the current fishingOperation
-//
-// if (wasModified) {
-// save();
-// }
-//
-// ui.getSpeciesTabContent().getHandler().clearTableSelection();
-//// ui.getBenthosTabContent().getHandler().clearTableSelection();
-//// ui.getPlanktonTabContent().getHandler().clearTableSelection();
-//// ui.getMacroWasteTabContent().getHandler().clearTableSelection();
-//// ui.getAccidentalTabContent().getHandler().clearTableSelection();
-//
-// // 2) Use new selected fishingOperation
-//
-// EditCatchesUIModel catchesUIModel = getModel();
-//
-// boolean otherOperation =
-// ObjectUtils.notEqual(bean, catchesUIModel.getFishingOperation());
-//
-// if (empty || newOperation || otherOperation || wasModified) {
-//
-// CatchBatch batch;
-//
-// if (empty || newOperation) {
-//
-// // create a new CatchBatch
-// if (log.isInfoEnabled()) {
-// log.info("Create a new CatchBatch");
-// }
-// batch = new CatchBatch();
-// batch.setFishingOperation(bean);
-//
-// } else {
-//
-// String operationId = bean.getId();
-//
-// if (log.isInfoEnabled()) {
-// log.info("Load existing CatchBatch from operation id: " +
-// operationId);
-// }
-//
-// batch = persistenceService.getCatchBatchFromFishingOperation(
-// operationId);
-//
-//// model.setCatchBatch(batch);
-//// model.setFishingOperation(bean);
-// }
-//
-// catchesUIModel.setCatchBatch(batch);
-// catchesUIModel.setFishingOperation(bean);
-//
-// catchesUIModel.fromBean(batch);
-//
-// catchesUIModel.setModify(false);
-// fishingOperationMonitor.clearModified();
-//
-// // 3) Propagate title to others tabs
-// ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
-// ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-//// ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-//// ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-//// ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-//// ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-//
-// // 4) Propagate new selected fishingoperation to others tabs
-//
-// ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
-//// ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
-//// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
-//// ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
-//// ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
-//
-// ui.getTabPane().repaint();
-// }
-// }
-
-// public void save() {
-//
-// // previous fishingOperation was modified, let's save it
-// EditCatchesUIModel beanToSave = catchBatchMonitor.getBean();
-//
-// CatchBatch catchBatch = beanToSave.toBean();
-//
-// if (log.isInfoEnabled()) {
-// log.info("FishingOperation " + catchBatch.getId() +
-// " was modified, will save it.");
-// }
-//
-// showInformationMessage(
-// "[ Captures - Caractéristiques générales ] " +
-// "Sauvegarde des modifications du résumé de la capture.");
-//
-// persistenceService.saveCatchBatch(catchBatch);
-// }
-
protected void registerValidators() {
registerValidators(getValidator(), ui.getSpeciesTabContent().getHandler().getValidator());
}
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -27,6 +27,7 @@
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -41,23 +42,21 @@
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";
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_CATCH_TOTAL_UNSORTED_WEIGHT = "catchTotalUnsortedWeight";
-
- public static final String PROPERTY_SPECIES_TOTAL_WEIGHT = "speciesTotalWeight";
-
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_SAMPLE_SORTED_WEIGHT = "speciesTotalSampleSortedWeight";
-
- public static final String PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT = "speciesTotalUnsortedWeight";
-
public static final String PROPERTY_SPECIES_TOTAL_INERT_WEIGHT = "speciesTotalInertWeight";
public static final String PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT = "speciesTotalLivingNotItemizedWeight";
@@ -119,18 +118,12 @@
protected static final Binder<EditCatchesUIModel, CatchBatch> toBeanBinder = BinderFactory.newBinder(EditCatchesUIModel.class, CatchBatch.class);
- protected Float speciesTotalWeight;
+ protected TuttiComputedOrNotData<Float> speciesTotalSortedComputedOrNotWeight = new TuttiComputedOrNotData<Float>();
- protected Float speciesTotalSortedWeight;
+ protected Float speciesTotalInertWeight = 0f;
- protected Float speciesTotalSampleSortedWeight;
+ protected Float speciesTotalLivingNotItemizedWeight = 0f;
- protected Float speciesTotalUnsortedWeight;
-
- protected Float speciesTotalInertWeight;
-
- protected Float speciesTotalLivingNotItemizedWeight;
-
protected Float benthosTotalWeight;
protected Float benthosTotalSortedWeight;
@@ -145,16 +138,16 @@
protected Float macroWasteTotalWeight;
- protected Float catchTotalWeight;
+ protected TuttiComputedOrNotData<Float> catchTotalComputedOrNotWeight
+ = new TuttiComputedOrNotData<Float>();
protected Float catchTotalSortedTremisWeight;
protected Float catchTotalSortedCarousselWeight;
- protected Float catchTotalRejectedWeight;
+ protected TuttiComputedOrNotData<Float> catchTotalRejectedComputedOrNotWeight
+ = new TuttiComputedOrNotData<Float>();
- protected Float catchTotalUnsortedWeight;
-
protected FishingOperation fishingOperation;
protected CatchBatch catchBatch;
@@ -173,7 +166,7 @@
}
public void setCatchBatch(CatchBatch catchBatch) {
- Object oldValue = getCatchTotalWeight();
+ Object oldValue = getCatchBatch();
this.catchBatch = catchBatch;
firePropertyChange(PROPERTY_CATCH_BATCH, oldValue, catchBatch);
}
@@ -188,16 +181,30 @@
firePropertyChange(PROPERTY_FISHING_OPERATION, oldValue, fishingOperation);
}
+ public TuttiComputedOrNotData<Float> getCatchTotalComputedOrNotWeight() {
+ return catchTotalComputedOrNotWeight;
+ }
+
public Float getCatchTotalWeight() {
- return catchTotalWeight;
+ return catchTotalComputedOrNotWeight.getData();
}
public void setCatchTotalWeight(Float catchTotalWeight) {
Object oldValue = getCatchTotalWeight();
- this.catchTotalWeight = catchTotalWeight;
+ this.catchTotalComputedOrNotWeight.setData(catchTotalWeight);
firePropertyChange(PROPERTY_CATCH_TOTAL_WEIGHT, oldValue, catchTotalWeight);
}
+
+ public Float getCatchTotalComputedWeight() {
+ return catchTotalComputedOrNotWeight.getComputedData();
+ }
+ public void setCatchTotalComputedWeight(Float catchTotalComputedWeight) {
+ Object oldValue = getCatchTotalComputedWeight();
+ this.catchTotalComputedOrNotWeight.setComputedData(catchTotalComputedWeight);
+ firePropertyChange(PROPERTY_CATCH_TOTAL_COMPUTED_WEIGHT, oldValue, catchTotalComputedWeight);
+ }
+
public Float getCatchTotalSortedTremisWeight() {
return catchTotalSortedTremisWeight;
}
@@ -218,66 +225,54 @@
firePropertyChange(PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT, oldValue, catchTotalSortedCarousselWeight);
}
+ public TuttiComputedOrNotData<Float> getCatchTotalRejectedComputedOrNotWeight() {
+ return catchTotalRejectedComputedOrNotWeight;
+ }
+
public Float getCatchTotalRejectedWeight() {
- return catchTotalRejectedWeight;
+ return catchTotalRejectedComputedOrNotWeight.getData();
}
public void setCatchTotalRejectedWeight(Float catchTotalRejectedWeight) {
Object oldValue = getCatchTotalRejectedWeight();
- this.catchTotalRejectedWeight = catchTotalRejectedWeight;
+ this.catchTotalRejectedComputedOrNotWeight.setData(catchTotalRejectedWeight);
firePropertyChange(PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT, oldValue, catchTotalRejectedWeight);
}
- public Float getCatchTotalUnsortedWeight() {
- return catchTotalUnsortedWeight;
+ public Float getCatchTotalRejectedComputedWeight() {
+ return catchTotalRejectedComputedOrNotWeight.getComputedData();
}
- public void setCatchTotalUnsortedWeight(Float catchTotalUnsortedWeight) {
- Object oldValue = getCatchTotalUnsortedWeight();
- this.catchTotalUnsortedWeight = catchTotalUnsortedWeight;
- firePropertyChange(PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT, oldValue, catchTotalUnsortedWeight);
+ public void setCatchTotalRejectedComputedWeight(Float catchTotalRejectedComputedWeight) {
+ Object oldValue = getCatchTotalRejectedComputedWeight();
+ this.catchTotalRejectedComputedOrNotWeight.setComputedData(catchTotalRejectedComputedWeight);
+ firePropertyChange(PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT, oldValue, catchTotalRejectedComputedWeight);
}
-
- public Float getSpeciesTotalWeight() {
- return speciesTotalWeight;
+
+ public TuttiComputedOrNotData<Float> getSpeciesTotalSortedComputedOrNotWeight() {
+ return speciesTotalSortedComputedOrNotWeight;
}
-
- public void setSpeciesTotalWeight(Float speciesTotalWeight) {
- Object oldValue = getSpeciesTotalWeight();
- this.speciesTotalWeight = speciesTotalWeight;
- firePropertyChange(PROPERTY_SPECIES_TOTAL_WEIGHT, oldValue, speciesTotalWeight);
- }
-
+
public Float getSpeciesTotalSortedWeight() {
- return speciesTotalSortedWeight;
+ return speciesTotalSortedComputedOrNotWeight.getData();
}
public void setSpeciesTotalSortedWeight(Float speciesTotalSortedWeight) {
Object oldValue = getSpeciesTotalSortedWeight();
- this.speciesTotalSortedWeight = speciesTotalSortedWeight;
+ this.speciesTotalSortedComputedOrNotWeight.setData(speciesTotalSortedWeight);
firePropertyChange(PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, oldValue, speciesTotalSortedWeight);
}
-
- public Float getSpeciesTotalSampleSortedWeight() {
- return speciesTotalSampleSortedWeight;
+
+ public Float getSpeciesTotalSortedComputedWeight() {
+ return speciesTotalSortedComputedOrNotWeight.getComputedData();
}
- public void setSpeciesTotalSampleSortedWeight(Float speciesTotalSampleSortedWeight) {
- Object oldValue = getSpeciesTotalSampleSortedWeight();
- this.speciesTotalSampleSortedWeight = speciesTotalSampleSortedWeight;
- firePropertyChange(PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT, oldValue, speciesTotalSampleSortedWeight);
+ public void setSpeciesTotalSortedComputedWeight(Float speciesTotalSortedComputedWeight) {
+ Object oldValue = getSpeciesTotalSortedComputedWeight();
+ this.speciesTotalSortedComputedOrNotWeight.setComputedData(speciesTotalSortedComputedWeight);
+ firePropertyChange(PROPERTY_SPECIES_TOTAL_SORTED_COMPUTED_WEIGHT, oldValue, speciesTotalSortedComputedWeight);
}
- public Float getSpeciesTotalUnsortedWeight() {
- return speciesTotalUnsortedWeight;
- }
-
- public void setSpeciesTotalUnsortedWeight(Float speciesTotalUnsortedWeight) {
- Object oldValue = getSpeciesTotalUnsortedWeight();
- this.speciesTotalUnsortedWeight = speciesTotalUnsortedWeight;
- firePropertyChange(PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT, oldValue, speciesTotalUnsortedWeight);
- }
-
public Float getSpeciesTotalInertWeight() {
return speciesTotalInertWeight;
}
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -65,6 +65,22 @@
* @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;
public static <C extends Serializable> SampleCategory<C> newSample(SampleCategoryType categoryType) {
SampleCategory<C> result = new SampleCategory<C>();
@@ -107,6 +123,22 @@
this.computedWeight = computedWeight;
}
+ public boolean isSubSample() {
+ return subSample;
+ }
+
+ public void setSubSample(boolean subSample) {
+ this.subSample = subSample;
+ }
+
+ public boolean hasOnlyOneFrequency() {
+ return onlyOneFrequency;
+ }
+
+ public void setOnlyOneFrequency(boolean onlyOneFrequency) {
+ this.onlyOneFrequency = onlyOneFrequency;
+ }
+
public boolean isValid() {
return categoryValue != null;
}
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -38,6 +38,7 @@
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.BorderLayout;
+import java.awt.Color;
import java.awt.Component;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
@@ -208,6 +209,7 @@
boolean hasFocus,
int row,
int column) {
+
SampleCategory<C> sampleCategory = (SampleCategory<C>) value;
String text = null;
@@ -219,12 +221,25 @@
Float number = sampleCategory.getCategoryWeight();
Float computedNumber = sampleCategory.getComputedWeight();
- text = "<html>" + categoryDecorator.toString(categoryValue) + " / ";
+ text = "<html>" + categoryDecorator.toString(categoryValue) + " /";
+
+ if (sampleCategory.isSubSample()) {
+ text += "/";
+ }
+ text += " ";
if (number != null) {
- text += number;
+ text += String.format("%.3f", number);
+
} else if (computedNumber != null) {
- text += "<em style='color: blue'>" + computedNumber + "</em>";
+ if (sampleCategory.hasOnlyOneFrequency()) {
+ text += String.format("%.3f", computedNumber);
+
+ } else {
+ String blue = Integer.toHexString(Color.BLUE.getRGB()).substring(2);
+ text += "<em style='color: #" + blue + "'>" +
+ String.format("%.3f", computedNumber) + "</em>";
+ }
} else {
text += "-";
}
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -34,12 +34,15 @@
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.util.Collections;
import java.util.List;
+import org.apache.commons.logging.LogFactory;
/**
* Represents a species batch (i.e a row in the batch table).
@@ -239,6 +242,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());
+ }
+ });
+ computedOrNotWeight.addPropertyChangeListener(
+ TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA,
+ new PropertyChangeListener() {
+
+ 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());
+ }
+ });
+ computedOrNotNumber.addPropertyChangeListener(
+ TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA,
+ new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_COMPUTED_NUMBER, evt.getOldValue(), evt.getNewValue());
+ }
+ });
}
public SpeciesBatchRowModel(SpeciesBatch aBatch,
@@ -287,6 +324,26 @@
return sampleCategory;
}
+ public SampleCategory getFinestCategory() {
+ SampleCategory finestCategory;
+ if (ageCategory.isValid()) {
+ finestCategory = ageCategory;
+
+ } else if (maturityCategory.isValid()) {
+ finestCategory = maturityCategory;
+
+ } else if (sexCategory.isValid()) {
+ finestCategory = sexCategory;
+
+ } else if (sizeCategory.isValid()) {
+ finestCategory = sizeCategory;
+
+ } else {
+ finestCategory = sortedUnsortedCategory;
+ }
+ return finestCategory;
+ }
+
//------------------------------------------------------------------------//
//-- Species category --//
//------------------------------------------------------------------------//
@@ -515,9 +572,7 @@
}
public void setWeight(Float weight) {
- Object oldValue = getWeight();
this.computedOrNotWeight.setData(weight);
- firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
}
public Integer getNumber() {
@@ -525,9 +580,7 @@
}
public void setNumber(Integer number) {
- Object oldValue = getNumber();
computedOrNotNumber.setData(number);
- firePropertyChange(PROPERTY_NUMBER, oldValue, number);
}
public String getComment() {
@@ -565,10 +618,7 @@
}
public void setComputedNumber(Integer computedNumber) {
- Object oldValue = getComputedNumber();
computedOrNotNumber.setComputedData(computedNumber);
- firePropertyChange(PROPERTY_COMPUTED_NUMBER, oldValue,
- computedNumber);
}
public Float getComputedWeight() {
@@ -576,10 +626,7 @@
}
public void setComputedWeight(Float computedWeight) {
- Object oldValue = getComputedWeight();
computedOrNotWeight.setComputedData(computedWeight);
- firePropertyChange(PROPERTY_COMPUTED_WEIGHT, oldValue,
- computedWeight);
}
public TuttiComputedOrNotData<Integer> getComputedOrNotNumber() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-02-15 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-02-15 18:24:13 UTC (rev 427)
@@ -27,18 +27,26 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
bean: {model};
showReset: true;
+ useFloat: true;
+ numberPattern: {DECIMAL3_PATTERN};
}
+TuttiComputedOrNotDataEditor {
+ autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
+ showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+ showReset: true;
+ useFloat: true;
+ numberPattern: {DECIMAL3_PATTERN};
+ decimalNumber: 3;
+}
+
#speciesTotalWeightLabel {
text: "tutti.label.catches.speciesTotalWeight";
labelFor: {speciesTotalWeightField};
}
#speciesTotalWeightField {
- property: speciesTotalWeight;
- model: {model.getSpeciesTotalWeight()};
- numberPattern: {DECIMALFORCE3_PATTERN};
- useFloat: true;
+ _computed: true;
}
#speciesTotalSortedWeightLabel {
@@ -47,10 +55,8 @@
}
#speciesTotalSortedWeightField {
- property: speciesTotalSortedWeight;
+ bean: {model.getSpeciesTotalSortedComputedOrNotWeight()};
model: {model.getSpeciesTotalSortedWeight()};
- numberPattern: {DECIMALFORCE3_PATTERN};
- useFloat: true;
}
#speciesTotalSampleSortedWeightLabel {
@@ -59,9 +65,7 @@
}
#speciesTotalSampleSortedWeightField {
- text: {getStringValue(model.getSpeciesTotalUnsortedWeight())};
- editable: false;
- enabled: false;
+ _computed: true;
}
#speciesTotalUnsortedWeightLabel {
@@ -70,9 +74,7 @@
}
#speciesTotalUnsortedWeightField {
- text: {getStringValue(model.getSpeciesTotalUnsortedWeight())};
- editable: false;
- enabled: false;
+ _computed: true;
}
#speciesTotalInertWeightLabel {
@@ -83,8 +85,7 @@
#speciesTotalInertWeightField {
property: speciesTotalInertWeight;
model: {model.getSpeciesTotalInertWeight()};
- numberPattern: {DECIMALFORCE3_PATTERN};
- useFloat: true;
+ showReset: false;
}
#speciesTotalLivingNotItemizedWeightLabel {
@@ -95,8 +96,7 @@
#speciesTotalLivingNotItemizedWeightField {
property: speciesTotalLivingNotItemizedWeight;
model: {model.getSpeciesTotalLivingNotItemizedWeight()};
- numberPattern: {DECIMALFORCE3_PATTERN};
- useFloat: true;
+ showReset: false;
}
#tablePopup {
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-02-15 18:24:13 UTC (rev 427)
@@ -29,6 +29,7 @@
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
+ fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
org.jdesktop.swingx.JXTable
@@ -67,13 +68,8 @@
<BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
- <field name='speciesTotalWeight' component='speciesTotalWeightField'/>
<field name='speciesTotalSortedWeight'
component='speciesTotalSortedWeightField'/>
- <field name='speciesTotalSampleSortedWeight'
- component='speciesTotalSampleSortedWeightField'/>
- <field name='speciesTotalUnsortedWeight'
- component='speciesTotalUnsortedWeightField'/>
</BeanValidator>
<LongTextEditorUI id='longTextEditor'/>
@@ -96,13 +92,13 @@
<JLabel id='speciesTotalWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <NumberEditor id='speciesTotalWeightField' constructorParams='this'/>
+ <JTextField id='speciesTotalWeightField'/>
</cell>
<cell anchor='west'>
<JLabel id='speciesTotalSortedWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <NumberEditor id='speciesTotalSortedWeightField'
+ <TuttiComputedOrNotDataEditor id='speciesTotalSortedWeightField'
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -58,7 +58,7 @@
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
-import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor;
+import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataTableCell;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
@@ -132,7 +132,6 @@
public SpeciesBatchUIHandler(TuttiUI<?, ?> parentUi,
SpeciesBatchUI ui) {
super(parentUi, ui,
- SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
SpeciesBatchRowModel.PROPERTY_SPECIES,
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
@@ -148,7 +147,8 @@
SpeciesBatchRowModel.PROPERTY_NUMBER,
SpeciesBatchRowModel.PROPERTY_COMMENT,
SpeciesBatchRowModel.PROPERTY_ATTACHMENTS,
- SpeciesBatchRowModel.PROPERTY_FREQUENCY);
+ SpeciesBatchRowModel.PROPERTY_FREQUENCY,
+ SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM);
tableFilters = new EnumMap<TableViewMode, RowFilter<SpeciesBatchTableModel, Integer>>(TableViewMode.class);
tableFilters.put(TableViewMode.ALL, new RowFilter<SpeciesBatchTableModel, Integer>() {
@@ -277,14 +277,13 @@
Object oldValue,
Object newValue) {
- if (SAMPLING_PROPERTIES.contains(propertyName) ||
- SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
+ if (SAMPLING_PROPERTIES.contains(propertyName)) {
// species has changed, recompute valid property
recomputeRowValidState(row);
// recompute the totalUnsorted weight
- recomputeTotalUnsortedWeight();
+// recomputeTotalUnsortedWeight();
}
// when row valid state has changed, recompute action enabled states
@@ -294,11 +293,12 @@
@Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor,
SpeciesBatchRowModel row) {
-
+log.debug("saveSelectedRowIfRequired");
if (row.isValid()) {
// there is a valid bean attached to the monitor
-
+log.debug("isValid");
if (rowMonitor.wasModified()) {
+log.debug("wasModified");
// monitored bean was modified, save it
if (log.isInfoEnabled()) {
@@ -315,6 +315,7 @@
rowMonitor.clearModified();
}
} else {
+log.debug("wasNotModified");
//FIXME See how to delete rows ? Or moreover how to save tehem...
if (log.isWarnEnabled()) {
@@ -592,15 +593,11 @@
{ // Weight column
- TuttiComputedOrNotDataEditor<Float> editor =
- new TuttiComputedOrNotDataEditor(Float.class, false);
- editor.getNumberEditor().setSelectAllTextOnError(true);
- editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
- editor.getNumberEditor().setNumberPattern(TuttiUI.DECIMALFORCE3_PATTERN);
-
addColumnToModel(columnModel,
- editor,
- null,
+ TuttiComputedOrNotDataTableCell.newEditor(
+ Float.class, false, true, 3),
+ TuttiComputedOrNotDataTableCell.newRender(
+ defaultRenderer, true, 3),
SpeciesBatchTableModel.WEIGHT);
}
@@ -852,6 +849,7 @@
}
}
row.setComputedNumber(totalNumber);
+ row.getFinestCategory().setOnlyOneFrequency(frequency.size() == 1);
}
}
@@ -957,7 +955,8 @@
log.info("New total vrac / hors vrac: " +
totalVrac + " / " + totalHorsVrac);
}
- getModel().setSpeciesTotalUnsortedWeight(totalHorsVrac);
+ ui.getSpeciesTotalUnsortedWeightField()
+ .setText(JAXXUtil.getStringValue(totalHorsVrac));
//TODO Should we also set the total vrac weight ?
// getModel().setTotalVracWeight(totalVrac);
}
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -30,6 +30,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
import java.util.List;
@@ -132,22 +133,15 @@
public SpeciesBatchUIModel(EditCatchesUIModel catchesUIModel) {
super(catchesUIModel,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT);
}
- public Float getSpeciesTotalWeight() {
- return catchesUIModel.getSpeciesTotalWeight();
+ public TuttiComputedOrNotData<Float> getSpeciesTotalSortedComputedOrNotWeight() {
+ return catchesUIModel.getSpeciesTotalSortedComputedOrNotWeight();
}
- public void setSpeciesTotalWeight(Float speciesTotalWeight) {
- catchesUIModel.setSpeciesTotalWeight(speciesTotalWeight);
- }
-
public Float getSpeciesTotalSortedWeight() {
return catchesUIModel.getSpeciesTotalSortedWeight();
}
@@ -155,23 +149,15 @@
public void setSpeciesTotalSortedWeight(Float speciesTotalSortedWeight) {
catchesUIModel.setSpeciesTotalSortedWeight(speciesTotalSortedWeight);
}
-
- public Float getSpeciesTotalSampleSortedWeight() {
- return catchesUIModel.getSpeciesTotalSampleSortedWeight();
+
+ public Float getSpeciesTotalSortedComputedWeight() {
+ return catchesUIModel.getSpeciesTotalSortedComputedWeight();
}
- public void setSpeciesTotalSampleSortedWeight(Float speciesSampleSortedWeight) {
- catchesUIModel.setSpeciesTotalSampleSortedWeight(speciesSampleSortedWeight);
+ public void setSpeciesTotalSortedComputedWeight(Float speciesTotalSortedComputedWeight) {
+ catchesUIModel.setSpeciesTotalSortedComputedWeight(speciesTotalSortedComputedWeight);
}
- public Float getSpeciesTotalUnsortedWeight() {
- return catchesUIModel.getSpeciesTotalUnsortedWeight();
- }
-
- public void setSpeciesTotalUnsortedWeight(Float speciesTotalUnsortedWeight) {
- catchesUIModel.setSpeciesTotalUnsortedWeight(speciesTotalUnsortedWeight);
- }
-
public Float getSpeciesTotalInertWeight() {
return catchesUIModel.getSpeciesTotalInertWeight();
}
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -26,6 +26,7 @@
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;
@@ -46,6 +47,7 @@
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;
@@ -72,7 +74,26 @@
setHorizontalAlignment(CENTER);
setIcon(SwingUtil.createActionIcon("show-frequency"));
}
+
+ public void setComputedOrNotText(TuttiComputedOrNotData<Integer> data) {
+ String text;
+ if (data != null && data.getData() != null) {
+ text = String.valueOf(data.getData());
+
+ } else if (data != null
+ && 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>";
+
+ } else {
+ text = " - ";
+ }
+ setText(text);
+ }
+
public static TableCellRenderer newRender() {
return new FrequencyCellRenderer();
}
@@ -171,11 +192,7 @@
}
// push back to batch
- Integer number = null;
- if (frequency.size() == 1) {
- number = frequency.get(0).getNumber();
- }
- editRow.setNumber(number);
+ editRow.setNumber(null);
}
@@ -207,14 +224,9 @@
this.table = table;
columnIdentifier = tableModel.getPropertyName(column);
}
- String text;
- if (value == null) {
- text = " - ";
- } else {
- text = String.valueOf(value);
- }
- component.setText(text);
-
+ TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value;
+ component.setComputedOrNotText(data);
+
rowIndex = row;
columnIndex = column;
@@ -275,21 +287,13 @@
int row,
int column) {
+ TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value;
FrequencyCellComponent result =
(FrequencyCellComponent) component.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- if (table != null) {
- String text;
- if (value == null) {
- text = " - ";
- } else {
- text = String.valueOf(value);
- }
- boolean editable = table.isCellEditable(row, column);
- result.setEnabled(editable);
- result.setText(text);
- }
-
+ boolean editable = table.isCellEditable(row, column);
+ result.setEnabled(editable);
+ result.setComputedOrNotText(data);
return result;
}
}
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -27,6 +27,7 @@
import com.ezware.oxbow.swingbits.util.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
@@ -59,6 +60,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -77,6 +79,8 @@
private Map<Integer, SpeciesProtocol> speciesProtocol;
private Map<String, Caracteristic> lengthStepCaracteristics;
+
+ protected Set<SpeciesFrequencyRowModel> withWeightRows = Sets.newHashSet();
public SpeciesFrequencyUIHandler(TuttiUIContext context,
SpeciesFrequencyUI ui) {
@@ -104,7 +108,8 @@
protected boolean isRowValid(SpeciesFrequencyRowModel row) {
return row.getLengthStepCaracteristic() != null &&
row.getLengthStep() != null &&
- row.getNumber() != null;
+ row.getNumber() != null && row.getNumber() > 0 &&
+ (withWeightRows.isEmpty() || row.getWeight() != null && row.getWeight() > 0);
}
@Override
@@ -114,7 +119,28 @@
Object oldValue,
Object newValue) {
- recomputeRowValidState(row);
+ 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,
+ // the other ones do not need to have a weight to be valid
+ recomputeAllRows = withWeightRows.isEmpty();
+ }
+ if (recomputeAllRows) {
+ List<SpeciesFrequencyRowModel> rows = getModel().getRows();
+ for (SpeciesFrequencyRowModel r : rows) {
+ recomputeRowValidState(r);
+ }
+ } else {
+ recomputeRowValidState(row);
+ }
}
@Override
@@ -237,7 +263,7 @@
addFloatColumnToModel(columnModel,
SpeciesFrequencyTableModel.WEIGHT,
- TuttiUI.DECIMALFORCE3_PATTERN);
+ TuttiUI.DECIMAL3_PATTERN);
}
// create table model
@@ -367,9 +393,10 @@
}
public void editBatch(SpeciesBatchRowModel speciesBatch, FrequencyCellEditor editor) {
-
+ withWeightRows.clear();
+
frequencyEditor = editor;
-
+
Caracteristic lengthStepCaracteristic = null;
Float lengthStep = 1f;
@@ -382,7 +409,7 @@
// try to load existing frequency
- if (frequency != null) {
+ if (!CollectionUtils.isEmpty(frequency)) {
SpeciesFrequencyTableModel tableModel = getTableModel();
@@ -394,22 +421,23 @@
newRow.setNumber(rowModel.getNumber());
newRow.setWeight(rowModel.getWeight());
editFrequency.add(newRow);
+
+ if (newRow.getWeight() != null) {
+ withWeightRows.add(newRow);
+ }
}
- if (CollectionUtils.isNotEmpty(frequency)) {
+ // use first frequency row length step caracteristics
- // use first frequency row length step caracteristics
+ SpeciesFrequencyRowModel rowModel = frequency.get(0);
+ lengthStepCaracteristic = rowModel.getLengthStepCaracteristic();
+ lengthStep = rowModel.getLengthStep();
- SpeciesFrequencyRowModel rowModel = frequency.get(0);
- lengthStepCaracteristic = rowModel.getLengthStepCaracteristic();
- lengthStep = rowModel.getLengthStep();
-
- if (log.isInfoEnabled()) {
- log.info("Use existing lengthStep " +
- "caracteristic / step " +
- decorate(lengthStepCaracteristic) + " / " +
- lengthStep);
- }
+ if (log.isInfoEnabled()) {
+ log.info("Use existing lengthStep " +
+ "caracteristic / step " +
+ decorate(lengthStepCaracteristic) + " / " +
+ lengthStep);
}
}
@@ -454,7 +482,6 @@
mode = SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE_COUNTING;
}
}
-
if (speciesBatch.getNumber() != null && editFrequency.isEmpty()) {
mode = SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE_COUNTING;
model.setSimpleCount(speciesBatch.getNumber());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-02-15 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-02-15 18:24:13 UTC (rev 427)
@@ -75,7 +75,7 @@
property: batchWeight;
model: {model.getBatchWeight()};
useFloat: true;
- numberPattern: {DECIMALFORCE3_PATTERN};
+ numberPattern: {DECIMAL3_PATTERN};
bean: {model};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-02-15 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -382,7 +382,7 @@
addFloatColumnToModel(columnModel,
SplitSpeciesBatchTableModel.WEIGHT,
- TuttiUI.DECIMALFORCE3_PATTERN);
+ TuttiUI.DECIMAL3_PATTERN);
}
}
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -1,6 +1,8 @@
package fr.ifremer.tutti.ui.swing.util;
+import org.jdesktop.beans.AbstractBean;
+
/*
* #%L
* Tutti :: UI
@@ -29,8 +31,12 @@
*
* @author kmorin <kmorin(a)codelutin.com>
*/
-public class TuttiComputedOrNotData<N extends Number> {
+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;
@@ -50,7 +56,9 @@
}
public void setData(N data) {
+ Object oldValue = getData();
this.data = data;
+ firePropertyChange(PROPERTY_DATA, oldValue, data);
}
public N getComputedData() {
@@ -58,16 +66,18 @@
}
public void setComputedData(N computedData) {
+ Object oldValue = getComputedData();
this.computedData = computedData;
+ firePropertyChange(PROPERTY_COMPUTED_DATA, oldValue, computedData);
}
-
+
@Override
public String toString() {
String result = null;
if (data != null) {
result = data.toString();
} else if (computedData != null) {
- result = "<html><em style='color: blue'>" + computedData.toString() + "</em></html>";
+ result = computedData.toString();
}
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.java 2013-02-15 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -1,141 +1,10 @@
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.util.TuttiComputedOrNotData;
-import java.awt.Component;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import javax.swing.AbstractCellEditor;
-import javax.swing.JTable;
-import javax.swing.SwingConstants;
-import javax.swing.SwingUtilities;
-import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
-import javax.swing.table.TableCellEditor;
-import jaxx.runtime.swing.editor.NumberEditor;
-
/**
- * Editor for TuttiComputedOrNotData
- *
+ *
* @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
*/
-public class TuttiComputedOrNotDataEditor<E extends Number> extends AbstractCellEditor
- implements TableCellEditor, FocusListener, AncestorListener {
+public class TuttiComputedOrNotDataEditor {
- private static final long serialVersionUID = 1L;
-
- protected final NumberEditor numberEditor;
-
- protected TuttiComputedOrNotData<E> data;
-
- /** constructor */
- public TuttiComputedOrNotDataEditor(Class<E> type, boolean useSign) {
- numberEditor = new NumberEditor();
- numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT);
- numberEditor.getTextField().setBorder(null);
- numberEditor.getTextField().addFocusListener(this);
- numberEditor.getTextField().addAncestorListener(this);
-
- numberEditor.setModelType(type);
-
- numberEditor.setUseSign(useSign);
- numberEditor.init();
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value,
- boolean isSelected, int row, int column) {
-
- data = (TuttiComputedOrNotData<E>) value;
- numberEditor.setModel(data.getData());
-
- // Check nullity and set the text that will be selected with the current value
- if (data.getData() != null) {
- numberEditor.setModelText(String.valueOf(data.getData()));
- }
- return numberEditor;
- }
-
- public NumberEditor getNumberEditor() {
- return numberEditor;
- }
-
- @Override
- public TuttiComputedOrNotData<E> getCellEditorValue() {
- return data;
- }
-
- @Override
- public void focusGained(FocusEvent e) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- numberEditor.getTextField().requestFocus();
- numberEditor.getTextField().selectAll();
- }
- });
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- }
-
- @Override
- public void ancestorAdded(AncestorEvent event) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- numberEditor.getTextField().requestFocus();
- numberEditor.getTextField().selectAll();
- }
- });
- }
-
- @Override
- public void ancestorRemoved(AncestorEvent event) {
- }
-
- @Override
- public void ancestorMoved(AncestorEvent event) {
- }
-
- @Override
- public boolean stopCellEditing() {
- boolean result = super.stopCellEditing();
- // Reset previous data to avoid keeping it on other cell edition
- if (result) {
- data.setData((E) numberEditor.getModel());
-
- numberEditor.setModel(null);
- // Use empty string, otherwise there is a NPE in NumberEditorHandler
- numberEditor.setModelText("");
-
- data = null;
- }
- return result;
- }
-
}
Added: 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 (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-02-15 18:24:13 UTC (rev 427)
@@ -0,0 +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
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java (from rev 411, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -0,0 +1,113 @@
+
+package fr.ifremer.tutti.ui.swing.util.editor;
+
+import fr.ifremer.tutti.ui.swing.TuttiUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+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() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ setComputedTextIfNullModel();
+ }
+ };
+
+ TuttiComputedOrNotData bean = (TuttiComputedOrNotData) editor.getBean();
+ if (bean != null) {
+ bean.addPropertyChangeListener(TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, l);
+ }
+ 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) {
+ JTextField tf = editor.getTextField();
+ tf.setFont(TuttiUI.TEXTFIELD_NORMAL_FONT);
+ tf.setForeground(Color.BLACK);
+ if (editor.getModel() == null) {
+ tf.setText("");
+ }
+ }
+
+ public void focusLost(FocusEvent e) {
+ setComputedTextIfNullModel();
+ }
+ });
+
+ editor.addPropertyChangeListener(TuttiComputedOrNotDataEditor.PROPERTY_DECIMAL_NUMBER,
+ new PropertyChangeListener() {
+
+ 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) {
+ modelText = String.format("%." + decimalNumber + "f", computedData);
+ } else {
+ modelText = JAXXUtil.getStringValue(computedData);
+ }
+ tf.setText(modelText);
+ }
+ }
+
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java (from rev 411, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-02-15 18:24:13 UTC (rev 427)
@@ -0,0 +1,209 @@
+package fr.ifremer.tutti.ui.swing.util.editor;
+
+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 javax.swing.AbstractCellEditor;
+import javax.swing.JTable;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.border.LineBorder;
+import javax.swing.event.AncestorEvent;
+import javax.swing.event.AncestorListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import jaxx.runtime.JAXXUtil;
+
+/**
+ * Editor for TuttiComputedOrNotData
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class TuttiComputedOrNotDataTableCell extends DefaultTableCellRenderer {
+
+ public static TableCellRenderer newRender(TableCellRenderer renderer,
+ boolean useFloat,
+ Integer decimalNumber) {
+
+ return new TuttiComputedOrNotDataTableCellRenderer(renderer,
+ useFloat,
+ decimalNumber);
+ }
+
+ public static TableCellEditor newEditor(Class type,
+ boolean useSign,
+ boolean useFloat,
+ Integer decimalNumber) {
+
+ return new TuttiComputedOrNotDataTableCellEditor(type, useSign,
+ useFloat, decimalNumber);
+ }
+
+ public static class TuttiComputedOrNotDataTableCellEditor
+ extends AbstractCellEditor
+ implements TableCellEditor, FocusListener, AncestorListener {
+
+ private static final long serialVersionUID = 1L;
+ protected final TuttiComputedOrNotDataEditor numberEditor;
+ protected TuttiComputedOrNotData data;
+
+ /**
+ * constructor
+ */
+ public TuttiComputedOrNotDataTableCellEditor(Class type,
+ boolean useSign,
+ boolean useFloat,
+ Integer decimalNumber) {
+
+ numberEditor = new TuttiComputedOrNotDataEditor();
+ numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT);
+ numberEditor.getTextField().addFocusListener(this);
+ numberEditor.getTextField().addAncestorListener(this);
+ numberEditor.getTextField().setBorder(new LineBorder(Color.GRAY, 2));
+ numberEditor.setSelectAllTextOnError(true);
+ numberEditor.setNumberPattern(TuttiUI.DECIMAL3_PATTERN);
+
+ numberEditor.setModelType(type);
+ numberEditor.setUseSign(useSign);
+ numberEditor.setUseFloat(useFloat);
+ numberEditor.setDecimalNumber(decimalNumber);
+ numberEditor.init();
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected, int row, int column) {
+
+ data = (TuttiComputedOrNotData) value;
+ numberEditor.setModel(data.getData());
+
+ // Check nullity and set the text that will be selected with the current value
+ if (data.getData() != null) {
+ numberEditor.setModelText(String.valueOf(data.getData()));
+ }
+ return numberEditor;
+ }
+
+ public TuttiComputedOrNotDataEditor getNumberEditor() {
+ return numberEditor;
+ }
+
+ @Override
+ public TuttiComputedOrNotData getCellEditorValue() {
+ return data;
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ numberEditor.getTextField().requestFocus();
+ numberEditor.getTextField().selectAll();
+ }
+ });
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ }
+
+ @Override
+ public void ancestorAdded(AncestorEvent event) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ numberEditor.getTextField().requestFocus();
+ numberEditor.getTextField().selectAll();
+ }
+ });
+ }
+
+ @Override
+ public void ancestorRemoved(AncestorEvent event) {
+ }
+
+ @Override
+ public void ancestorMoved(AncestorEvent event) {
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ boolean result = super.stopCellEditing();
+ // Reset previous data to avoid keeping it on other cell edition
+ if (result) {
+ data.setData(numberEditor.getModel());
+
+ numberEditor.setBean(null);
+
+ data = null;
+ }
+ return result;
+ }
+ }
+
+ public static class TuttiComputedOrNotDataTableCellRenderer<E>
+ 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) {
+
+ TuttiComputedOrNotData data = (TuttiComputedOrNotData) value;
+ Number dataValue = data.getData();
+ Font font;
+ Color foreground;
+ if (dataValue == null) {
+ dataValue = data.getComputedData();
+ font = TuttiUI.TEXTFIELD_COMPUTED_FONT;
+ foreground = Color.BLUE;
+
+ } else {
+ font = TuttiUI.TEXTFIELD_NORMAL_FONT;
+ foreground = Color.BLACK;
+ }
+ String text;
+ if (useFloat && decimalNumber != null && dataValue != null) {
+ text = JAXXUtil.getStringValue(
+ String.format("%." + decimalNumber + "f", dataValue));
+ } else {
+ text = JAXXUtil.getStringValue(dataValue);
+ }
+
+ Component component = delegate.getTableCellRendererComponent(table,
+ text,
+ isSelected,
+ hasFocus,
+ row,
+ column);
+ component.setFont(font);
+ component.setForeground(foreground);
+
+ return component;
+ }
+
+ }
+}
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-edit-warning-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-edit-warning-validation.xml 2013-02-15 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-edit-warning-validation.xml 2013-02-15 18:24:13 UTC (rev 427)
@@ -42,9 +42,11 @@
<field-validator type="fieldexpression" short-circuit="true">
<param name="expression">
<![CDATA[ gearShootingStartDate == null || gearShootingEndDate == null
- || org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) <= 45 ]]>
+ || (org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) <= 45
+ && org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) >= 20 )
+ ]]>
</param>
- <message>tutti.validator.error.fishingOperation.dates.tooLong</message>
+ <message>tutti.validator.error.fishingOperation.dates.wrongTime</message>
</field-validator>
</field>
@@ -61,9 +63,11 @@
<field-validator type="fieldexpression" short-circuit="true">
<param name="expression">
<![CDATA[ gearShootingStartDate == null || gearShootingEndDate == null
- || org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) <= 45 ]]>
+ || (org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) <= 45
+ && org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) >= 20 )
+ ]]>
</param>
- <message>tutti.validator.error.fishingOperation.dates.tooLong</message>
+ <message>tutti.validator.error.fishingOperation.dates.wrongTime</message>
</field-validator>
</field>
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-warning-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-warning-validation.xml 2013-02-15 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-warning-validation.xml 2013-02-15 18:24:13 UTC (rev 427)
@@ -35,9 +35,11 @@
<field-validator type="fieldexpression" short-circuit="true">
<param name="expression">
<![CDATA[ gearShootingStartDate == null || gearShootingEndDate == null
- || org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) <= 45 ]]>
+ || org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) <= 45
+ && org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) >= 20 )
+ ]]>
</param>
- <message>tutti.validator.error.fishingOperation.dates.tooLong</message>
+ <message>tutti.validator.error.fishingOperation.dates.wrongTime</message>
</field-validator>
</field>
@@ -47,9 +49,11 @@
<field-validator type="fieldexpression" short-circuit="true">
<param name="expression">
<![CDATA[ gearShootingStartDate == null || gearShootingEndDate == null
- || org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) <= 45 ]]>
+ || org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) <= 45
+ && org.nuiton.util.DateUtil.getDifferenceInMinutes(gearShootingStartDate, gearShootingEndDate) >= 20 )
+ ]]>
</param>
- <message>tutti.validator.error.fishingOperation.dates.tooLong</message>
+ <message>tutti.validator.error.fishingOperation.dates.wrongTime</message>
</field-validator>
</field>
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 17:55:53 UTC (rev 426)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-15 18:24:13 UTC (rev 427)
@@ -195,7 +195,7 @@
tutti.label.catches.catchThalassa=(*) uniquement sur Thalassa
tutti.label.catches.catchTotalRejectedWeight=Poids total NON TRIÉ (kg)
tutti.label.catches.catchTotalSortedCarousselWeight=Caroussel Observé (*)
-tutti.label.catches.catchTotalSortedTremisWeight=Tremis (*)
+tutti.label.catches.catchTotalSortedTremisWeight=Tremie (*)
tutti.label.catches.catchTotalSortedWeight=Poids total VRAC (kg)
tutti.label.catches.catchTotalUnsortedWeight=Poids total HORS VRAC (kg)
tutti.label.catches.catchTotalWeight=Poids TOTAL (kg)
@@ -497,7 +497,7 @@
tutti.validator.error.fishingOperation.dates.endBeforeStart=La date de fin doit être après la date de début
tutti.validator.error.fishingOperation.dates.endOutOfCruiseDates=La date de fin est en dehors des dates de la campagne
tutti.validator.error.fishingOperation.dates.startOutOfCruiseDates=La date de début est en dehors des dates de la campagne
-tutti.validator.error.fishingOperation.dates.tooLong=La durée du trait dépasse 45 minutes, merci de vérifier les dates/heures du trait
+tutti.validator.error.fishingOperation.dates.wrongTime=La durée du trait dépasse 45 minutes ou est inférieure à 20 minutes, merci de vérifier les dates/heures du trait
tutti.validator.error.fishingOperation.existingKey=La clé code station/numéro de trait/date de début existe déjà
tutti.validator.error.fishingOperation.fishingOperationNumber.required=Le numéro de trait est obligatoire
tutti.validator.error.fishingOperation.fishingOperationValid.required=La validité du traît est obligatoire
1
0