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
May 2013
- 4 participants
- 180 discussions
r911 - in trunk/tutti-persistence/src/main: java/fr/ifremer/tutti/persistence/service resources
by kmorin@users.forge.codelutin.com 02 May '13
by kmorin@users.forge.codelutin.com 02 May '13
02 May '13
Author: kmorin
Date: 2013-05-02 12:32:02 +0200 (Thu, 02 May 2013)
New Revision: 911
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/911
Log:
fixes #2393 [CAMPAGNE] - Engins - Tous les engins asoci?\195?\169s aux campagnes sont retourn?\195?\169s en tant qu'engins scientifiques
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
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-05-02 10:00:47 UTC (rev 910)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-05-02 10:32:02 UTC (rev 911)
@@ -30,6 +30,7 @@
import fr.ifremer.adagio.core.dao.data.vessel.VesselExtendDao;
import fr.ifremer.adagio.core.dao.referential.StatusDao;
import fr.ifremer.adagio.core.dao.referential.gear.FishingGearExtendDao;
+import fr.ifremer.adagio.core.dao.referential.gear.GearClassification;
import fr.ifremer.adagio.core.dao.referential.location.LocationExtendDao;
import fr.ifremer.adagio.core.dao.referential.taxon.TaxonNameExtendDao;
import fr.ifremer.adagio.core.dao.referential.taxon.TaxonRefVO;
@@ -316,7 +317,7 @@
List<Gear> result = Lists.newArrayList();
while (sources.hasNext()) {
Object[] source = sources.next();
- Gear target = loadGear(source, true);
+ Gear target = loadGear(source);
result.add(target);
}
return Collections.unmodifiableList(result);
@@ -330,7 +331,7 @@
List<Gear> result = Lists.newArrayList();
while (sources.hasNext()) {
Object[] source = sources.next();
- Gear target = loadGear(source, false);
+ Gear target = loadGear(source);
result.add(target);
}
return Collections.unmodifiableList(result);
@@ -369,7 +370,7 @@
"gear",
"gearId", IntegerType.INSTANCE, gearId);
- Gear result = source == null ? null : loadGear(source, true);
+ Gear result = source == null ? null : loadGear(source);
return result;
}
@@ -902,14 +903,19 @@
return target;
}
- protected Gear loadGear(Object[] source, boolean scientificGear) {
+ protected Gear loadGear(Object[] source) {
Gear result = TuttiBeanFactory.newGear();
result.setId(String.valueOf(source[0]));
result.setLabel((String) source[1]);
result.setName((String) source[2]);
- result.setScientificGear(scientificGear);
+ GearClassification classification = (GearClassification) source[3];
+ boolean scientific = false;
+ if (classification != null) {
+ scientific = classification.getId().equals(enumeration.GEAR_CLASSIFICIATION_ID_SCIENTIFIC);
+ }
+ result.setScientificGear(scientific);
- setStatus((fr.ifremer.adagio.core.dao.referential.Status) source[3], result);
+ setStatus((fr.ifremer.adagio.core.dao.referential.Status) source[4], result);
return result;
}
Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-05-02 10:00:47 UTC (rev 910)
+++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-05-02 10:32:02 UTC (rev 911)
@@ -695,6 +695,7 @@
g.id,
g.label,
g.name,
+ g.gearClassification,
g.status AS status
FROM GearImpl g
WHERE
@@ -713,6 +714,7 @@
g.id,
g.label,
g.name,
+ g.gearClassification,
g.status AS status
FROM GearImpl g
WHERE
1
0
r910 - in trunk/tutti-ui-swing/src/main: assembly/full java/fr/ifremer/tutti/ui/swing java/fr/ifremer/tutti/ui/swing/content/db resources/i18n
by tchemit@users.forge.codelutin.com 02 May '13
by tchemit@users.forge.codelutin.com 02 May '13
02 May '13
Author: tchemit
Date: 2013-05-02 12:00:47 +0200 (Thu, 02 May 2013)
New Revision: 910
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/910
Log:
refs #2369: [IMP/EXP] - L'export de base avec suppression ne fonctionne pas
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
Modified:
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/java/fr/ifremer/tutti/ui/swing/RunTutti.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/ExportAndCleanDbAction.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat
===================================================================
--- trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat 2013-05-02 09:23:28 UTC (rev 909)
+++ trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat 2013-05-02 10:00:47 UTC (rev 910)
@@ -20,5 +20,21 @@
copy tutti.config tutti
call tutti\launch.bat --option tutti.launch.mode full --option tutti.basedir %TUTTI_BASEDIR%
if errorlevel 88 goto start
+if errorlevel 89 goto deletedb
+goto quit
+
+:deletedb
+echo "Clean database and restart"
+
+del /S/Q data\db
+del /S/Q data\dbcache
+del /S/Q data\dbconf
+rmdir data\db
+rmdir data\dbcache
+rmdir data\dbconf
+
+goto start
+
+:quit
cd %OLDDIR%
Modified: trunk/tutti-ui-swing/src/main/assembly/full/tutti.sh
===================================================================
--- trunk/tutti-ui-swing/src/main/assembly/full/tutti.sh 2013-05-02 09:23:28 UTC (rev 909)
+++ trunk/tutti-ui-swing/src/main/assembly/full/tutti.sh 2013-05-02 10:00:47 UTC (rev 910)
@@ -22,6 +22,14 @@
./tutti/launch.sh --option tutti.launch.mode full --option tutti.basedir $TUTTI_BASEDIR
exitcode=$?
+ if [ "$exitcode" -eq "89" ]; then
+ # delete db directory and restart
+ rm -rfv data/db
+ rm -rfv data/dbcache
+ rm -rfv data/dbconf
+ exitcode=88
+ fi
+
if [ ! "$exitcode" -eq "88" ]; then
# quit now!
exit $exitcode
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-05-02 09:23:28 UTC (rev 909)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-05-02 10:00:47 UTC (rev 910)
@@ -54,6 +54,8 @@
/** Logger. */
private static final Log log = LogFactory.getLog(RunTutti.class);
+ public static final int DELETE_DB_EXIT_CODE = 89;
+
public static final int UPATE_EXIT_CODE = 88;
public static final int NORMAL_EXIT_CODE = 0;
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-05-02 09:23:28 UTC (rev 909)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-05-02 10:00:47 UTC (rev 910)
@@ -1,87 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%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.persistence.config.TuttiPersistenceConfig;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To close db attached to Tutti.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class CloseDbAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(CloseDbAction.class);
-
- public CloseDbAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.MANAGE_DB);
- }
-
- String jdbcUrl;
-
- @Override
- protected void doAction() {
-
- if (log.isInfoEnabled()) {
- log.info("Will close db...");
- }
-
- jdbcUrl = TuttiPersistenceConfig.getInstance().getJdbcUrl();
-
- // clear all caches
- getContext().getPersistenceService().clearAllCaches();
-
- // set to not reload a real db
- getContext().setDbLoaded(false);
-
- // close services + repon a fake persistence service
- getHandler().reloadPersistenceService();
-
- // clean db context
- getContext().clearDbContext();
-
-// TuttiIOUtil.deleteDirectory(
-// getConfig().getServiceConfig().getPersistenceConfig().getCacheDirectory(),
-// _("tutti.dbManager.action.closeDb.deleteCache.error"));
- }
-
- @Override
- public void postSuccessAction() {
-
- sendMessage(_("tutti.flash.info.db.closed", jdbcUrl));
-
- // make sure title is reloaded
- getUI().getHandler().changeTitle();
- }
-}
\ 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-05-02 09:23:28 UTC (rev 909)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css 2013-05-02 10:00:47 UTC (rev 910)
@@ -58,16 +58,6 @@
visible: {model.isDbExist()};
}
-#openDbButton {
- actionIcon: open-db;
- text: "tutti.dbManager.action.openDb";
- i18nMnemonic: "tutti.dbManager.action.openDb.mnemonic";
- enabled: {!model.isDbLoaded()};
- _tuttiAction: {OpenDbAction.class};
- toolTipText: "tutti.dbManager.action.openDb.tip";
- _help: {"tutti.dbManager.action.openDb.help"};
-}
-
#upgradeDbButton {
actionIcon: update-referential;
text: "tutti.dbManager.action.upgradeDb";
@@ -78,16 +68,6 @@
_help: {"tutti.dbManager.action.upgradeDb.help"};
}
-#closeDbButton {
- actionIcon: close-db;
- text: "tutti.dbManager.action.closeDb";
- i18nMnemonic: "tutti.dbManager.action.closeDb.mnemonic";
- enabled: {model.isDbLoaded()};
- _tuttiAction: {CloseDbAction.class};
- toolTipText: "tutti.dbManager.action.closeDb.tip";
- _help: {"tutti.dbManager.action.closeDb.help"};
-}
-
#exportDbButton {
actionIcon: export-db;
text: "tutti.dbManager.action.exportDb";
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-05-02 09:23:28 UTC (rev 909)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.jaxx 2013-05-02 10:00:47 UTC (rev 910)
@@ -65,11 +65,9 @@
</JPanel>
<JPanel id='withDbActions' constraints='BorderLayout.SOUTH'
layout='{new GridLayout(0, 1)}'>
- <JButton id='openDbButton'/>
<JButton id='upgradeDbButton'/>
<JButton id='exportDbButton'/>
<JButton id='exportAndCleanDbButton'/>
- <JButton id='closeDbButton'/>
</JPanel>
</JPanel>
</JPanel>
\ No newline at end of file
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-05-02 09:23:28 UTC (rev 909)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java 2013-05-02 10:00:47 UTC (rev 910)
@@ -27,8 +27,6 @@
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import jaxx.runtime.validator.swing.SwingValidator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
@@ -41,10 +39,6 @@
*/
public class DbManagerUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, DbManagerUI> {
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(DbManagerUIHandler.class);
-
public DbManagerUIHandler(TuttiUIContext context, DbManagerUI ui) {
super(context, ui);
}
@@ -83,8 +77,6 @@
initUI(ui);
- ui.applyDataBinding(DbManagerUI.BINDING_OPEN_DB_BUTTON_ENABLED);
-// ui.applyDataBinding(DbManagerUI.BINDING_USE_EXTERNAL_DB_BUTTON_ENABLED);
ui.applyDataBinding(DbManagerUI.BINDING_UPGRADE_DB_BUTTON_ENABLED);
ui.applyDataBinding(DbManagerUI.BINDING_EXPORT_DB_BUTTON_ENABLED);
ui.applyDataBinding(DbManagerUI.BINDING_EXPORT_AND_CLEAN_DB_BUTTON_ENABLED);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-05-02 09:23:28 UTC (rev 909)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-05-02 10:00:47 UTC (rev 910)
@@ -27,12 +27,10 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
-import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.RunTutti;
import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -111,36 +109,32 @@
progressionModel.setMessage(_("tutti.exportDb.closeDb"));
- TuttiActionHelper.runInternalAction(getHandler(), CloseDbAction.class);
+ // clear all caches
+ getContext().getPersistenceService().clearAllCaches();
- PersistenceService persistenceService =
- getContext().getPersistenceService();
+ // set to not reload a real db
+ getContext().setDbLoaded(false);
+ // close services + repon a fake persistence service
+ getHandler().reloadPersistenceService();
+
+ // clean db context
+ getContext().clearDbContext();
+
// export db
progressionModel.increments(1);
progressionModel.setMessage(_("tutti.exportDb.createArchive", file));
- persistenceService.exportDb(file);
+ getContext().getPersistenceService().exportDb(file);
// clean files
progressionModel.increments(1);
- progressionModel.setMessage(_("tutti.exportDb.deleteFiles"));
+ progressionModel.setMessage(_("tutti.exportDb.reloadApplication"));
- TuttiPersistenceConfig persistenceConfig =
- getConfig().getServiceConfig().getPersistenceConfig();
-
- File dbDirectory = persistenceConfig.getDbDirectory();
- TuttiIOUtil.cleanDirectory(dbDirectory, _("tutti.io.directory.delete.error", dbDirectory));
-
- File attachmentDirectory = persistenceConfig.getDbAttachmentDirectory();
- TuttiIOUtil.cleanDirectory(attachmentDirectory, _("tutti.io.directory.delete.error", attachmentDirectory));
-
-// File protocolDirectory = persistenceConfig.getProtocolDirectory();
-// TuttiIOUtil.cleanDirectory(protocolDirectory, _("tutti.io.directory.delete.error", protocolDirectory));
-
- getModel().setDbExist(false);
+ // Close the application, will exit and restart application
+ RunTutti.closeTutti(getHandler(), RunTutti.DELETE_DB_EXIT_CODE);
}
@Override
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-05-02 09:23:28 UTC (rev 909)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-05-02 10:00:47 UTC (rev 910)
@@ -851,6 +851,7 @@
tutti.exportDb.createArchive=
tutti.exportDb.deleteFiles=
tutti.exportDb.openDb=
+tutti.exportDb.reloadApplication=
tutti.exportProgram.action.success=
tutti.exportProtocol.action.success=
tutti.fishingOperations.action.newFishingOperation.mnemonic=
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-05-02 09:23:28 UTC (rev 909)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-05-02 10:00:47 UTC (rev 910)
@@ -820,8 +820,8 @@
tutti.exportCruiseForSumatra.title.choose.exportFile=Exporter les captures de la campagne
tutti.exportDb.closeDb=Fermeture de la base courante
tutti.exportDb.createArchive=Création de l'archive %s
-tutti.exportDb.deleteFiles=Suppression des fichiers dans Tutti
tutti.exportDb.openDb=Réouverture de la base courante
+tutti.exportDb.reloadApplication=Redémarrage de l'application
tutti.exportProgram.action.success=La série de campagne <strong>%s</strong> a été exportée dans le fichier <strong>%s</strong>.
tutti.exportProtocol.action.success=Protocole [%1s] exporté dans le fichier <strong>%2s</strong>.
tutti.fishingOperations.action.newFishingOperation.mnemonic=N
1
0
r909 - in trunk: src/site/rst tutti-service/src/main/java/fr/ifremer/tutti/service
by tchemit@users.forge.codelutin.com 02 May '13
by tchemit@users.forge.codelutin.com 02 May '13
02 May '13
Author: tchemit
Date: 2013-05-02 11:23:28 +0200 (Thu, 02 May 2013)
New Revision: 909
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/909
Log:
fixes #2391: [IMP/EXP] Ne plus g?\195?\169rer le protocole lors d'un import/export de la base
Modified:
trunk/src/site/rst/features.rst
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
Modified: trunk/src/site/rst/features.rst
===================================================================
--- trunk/src/site/rst/features.rst 2013-05-02 08:42:16 UTC (rev 908)
+++ trunk/src/site/rst/features.rst 2013-05-02 09:23:28 UTC (rev 909)
@@ -41,10 +41,9 @@
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é.
+- 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é (mis à jour des référentiels).
-- Exporter les données de Tutti (base de travail / protocols / pièces-jointes) (sous forme d'archive zip).
+- Exporter les données de Tutti (base de travail / pièces-jointes) (sous forme d'archive zip).
- Exporter les données de Tutti puis les supprimer , permet alors de pouvoir installer une nouvelle base ou importer des données de Tutti.
- Import les données de Tuttii : permet d'importer les données d'une autre instance de Tutti précedemment exportées.
@@ -60,30 +59,27 @@
| |-- allegro.properties
| |-- allegro.script
| `-- version.appup
- |-- meas_files
- | |-- CATCH_BATCH
- | | |-- OBJ100000
- | | | |-- CATCH_BATCH-OBJ100000-100005.tnk
- | | | `-- CATCH_BATCH-OBJ100000-100006.car
- | | `-- OBJ100003
- | |-- OPERATION
- | | `-- OBJ100000
- | | |-- OPERATION-OBJ100000-100000.dat
- | | `-- OPERATION-OBJ100000-100007.dat
- | `-- SAMPLE
- | |-- OBJ100000
- | | `-- SAMPLE-OBJ100000-100002.asc
- | |-- OBJ100015
- | | `-- SAMPLE-OBJ100015-100001.dat
- | |-- OBJ100018
- | | `-- SAMPLE-OBJ100018-100002.dat
- | |-- OBJ100022
- | | `-- SAMPLE-OBJ100022-100003.dat
- | `-- OBJ100040
- | `-- SAMPLE-OBJ100040-100004.dat
- `-- protocol
- |-- 194016f4-3bea-40a2-aea2-792401b9f3c9.tuttiProtocol
- `-- 54f6cb48-2463-4212-9e9b-5849db109acc.tuttiProtocol
+ `-- meas_files
+ |-- CATCH_BATCH
+ | |-- OBJ100000
+ | | |-- CATCH_BATCH-OBJ100000-100005.tnk
+ | | `-- CATCH_BATCH-OBJ100000-100006.car
+ | `-- OBJ100003
+ |-- OPERATION
+ | `-- OBJ100000
+ | |-- OPERATION-OBJ100000-100000.dat
+ | `-- OPERATION-OBJ100000-100007.dat
+ `-- SAMPLE
+ |-- OBJ100000
+ | `-- SAMPLE-OBJ100000-100002.asc
+ |-- OBJ100015
+ | `-- SAMPLE-OBJ100015-100001.dat
+ |-- OBJ100018
+ | `-- SAMPLE-OBJ100018-100002.dat
+ |-- OBJ100022
+ | `-- SAMPLE-OBJ100022-100003.dat
+ `-- OBJ100040
+ `-- SAMPLE-OBJ100040-100004.dat
Pour le moment si vous voulez importer une base sans les autres données
(pièces-jointes / protocole), il vous suffit alors simplement de créer une
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-05-02 08:42:16 UTC (rev 908)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-05-02 09:23:28 UTC (rev 909)
@@ -149,10 +149,6 @@
new File(structureDirectory, "db"),
_("tutti.service.persistence.copyDirectory.db.error"));
- TuttiIOUtil.copyDirectory(pConfig.getProtocolDirectory(),
- new File(structureDirectory, "protocol"),
- _("tutti.service.persistence.copyDirectory.protocol.error"));
-
TuttiIOUtil.copyDirectory(pConfig.getDbAttachmentDirectory(),
new File(structureDirectory, "meas_files"),
_("tutti.service.persistence.copyDirectory.attachment.error"));
@@ -190,7 +186,6 @@
fileObject = children[0];
checkArchiveDb(file, fileObject, "db", true);
checkArchiveDb(file, fileObject, "meas_files", false);
- checkArchiveDb(file, fileObject, "protocol", false);
}
protected void checkArchiveDb(File file,
1
0
r908 - trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol
by kmorin@users.forge.codelutin.com 02 May '13
by kmorin@users.forge.codelutin.com 02 May '13
02 May '13
Author: kmorin
Date: 2013-05-02 10:42:16 +0200 (Thu, 02 May 2013)
New Revision: 908
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/908
Log:
refs #2372 [PROTOCOLE] le fichier que j'importais ne passe plus en 2.0
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java 2013-05-01 14:27:16 UTC (rev 907)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java 2013-05-02 08:42:16 UTC (rev 908)
@@ -48,6 +48,7 @@
import org.nuiton.util.beans.BinderFactory;
import org.nuiton.util.csv.Export;
import org.nuiton.util.csv.Import;
+import org.nuiton.util.csv.ImportRuntimeException;
import java.io.BufferedWriter;
import java.io.File;
@@ -265,8 +266,13 @@
IOUtils.closeQuietly(importer);
}
reader.close();
+
+ } catch (ImportRuntimeException e) {
+ throw new TuttiTechnicalException(e.getCause().getMessage(), e);
+
} catch (Exception e) {
throw new TuttiTechnicalException(_("tutti.service.protocol.import.species.error", protocol.getName(), file), e);
+
} finally {
IOUtils.closeQuietly(reader);
}
1
0
r907 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: . content
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 16:27:16 +0200 (Wed, 01 May 2013)
New Revision: 907
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/907
Log:
fixes #2383: [TECH] - Mise ?\195?\160 jour de la base : ?\195?\169crasement des donn?\195?\169es si on force la mise ?\195?\160 jour
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/content/ShowAboutAction.java
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-05-01 13:30:06 UTC (rev 906)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-05-01 14:27:16 UTC (rev 907)
@@ -146,10 +146,14 @@
dbInstalled = false;
dbUpdated = false;
} else {
- if (ApplicationUpdater.ZERO_VERSION.equals(info.oldVersion)) {
+ if (context.isDbExist()) {
+
+ // when db exists always an update
+ dbUpdated = true;
+ } else {
+
+ // when no db, then always install
dbInstalled = true;
- } else {
- dbUpdated = true;
}
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-05-01 13:30:06 UTC (rev 906)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-05-01 14:27:16 UTC (rev 907)
@@ -267,8 +267,7 @@
case DB: {
UpdateDbAction logicAction = TuttiActionHelper.createLogicAction(getHandler(), UpdateDbAction.class);
action = logicAction;
- ApplicationInfo info = versions.get(appType);
- if (ApplicationUpdater.ZERO_VERSION.equals(info.oldVersion)) {
+ if (!getContext().isDbExist()) {
// install db
action.setActionDescription(
1
0
r906 - in trunk/tutti-persistence/src: main/java/fr/ifremer/tutti/persistence main/java/fr/ifremer/tutti/persistence/service main/java/fr/ifremer/tutti/persistence/service/batch main/resources/i18n test/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 15:30:06 +0200 (Wed, 01 May 2013)
New Revision: 906
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/906
Log:
refs #2221: Rendre les donn?\195?\169es CGFS compatible avec Tutti (am?\195?\169lioration validation arbre + api)
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -25,7 +25,6 @@
*/
import com.google.common.collect.Maps;
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.adagio.core.service.technical.CacheService;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
@@ -579,12 +578,7 @@
@Override
public CatchBatch getCatchBatchFromFishingOperation(String id) throws InvalidBatchModelException {
- try {
- return catchBatchService.getCatchBatchFromFishingOperation(id);
- } catch (CatchBatchValidationException e) {
- throw new InvalidBatchModelException(
- "L'arbre d'échantillonage n'est pas compatible avec celui de Tutti.", e);
- }
+ return catchBatchService.getCatchBatchFromFishingOperation(id);
}
@Override
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -29,7 +29,6 @@
import fr.ifremer.adagio.core.dao.administration.programStrategy.Program;
import fr.ifremer.adagio.core.dao.administration.user.DepartmentImpl;
import fr.ifremer.adagio.core.dao.administration.user.PersonImpl;
-import fr.ifremer.adagio.core.dao.data.operation.FishingOperationDao;
import fr.ifremer.adagio.core.dao.data.operation.FishingOperationImpl;
import fr.ifremer.adagio.core.dao.data.sample.Sample;
import fr.ifremer.adagio.core.dao.data.sample.SampleDao;
@@ -79,9 +78,6 @@
@Autowired
protected SampleMeasurementPersistenceHelper sampleMeasurementPersistenceHelper;
- @Resource(name = "fishingOperationDao")
- protected FishingOperationDao fishingOperationDao;
-
@Resource(name = "sampleDao")
protected SampleDao sampleDao;
@@ -326,5 +322,4 @@
}
}
-
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -97,7 +97,7 @@
"allAttachment",
"objectId", IntegerType.INSTANCE, objectId,
"objectTypeCode", StringType.INSTANCE, objectType.getFieldValue()
- );
+ );
List<Attachment> result = Lists.newArrayList();
while (list.hasNext()) {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -29,7 +29,6 @@
import com.google.common.collect.Sets;
import fr.ifremer.adagio.core.dao.data.batch.Batch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
@@ -43,14 +42,12 @@
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.FlushMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
@@ -82,9 +79,6 @@
@Autowired
protected AttachmentPersistenceService attachmentPersistenceService;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
-
@Resource(name = "batchPersistenceHelper")
protected BatchPersistenceHelper batchHelper;
@@ -96,46 +90,43 @@
public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId) {
Preconditions.checkNotNull(fishingOperationId);
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
- Preconditions.checkNotNull(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
- Collection<Batch> catchBatchChils = catchBatch.getChildBatchs();
-
// Vrac / Benthos
- SortingBatch vracBenthosBatch = catchBatchDao.getSortingBatch(
- catchBatchChils,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
+ SortingBatch vracBenthosBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Vrac > Benthos > Alive Itemized",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
+ enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
);
BatchContainer<BenthosBatch> result = new BatchContainer<BenthosBatch>();
- result.setId(vracBenthosBatch.getId());
+ if (vracBenthosBatch != null) {
+ result.setId(vracBenthosBatch.getId());
- for (Batch batch : vracBenthosBatch.getChildBatchs()) {
- SortingBatch source = (SortingBatch) batch;
- ReferenceTaxon referenceTaxon = source.getReferenceTaxon();
- Preconditions.checkNotNull(referenceTaxon, "Can't have a rootBenthosBatch with a null taxon, but was for " + batch.getId());
- Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxon.getId());
+ for (Batch batch : vracBenthosBatch.getChildBatchs()) {
+ SortingBatch source = (SortingBatch) batch;
+ ReferenceTaxon referenceTaxon = source.getReferenceTaxon();
+ Preconditions.checkNotNull(referenceTaxon, "Can't have a rootBenthosBatch with a null taxon, but was for " + batch.getId());
+ Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxon.getId());
- BenthosBatch target = TuttiBeanFactory.newBenthosBatch();
- target.setSpecies(species);
- entityToBenthosBatch(source, target);
- result.addChildren(target);
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Benthos > " + target.getSpecies().getReferenceTaxonId() + " : " + target.getId());
+ BenthosBatch target = TuttiBeanFactory.newBenthosBatch();
+ target.setSpecies(species);
+ entityToBenthosBatch(source, target);
+ result.addChildren(target);
+ if (log.isInfoEnabled()) {
+ log.info("Loaded CatchBatch Vrac > Benthos > Alive Itemized > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId());
+ }
}
}
// Hors-Vrac / Benthos
- SortingBatch horsVracBenthosBatch = catchBatchDao.getSortingBatch(
- catchBatchChils,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS
+ SortingBatch horsVracBenthosBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Hors Vrac > Benthos",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS
);
if (horsVracBenthosBatch != null) {
for (Batch batch : horsVracBenthosBatch.getChildBatchs()) {
@@ -150,7 +141,7 @@
entityToBenthosBatch(source, target);
result.addChildren(target);
if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac > Benthos > " + target.getSpecies().getReferenceTaxonId() + " : " + target.getId());
+ log.info("Loaded CatchBatch Hors Vrac > Benthos > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId());
}
}
}
@@ -167,20 +158,11 @@
Preconditions.checkNotNull(bean.getFishingOperation());
Preconditions.checkNotNull(bean.getFishingOperation().getId());
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- // Load full batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(bean.getFishingOperation().getId(), false);
SortingBatch batch = SortingBatch.Factory.newInstance();
benthosBatchToEntity(bean, batch, parentBatchId, catchBatch);
- batch = catchBatchDao.createSortingBatch(batch, catchBatch);
+ bean = batchHelper.createSortingBatch(bean, catchBatch, batch);
- bean.setId(batch.getId());
-
- getCurrentSession().flush();
-
return bean;
}
@@ -189,23 +171,16 @@
Preconditions.checkNotNull(bean);
Preconditions.checkNotNull(bean.getId());
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
- Preconditions.checkNotNull(catchBatchId);
+ Integer batchId = bean.getIdAsInt();
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(batchId);
+ SortingBatch batch = batchHelper.getSortingBatchById(catchBatch, batchId);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- SortingBatch batch = catchBatchDao.getSortingBatchById(catchBatch, bean.getIdAsInt());
String parentBatchId = null;
if (bean.getParentBatch() != null) {
parentBatchId = bean.getParentBatch().getId();
}
benthosBatchToEntity(bean, batch, parentBatchId, catchBatch);
- catchBatchDao.updateSortingBatch(batch, catchBatch);
- getCurrentSession().flush();
+ batchHelper.updateSortingBatch(batch, catchBatch);
return bean;
}
@@ -214,37 +189,22 @@
public void deleteBenthosBatch(String id) {
Preconditions.checkNotNull(id);
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer batchId = Integer.valueOf(id);
- catchBatchDao.removeWithChildren(batchId);
+ batchHelper.removeWithChildren(batchId);
attachmentPersistenceService.deleteAllAttachment(
AttachementObjectTypeEnum.BATCH,
batchId);
-
- getCurrentSession().flush();
}
@Override
public void deleteBenthosSubBatch(String id) {
Preconditions.checkNotNull(id);
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
Integer benthosBatchId = Integer.valueOf(id);
- // get catch batch
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(benthosBatchId);
-
- Preconditions.checkNotNull(
- catchBatchId,
- "Could not find catchBatch for benthosBatch: " + benthosBatchId);
-
- CatchBatch catchBatch =
- catchBatchDao.loadFullTree(catchBatchId);
-
- // get species batch
- SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(benthosBatchId);
+ SortingBatch sortingBatch = batchHelper.getSortingBatchById(
catchBatch, benthosBatchId);
// get his children
@@ -260,7 +220,7 @@
if (log.isInfoEnabled()) {
log.info("Delete child [" + childBatchId + "] of species batch: " + id);
}
- catchBatchDao.removeWithChildren(childBatchId);
+ batchHelper.removeWithChildren(childBatchId);
// delete his attachment (if any)
attachmentPersistenceService.deleteAllAttachment(
@@ -268,8 +228,6 @@
childBatchId);
}
}
-
- getCurrentSession().flush();
}
@Override
@@ -279,7 +237,7 @@
Preconditions.checkNotNull(species);
Preconditions.checkNotNull(species.getReferenceTaxonId());
- catchBatchDao.setSortingBatchReferenceTaxon(batchId, species.getReferenceTaxonId());
+ batchHelper.setSortingBatchReferenceTaxon(batchId, species.getReferenceTaxonId());
}
//------------------------------------------------------------------------//
@@ -318,18 +276,15 @@
}
}
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer sortingBatchId = Integer.valueOf(benthosBatchId);
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(sortingBatchId);
if (catchBatch == null) {
return frequencies;
}
// Retrieve parent
- SortingBatch parentBatch = catchBatchDao.getSortingBatchById(catchBatch, sortingBatchId);
+ SortingBatch parentBatch = batchHelper.getSortingBatchById(catchBatch, sortingBatchId);
// Remember child ids, to remove unchanged item (see at bottom in this method)
List<Integer> notUpdatedChildIds = Lists.newArrayList();
@@ -352,13 +307,12 @@
benthosBatchFrequencyToEntity(source, target, parentBatch, rankOrder);
// Create the targeted batch, then update the source id
- catchBatchDao.createSortingBatch(target, catchBatch);
- source.setId(target.getId());
+ batchHelper.createSortingBatch(source, catchBatch, target);
}
// Existing batch
else {
- target = catchBatchDao.getSortingBatchById(catchBatch, source.getIdAsInt());
+ target = batchHelper.getSortingBatchById(catchBatch, source.getIdAsInt());
// Fill the sorting batch from the source
benthosBatchFrequencyToEntity(source, target, parentBatch, rankOrder);
@@ -372,17 +326,15 @@
// If some batchs need to be update, do it
if (batchsToUpdate.size() > 0) {
- catchBatchDao.updateSortingBatch(batchsToUpdate, catchBatch);
+ batchHelper.updateSortingBatch(batchsToUpdate, catchBatch);
}
if (notUpdatedChildIds.size() > 0) {
for (Integer batchId : notUpdatedChildIds) {
- catchBatchDao.removeWithChildren(batchId, catchBatch);
+ batchHelper.removeWithChildren(batchId, catchBatch);
}
}
- getCurrentSession().flush();
-
return Collections.unmodifiableList(frequencies);
}
@@ -416,7 +368,7 @@
if (source.getSortingMeasurements().size() == 1) {
sm = source.getSortingMeasurements().iterator().next();
} else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) {
- sm = catchBatchDao.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
+ sm = batchHelper.getInheritedSortingMeasurement(source);
}
if (sm != null) {
SampleCategoryEnum sampleCategory = enumeration.getSampleCategoryByPmfmId(sm.getPmfm().getId());
@@ -488,8 +440,6 @@
Preconditions.checkNotNull(source.getFishingOperation());
Preconditions.checkNotNull(source.getFishingOperation().getId());
- // Retrieve recorder department
- Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
@@ -537,12 +487,14 @@
if (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 = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getSampleCategoryWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
} else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -555,20 +507,21 @@
samplingRatioText = samplingRatioText.replaceAll(",", ".");
target.setSamplingRatioText(samplingRatioText);
target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight());
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// Sorting measurement
- if ((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 = source.getSampleCategoryType().getFieldValue();
// Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
- SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, recorderDepartmentId,
- source.getSampleCategoryType(), source.getSampleCategoryValue());
+ SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(
+ target,
+ source.getSampleCategoryType(),
+ source.getSampleCategoryValue());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
}
@@ -616,9 +569,6 @@
Preconditions.checkNotNull(source.getBatch());
Preconditions.checkNotNull(source.getBatch().getId());
- // Retrieve recorder department
- Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
-
Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
@@ -645,21 +595,17 @@
target.setRankOrder(rankOrder);
// Weight or SampleCategoryWeight
- if (source.getWeight() == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(
+ if (source.getWeight() != null) {
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// Sorting measurement
- if ((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 = source.getLengthStepCaracteristic().getIdAsInt();
- SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, recorderDepartmentId, pmfmId,
+ SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, pmfmId,
source.getLengthStep());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
@@ -705,26 +651,5 @@
alphanumericalValue,
qualitativeValueId);
target.setSampleCategoryValue(categoryValue);
-// if (numericalvalue != null) {
-// target.setSampleCategoryValue(numericalvalue);
-// return;
-// }
-// if (alphanumericalValue != null) {
-// target.setSampleCategoryValue(alphanumericalValue);
-// return;
-// }
-//
-// Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
-// if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
-// return;
-// }
-// CaracteristicQualitativeValue value = null;
-// for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
-// if (qualitativeValueId.equals(qv.getIdAsInt())) {
-// value = qv;
-// break;
-// }
-// }
-// target.setSampleCategoryValue(value);
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -24,8 +24,6 @@
* #L%
*/
-
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import org.springframework.transaction.annotation.Transactional;
@@ -42,9 +40,8 @@
*
* @param fishingOperationId id of the fihsing operation
* @return found catchBatch
- * @throws CatchBatchValidationException
*/
- CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException;
+ CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId);
/**
* Create the given CatchBatch and return it.
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -26,15 +26,10 @@
import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-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.CatchBatchImpl;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidator;
import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
-import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
import fr.ifremer.adagio.core.dao.data.operation.FishingOperationImpl;
import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus;
@@ -52,7 +47,6 @@
import javax.annotation.Resource;
import java.util.Collection;
-import java.util.Map;
import java.util.Set;
@Service("batchPersistenceService")
@@ -69,40 +63,20 @@
@Autowired
protected AttachmentPersistenceService attachmentPersistenceService;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
-
- @Resource(name = "scientificCruiseCatchBatchValidator")
- protected CatchBatchValidator catchBatchValidator;
-
@Resource(name = "batchPersistenceHelper")
protected BatchPersistenceHelper batchHelper;
- @Override
- public void init() {
- super.init();
- catchBatchDao.registerCatchBatchValidator(catchBatchValidator);
- }
-
- @Override
- public void close() {
- catchBatchDao.unregisterCatchBatchValidator(catchBatchValidator);
- super.close();
- }
-
//------------------------------------------------------------------------//
//-- CatchBatch methods --//
//------------------------------------------------------------------------//
@Override
- public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException {
+ public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) {
Preconditions.checkNotNull(fishingOperationId);
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
- Preconditions.checkNotNull(catchBatchId);
-
// whenever want to repair anything from Tutti
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch source = catchBatchDao.loadFullTree(catchBatchId, true, false);
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch source =
+ batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, true);
CatchBatch result = new CatchBatchBean();
result.setId(source.getId());
@@ -113,176 +87,126 @@
}
// Vrac
- SortingBatch vracBatch = catchBatchDao.getSortingBatch(
- source.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch vracBatch = batchHelper.getSortingBatch(
+ source,
+ "Vrac",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_VRAC_ID);
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac: " + vracBatch.getId());
- }
+
result.setCatchTotalSortedCarousselWeight(vracBatch.getWeight());
result.setCatchTotalSortedTremisWeight(vracBatch.getWeightBeforeSampling());
{
// Vrac > Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(
- vracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch vracSpeciesBatch = batchHelper.getSortingBatch(
+ vracBatch,
+ "Vrac > Species",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Species: " + speciesBatch.getId());
- }
+ if (vracSpeciesBatch != null) {
- result.setSpeciesTotalSortedWeight(speciesBatch.getWeight());
+ result.setSpeciesTotalSortedWeight(vracSpeciesBatch.getWeight());
- {
// Vrac > Species > Inert
- SortingBatch inertBatch = catchBatchDao.getSortingBatch(
- speciesBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch inertBatch = batchHelper.getSortingBatch(
+ vracSpeciesBatch,
+ "Vrac > Species > Inert",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
-
if (inertBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Species > Inert: " + inertBatch.getId());
- }
result.setSpeciesTotalInertWeight(inertBatch.getWeight());
}
// Vrac > Species > Alive not itemized
- SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(
- speciesBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch(
+ vracSpeciesBatch,
+ "Vrac > Species > Alive not itemized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
if (livingNotItemizedBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Species > Alive not itemized: " + livingNotItemizedBatch.getId());
- }
result.setSpeciesTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight());
}
}
// Vrac > Benthos
- SortingBatch benthosBatch = catchBatchDao.getSortingBatch(
- vracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch vracBenthosBatch = batchHelper.getSortingBatch(
+ vracBatch,
+ "Vrac > Benthos",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Benthos: " + benthosBatch.getId());
- }
+ if (vracBenthosBatch != null) {
+ result.setBenthosTotalSortedWeight(vracBenthosBatch.getWeight());
- result.setBenthosTotalSortedWeight(benthosBatch.getWeight());
-
- {
// Vrac > Benthos > Inert
- SortingBatch inertBatch = catchBatchDao.getSortingBatch(
- benthosBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch inertBatch = batchHelper.getSortingBatch(
+ vracBenthosBatch,
+ "Vrac > Benthos > Inert",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
if (inertBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Benthos > Inert: " + inertBatch.getId());
- }
result.setBenthosTotalInertWeight(inertBatch.getWeight());
}
// Vrac > Benthos > Alive no itemized
- SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(
- benthosBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch(
+ vracBenthosBatch,
+ "Vrac > Benthos > Alive not itemized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
if (livingNotItemizedBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Benthos > Alive not itemized: " + livingNotItemizedBatch.getId());
- }
result.setBenthosTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight());
}
}
-
- // TODO : Plancton...
}
// Hors Vrac
- SortingBatch horsVracBatch = catchBatchDao.getSortingBatch(
- source.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch horsVracBatch = batchHelper.getSortingBatch(
+ source,
+ "Hors Vrac",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_HORS_VRAC_ID);
+
if (horsVracBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac: " + horsVracBatch.getId());
- }
- {
- // Hors Vrac > Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- if (speciesBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac > Species: " + speciesBatch.getId());
- }
- }
+ // Hors Vrac > Species
+ batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > Species",
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- // Hors Vrac > Benthos
- SortingBatch benthosBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ // Hors Vrac > Benthos
+ batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > Benthos",
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ // Hors Vrac > MarineLitter
+ SortingBatch marineLitterBatch = batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > MarineLitter",
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
- if (benthosBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac > Benthos: " + benthosBatch.getId());
- }
- }
-
- // Hors Vrac > MarineLitter
- SortingBatch marineLitterBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
-
-
- if (marineLitterBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac > MarineLitter: " + marineLitterBatch.getId());
- }
-
- result.setMarineLitterTotalWeight(marineLitterBatch.getWeight());
- }
-
- // TODO : Plancton...
+ if (marineLitterBatch != null) {
+ result.setMarineLitterTotalWeight(marineLitterBatch.getWeight());
}
}
// Non trié
- SortingBatch unsortedBatch = catchBatchDao.getSortingBatch(
- source.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch unsortedBatch = batchHelper.getSortingBatch(
+ source,
+ "Unsorted",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_UNSORTED_ID);
if (unsortedBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Unsorted: " + unsortedBatch.getId());
- }
result.setCatchTotalRejectedWeight(unsortedBatch.getWeight());
}
@@ -298,8 +222,7 @@
fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = fr.ifremer.adagio.core.dao.data.batch.CatchBatch.Factory.newInstance();
catchBatchToEntity(bean, catchBatch);
- catchBatch = catchBatchDao.create(catchBatch);
- bean.setId(catchBatch.getId());
+ bean = batchHelper.createCatchBatch(bean, catchBatch);
// Link to fishing operation
getCurrentSession().flush();
@@ -324,13 +247,13 @@
getCurrentSession().enableFetchProfile("batch-with-childs");
getCurrentSession().setFlushMode(FlushMode.COMMIT);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.load(bean.getIdAsInt());
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = load(CatchBatchImpl.class, bean.getIdAsInt());
if (catchBatch == null) {
throw new DataRetrievalFailureException("Could not retrieve catch batch with id=" + bean.getId());
}
catchBatchToEntity(bean, catchBatch);
- catchBatchDao.update(catchBatch);
+ batchHelper.update(catchBatch);
getCurrentSession().flush();
return bean;
@@ -346,7 +269,6 @@
Preconditions.checkNotNull(source.getFishingOperation().getId());
// Retrieve recorder department
- Integer recorderDepartmentId = getRecorderDepartmentId();
// First initialization (when created)
Integer fishingOperationId = source.getFishingOperation().getIdAsInt();
@@ -364,11 +286,11 @@
}
// Total Weight
- if (source.getCatchTotalWeight() == null) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getCatchTotalWeight(), true);
+ if (source.getCatchTotalWeight() != null) {
+
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getCatchTotalWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -377,487 +299,110 @@
quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
}
- Map<Integer, SortingBatch> catchBatchChilds = getChildsMap(
- target, enumeration.PMFM_ID_SORTED_UNSORTED);
-
- // -----------------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// Vrac
- // -----------------------------------------------------------------------------
- {
- SortingBatch batch = catchBatchChilds.get(enumeration.QUALITATIVE_VRAC_ID);
- if (batch == null) {
- batch = SortingBatch.Factory.newInstance();
- target.getChildBatchs().add(batch);
- }
+ // ---------------------------------------------------------------------
+ SortingBatch vracBatch = batchHelper.getOrCreateVracBatch(
+ target,
+ source.getCatchTotalSortedCarousselWeight(),
+ source.getCatchTotalSortedTremisWeight());
- beanToEntitySortingBatch(target,
- target,
- batch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTED_UNSORTED,
- enumeration.QUALITATIVE_VRAC_ID,
- source.getCatchTotalSortedCarousselWeight(),
- source.getCatchTotalSortedTremisWeight());
- batch.setRankOrder((short) 1);
+ // ---------------------------------------------------------------------
+ // Vrac / Species
+ // ---------------------------------------------------------------------
- {
- if (batch.getChildBatchs() == null) {
- batch.setChildBatchs(Sets.<Batch>newHashSet());
- }
+ SortingBatch speciesBatch = batchHelper.getOrCreateSpeciesVracRootBatch(
+ target,
+ vracBatch,
+ source.getSpeciesTotalSortedWeight());
- Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
+ // ---------------------------------------------------------------------
+ // Vrac / Species / Alive not itemized
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateSpeciesVracAliveNotItemizeRootBatch(
+ target,
+ speciesBatch,
+ source.getSpeciesTotalLivingNotItemizedWeight());
- // -----------------------------------------------------------------------------
- // Vrac / Species
- // -----------------------------------------------------------------------------
+ // ---------------------------------------------------------------------
+ // Vrac / Species / Inert (not alive)
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateSpeciesVracInertRootBatch(
+ target,
+ speciesBatch,
+ source.getSpeciesTotalInertWeight());
- SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ // ---------------------------------------------------------------------
+ // Vrac / Species / Alive itemized
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateSpeciesVracAliveItemizeRootBatch(
+ target,
+ speciesBatch);
- if (speciesBatch == null) {
- speciesBatch = SortingBatch.Factory.newInstance();
- batch.getChildBatchs().add(speciesBatch);
- }
- beanToEntitySortingBatch(target,
- batch,
- speciesBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- source.getSpeciesTotalSortedWeight(),
- null);
- speciesBatch.setRankOrder((short) 1);
+ // ---------------------------------------------------------------------
+ // Vrac > Benthos
+ // ---------------------------------------------------------------------
+ SortingBatch benthosBatch = batchHelper.getOrCreateBenthosVracRootBatch(
+ target,
+ vracBatch,
+ source.getBenthosTotalSortedWeight());
- {
- if (speciesBatch.getChildBatchs() == null) {
- speciesBatch.setChildBatchs(Sets.<Batch>newHashSet());
- }
+ // ---------------------------------------------------------------------
+ // Vrac / Benthos / Alive not itemized
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateBenthosVracAliveNotItemizeRootBatch(
+ target,
+ benthosBatch,
+ source.getBenthosTotalLivingNotItemizedWeight());
- Map<Integer, SortingBatch> speciesBatchChilds = getChildsMap(speciesBatch, enumeration.PMFM_ID_SORTING_TYPE_2);
+ // ---------------------------------------------------------------------
+ // Vrac / Benthos / Inert (not alive)
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateBenthosVracInertRootBatch(
+ target,
+ benthosBatch,
+ source.getBenthosTotalInertWeight());
- // -----------------------------------------------------------------------------
- // Vrac / Species / Alive not itemized
- // -----------------------------------------------------------------------------
+ // ---------------------------------------------------------------------
+ // Vrac / Benthos / Alive itemized
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateBenthosVracAliveItemizeRootBatch(
+ target,
+ benthosBatch);
- SortingBatch aliveNotItemizedBatch = speciesBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
- if (aliveNotItemizedBatch == null) {
- aliveNotItemizedBatch = SortingBatch.Factory.newInstance();
- speciesBatch.getChildBatchs().add(aliveNotItemizedBatch);
- }
-
- beanToEntitySortingBatch(target,
- speciesBatch,
- aliveNotItemizedBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED,
- source.getSpeciesTotalLivingNotItemizedWeight(),
- null);
- aliveNotItemizedBatch.setRankOrder((short) 1);
-
- // -----------------------------------------------------------------------------
- // Vrac / Species / Inert (not alive)
- // -----------------------------------------------------------------------------
-
- SortingBatch inertBatch = speciesBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
- if (inertBatch == null) {
- inertBatch = SortingBatch.Factory.newInstance();
- speciesBatch.getChildBatchs().add(inertBatch);
- }
-
- beanToEntitySortingBatch(target,
- speciesBatch,
- inertBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT,
- source.getSpeciesTotalInertWeight(),
- null);
- inertBatch.setRankOrder((short) 2);
-
- // -----------------------------------------------------------------------------
- // Vrac / Species / Alive itemized
- // -----------------------------------------------------------------------------
-
- SortingBatch aliveItemizedBatch = speciesBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED);
- if (aliveItemizedBatch == null) {
- aliveItemizedBatch = SortingBatch.Factory.newInstance();
- speciesBatch.getChildBatchs().add(aliveItemizedBatch);
- }
-
- beanToEntitySortingBatch(target,
- speciesBatch,
- aliveItemizedBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED,
- null,
- null);
- aliveItemizedBatch.setRankOrder((short) 3);
- }
-
- // -----------------------------------------------------------------------------
- // Vrac > Benthos
- // -----------------------------------------------------------------------------
-
- SortingBatch benthosBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
-
- if (benthosBatch == null) {
- benthosBatch = SortingBatch.Factory.newInstance();
- batch.getChildBatchs().add(benthosBatch);
- }
- beanToEntitySortingBatch(target,
- batch,
- benthosBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
- source.getBenthosTotalSortedWeight(),
- null);
- benthosBatch.setRankOrder((short) 2);
-
- {
-
- if (benthosBatch.getChildBatchs() == null) {
- benthosBatch.setChildBatchs(Sets.<Batch>newHashSet());
- }
-
- Map<Integer, SortingBatch> benthosBatchChilds = getChildsMap(benthosBatch, enumeration.PMFM_ID_SORTING_TYPE_2);
-
- // -----------------------------------------------------------------------------
- // Vrac / Benthos / Alive not itemized
- // -----------------------------------------------------------------------------
-
- SortingBatch aliveNotItemizedBatch = benthosBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
- if (aliveNotItemizedBatch == null) {
- aliveNotItemizedBatch = SortingBatch.Factory.newInstance();
- benthosBatch.getChildBatchs().add(aliveNotItemizedBatch);
- }
-
- beanToEntitySortingBatch(target,
- benthosBatch,
- aliveNotItemizedBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED,
- source.getBenthosTotalLivingNotItemizedWeight(),
- null);
- aliveNotItemizedBatch.setRankOrder((short) 1);
-
- // -----------------------------------------------------------------------------
- // Vrac / Benthos / Inert (not alive)
- // -----------------------------------------------------------------------------
-
- SortingBatch inertBatch = benthosBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
- if (inertBatch == null) {
- inertBatch = SortingBatch.Factory.newInstance();
- benthosBatch.getChildBatchs().add(inertBatch);
- }
-
- beanToEntitySortingBatch(target,
- benthosBatch,
- inertBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT,
- source.getBenthosTotalInertWeight(),
- null);
- inertBatch.setRankOrder((short) 2);
-
- // -----------------------------------------------------------------------------
- // Vrac / Benthos / Alive itemized
- // -----------------------------------------------------------------------------
-
- SortingBatch aliveItemizedBatch = benthosBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED);
- if (aliveItemizedBatch == null) {
- aliveItemizedBatch = SortingBatch.Factory.newInstance();
- benthosBatch.getChildBatchs().add(aliveItemizedBatch);
- }
-
- beanToEntitySortingBatch(target,
- benthosBatch,
- aliveItemizedBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED,
- null,
- null);
- aliveItemizedBatch.setRankOrder((short) 3);
- }
-
- // TODO plancton
- }
- }
-
- // -----------------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// 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,
- null,
- null);
- batch.setRankOrder((short) 2);
+ // ---------------------------------------------------------------------
+ SortingBatch horsVracBatch = batchHelper.getOrCreateHorsVracBatch(target);
- {
- Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
- if (batch.getChildBatchs() == null) {
- batch.setChildBatchs(Sets.<Batch>newHashSet());
- }
- // -----------------------------------------------------------------------------
- // Hors Vrac > Species
- // -----------------------------------------------------------------------------
- {
- SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- if (speciesBatch == null) {
- speciesBatch = SortingBatch.Factory.newInstance();
- batch.getChildBatchs().add(speciesBatch);
- }
- beanToEntitySortingBatch(target,
- batch,
- speciesBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- null,
- null);
- speciesBatch.setRankOrder((short) 1);
- }
+ // ---------------------------------------------------------------------
+ // Hors Vrac > Species
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateSpeciesHorsVracRootBatch(
+ target,
+ horsVracBatch);
- // -----------------------------------------------------------------------------
- // Hors Vrac > Benthos
- // -----------------------------------------------------------------------------
- {
- SortingBatch benthosBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
- if (benthosBatch == null) {
- benthosBatch = SortingBatch.Factory.newInstance();
- batch.getChildBatchs().add(benthosBatch);
- }
- beanToEntitySortingBatch(target,
- batch,
- benthosBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
- null,
- null);
- benthosBatch.setRankOrder((short) 2);
- }
+ // ---------------------------------------------------------------------
+ // Hors Vrac > Benthos
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateBenthosHorsVracRootBatch(
+ target,
+ horsVracBatch);
- // -----------------------------------------------------------------------------
- // Hors Vrac > MarineLitter
- // -----------------------------------------------------------------------------
- {
- SortingBatch marineLitterBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
- if (marineLitterBatch == null) {
- marineLitterBatch = SortingBatch.Factory.newInstance();
- batch.getChildBatchs().add(marineLitterBatch);
- }
- beanToEntitySortingBatch(target,
- batch,
- marineLitterBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER,
- source.getMarineLitterTotalWeight(),
- null);
- marineLitterBatch.setRankOrder((short) 3);
- }
+ // ---------------------------------------------------------------------
+ // Hors Vrac > MarineLitter
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateMarineLitterRootBatch(
+ target,
+ horsVracBatch,
+ source.getMarineLitterTotalWeight());
- // TODO : plancton
- }
-
- }
-
- // -----------------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// 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);
- unsortedBatch.setRankOrder((short) 3);
- }
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateRejectedBatch(
+ target, source.getCatchTotalRejectedWeight());
- protected Map<Integer, SortingBatch> getChildsMap(Batch parentBatch, Integer pmfmId) {
- Map<Integer, SortingBatch> batchByQualitativeValueId = Maps.newHashMap();
- if (parentBatch.getChildBatchs() == null) {
- return batchByQualitativeValueId;
- }
- for (Batch childBatch : parentBatch.getChildBatchs()) {
- SortingBatch childSortingBatch = (SortingBatch) childBatch;
- SortingMeasurement sm = catchBatchDao.getSortingMeasurement((SortingBatch) childBatch, pmfmId, null, false);
- if (sm != null && sm.getQualitativeValue() != null && sm.getQualitativeValue().getId() != null) {
- batchByQualitativeValueId.put(sm.getQualitativeValue().getId(), childSortingBatch);
- }
- }
- return batchByQualitativeValueId;
}
- protected void beanToEntitySortingBatch(
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch,
- Batch parentBatch,
- SortingBatch target,
- Integer recorderDepartmentId,
- Integer sortingPmfmId,
- Integer sortingQualitativeValueId,
- Float weight,
- Float weightBeforeSampling) {
-
- Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
- Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
-
- // Create lists to store all updates, then remove not updated items
- Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet();
- if (quantificationMeasurements != null) {
- notChangedQuantificationMeasurements.addAll(quantificationMeasurements);
- }
- Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet();
- if (sortingMeasurements != null) {
- notChangedSortingMeasurements.addAll(sortingMeasurements);
- }
-
- // Some mandatory properties :
- QualityFlagImpl qualityFlag = load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED);
- target.setQualityFlag(qualityFlag);
- target.setRootBatch(rootBatch);
- target.setParentBatch(parentBatch);
- target.setExhaustiveInventory(true);
-
- // No taxon or taxon group
- target.setReferenceTaxon(null);
- target.setTaxonGroup(null);
-
- // Sorting measurement
- if (sortingPmfmId == null || sortingQualitativeValueId == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
- SortingMeasurement sm = batchHelper.setSortingMeasurement(target, recorderDepartmentId, sortingPmfmId, sortingQualitativeValueId);
- notChangedSortingMeasurements.remove(sm);
- }
-
- // Sampling Ratio
- if (weightBeforeSampling == null || weight == null) {
- target.setSamplingRatio(null);
- target.setSamplingRatioText(null);
- } else {
- String samplingRatioText = weight + "/" + weightBeforeSampling;
- samplingRatioText = samplingRatioText.replaceAll(",", ".");
- target.setSamplingRatioText(samplingRatioText);
- target.setSamplingRatio(weight / weightBeforeSampling);
- }
-
- // Weight
- if (weightBeforeSampling == null && weight == null) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else {
- Float batchReferenceWeight = weight;
- if (batchReferenceWeight == null) {
- batchReferenceWeight = weightBeforeSampling;
- }
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(
- target,
- enumeration.PMFM_ID_WEIGHT_MEASURED,
- recorderDepartmentId,
- batchReferenceWeight,
- true);
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- }
-
- // Removed not changed measurements (in sorting and quantification measurement lists)
- if (quantificationMeasurements != null) {
- quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
- }
- if (sortingMeasurements != null) {
- sortingMeasurements.removeAll(notChangedSortingMeasurements);
- }
- }
-
-// protected void beanToEntityReferenceTaxonBatch(
-// fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch,
-// Batch parentBatch,
-// SortingBatch target,
-// Integer recorderDepartmentId,
-// Integer referenceTaxonId,
-// Float weight,
-// Float sampleWeight) {
-//
-// Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
-// Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
-//
-// // Create lists to store all updates, then remove not updated items
-// Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet();
-// if (quantificationMeasurements != null) {
-// notChangedQuantificationMeasurements.addAll(quantificationMeasurements);
-// }
-// Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet();
-// if (sortingMeasurements != null) {
-// notChangedSortingMeasurements.addAll(sortingMeasurements);
-// }
-//
-// // 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 ((sampleWeight == null || weight == null)) {
-// target.setSamplingRatio(null);
-// target.setSamplingRatioText(null);
-// } else {
-// String samplingRatioText = weight + "/" + sampleWeight;
-// samplingRatioText = samplingRatioText.replaceAll(",", ".");
-// target.setSamplingRatioText(samplingRatioText);
-// target.setSamplingRatio(weight / sampleWeight);
-// }
-//
-// // Weight
-// if ((sampleWeight == null && weight == null)) {
-// // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
-// } else {
-// Float batchReferenceWeight = weight;
-// if (batchReferenceWeight == null) {
-// batchReferenceWeight = sampleWeight;
-// }
-// QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
-// enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
-// notChangedQuantificationMeasurements.remove(quantificationMeasurement);
-// }
-//
-// // Removed not changed measurements (in sorting and quantification measurement lists)
-// if (quantificationMeasurements != null) {
-// quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
-// }
-// if (sortingMeasurements != null) {
-// sortingMeasurements.removeAll(notChangedSortingMeasurements);
-// }
-// }
-
- protected Integer getRecorderDepartmentId() {
- // TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?)
- return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
- }
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -30,9 +30,7 @@
import fr.ifremer.adagio.core.dao.administration.user.DepartmentImpl;
import fr.ifremer.adagio.core.dao.administration.user.PersonImpl;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
-import fr.ifremer.adagio.core.dao.data.operation.FishingOperationDao;
import fr.ifremer.adagio.core.dao.data.operation.FishingOperationImpl;
import fr.ifremer.adagio.core.dao.data.sample.Sample;
import fr.ifremer.adagio.core.dao.data.sample.SampleDao;
@@ -83,12 +81,9 @@
@Autowired
protected SampleMeasurementPersistenceHelper sampleMeasurementPersistenceHelper;
- @Resource(name = "fishingOperationDao")
- protected FishingOperationDao fishingOperationDao;
+ @Resource(name = "batchPersistenceHelper")
+ protected BatchPersistenceHelper batchHelper;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
-
@Resource(name = "sampleDao")
protected SampleDao sampleDao;
@@ -323,20 +318,17 @@
}
protected SortingBatch getBatch(Integer operationId) {
+ Preconditions.checkNotNull(operationId);
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(operationId);
- Preconditions.checkNotNull(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(operationId.toString(), false);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
// Vrac / Species
- SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(
- catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
+ SortingBatch vracSpeciesBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Vrac > Species > Alive Itemized",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
);
Preconditions.checkNotNull(vracSpeciesBatch);
return vracSpeciesBatch;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -28,13 +28,11 @@
import com.google.common.collect.Sets;
import fr.ifremer.adagio.core.dao.data.batch.Batch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValue;
-import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
@@ -45,9 +43,7 @@
import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.FlushMode;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -72,9 +68,6 @@
@Autowired
protected AttachmentPersistenceService attachmentPersistenceService;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
-
@Resource(name = "batchPersistenceHelper")
protected BatchPersistenceHelper batchHelper;
@@ -103,32 +96,29 @@
public BatchContainer<MarineLitterBatch> getRootMarineLitterBatch(String fishingOperationId) {
Preconditions.checkNotNull(fishingOperationId);
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
- Preconditions.checkNotNull(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
// Get marine litter root batch
- SortingBatch vracMarineLitterBatch = getMarineLitterParentBatch(catchBatch);
+ SortingBatch sortingBatch = getMarineLitterParentBatch(catchBatch);
BatchContainer<MarineLitterBatch> result = new BatchContainer<MarineLitterBatch>();
- result.setId(vracMarineLitterBatch.getId());
+ if (sortingBatch != null) {
+ result.setId(sortingBatch.getId());
- for (Batch batch1 : vracMarineLitterBatch.getChildBatchs()) {
- SortingBatch source = (SortingBatch) batch1;
+ for (Batch batch1 : sortingBatch.getChildBatchs()) {
+ SortingBatch source = (SortingBatch) batch1;
- MarineLitterBatch target = TuttiBeanFactory.newMarineLitterBatch();
- entityToMarineLitterBatch(source, target);
- result.addChildren(target);
+ MarineLitterBatch target = TuttiBeanFactory.newMarineLitterBatch();
+ entityToMarineLitterBatch(source, target);
+ result.addChildren(target);
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch MarineLetter > " +
- target.getMarineLitterCategory().getName() + " / " +
- target.getMarineLitterSizeCategory().getName() + " : " +
- target.getId());
+ if (log.isInfoEnabled()) {
+ log.info("Loaded CatchBatch Hors Vrac > MarineLetter > " +
+ target.getMarineLitterCategory().getName() + " / " +
+ target.getMarineLitterSizeCategory().getName() + ": " +
+ target.getId());
+ }
}
}
@@ -144,22 +134,12 @@
Preconditions.checkNotNull(bean.getMarineLitterCategory());
Preconditions.checkNotNull(bean.getMarineLitterSizeCategory());
Preconditions.checkNotNull(bean.getNumber());
-// Preconditions.checkNotNull(bean.getWeight());
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- // Load full batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(bean.getFishingOperation().getId(), false);
SortingBatch batch = SortingBatch.Factory.newInstance();
marineLitterBatchToEntity(bean, batch, catchBatch);
- batch = catchBatchDao.createSortingBatch(batch, catchBatch);
+ bean = batchHelper.createSortingBatch(bean, catchBatch, batch);
- bean.setId(batch.getId());
-
- getCurrentSession().flush();
-
return bean;
}
@@ -167,20 +147,11 @@
public MarineLitterBatch saveMarineLitterBatch(MarineLitterBatch bean) {
Preconditions.checkNotNull(bean);
Preconditions.checkNotNull(bean.getId());
-
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
- Preconditions.checkNotNull(catchBatchId);
-
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- SortingBatch batch = catchBatchDao.getSortingBatchById(catchBatch, bean.getIdAsInt());
+ Integer batchId = bean.getIdAsInt();
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(batchId);
+ SortingBatch batch = batchHelper.getSortingBatchById(catchBatch, batchId);
marineLitterBatchToEntity(bean, batch, catchBatch);
- catchBatchDao.updateSortingBatch(batch, catchBatch);
- getCurrentSession().flush();
+ batchHelper.updateSortingBatch(batch, catchBatch);
return bean;
}
@@ -189,16 +160,11 @@
public void deleteMarineLitterBatch(String id) {
Preconditions.checkNotNull(id);
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer batchId = Integer.valueOf(id);
- catchBatchDao.removeWithChildren(batchId);
+ batchHelper.removeWithChildren(batchId);
attachmentPersistenceService.deleteAllAttachment(
- AttachementObjectTypeEnum.BATCH,
- batchId);
-
- getCurrentSession().flush();
+ AttachementObjectTypeEnum.BATCH, batchId);
}
public MarineLitterBatch entityToMarineLitterBatch(SortingBatch source,
@@ -241,9 +207,6 @@
Preconditions.checkNotNull(source.getFishingOperation());
Preconditions.checkNotNull(source.getFishingOperation().getId());
- // Retrieve recorder department
- Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
-
Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
@@ -277,41 +240,33 @@
target.setSubgroupCount(1f);
// Weight
- if (source.getWeight() == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(
+ if (source.getWeight() != null) {
+
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
target,
- enumeration.PMFM_ID_WEIGHT_MEASURED,
- recorderDepartmentId,
- source.getWeight(),
- true);
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// MarineLitterCategory
- if (source.getMarineLitterCategory() == null) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else {
- SortingMeasurement measurement = catchBatchDao.getSortingMeasurement(
+ if (source.getMarineLitterCategory() != null) {
+
+ SortingMeasurement measurement = batchHelper.setSortingMeasurement(
target,
marineLitterCategory,
- recorderDepartmentId,
- true);
- measurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterCategory().getIdAsInt()));
+ source.getMarineLitterCategory().getIdAsInt()
+ );
notChangedSortingMeasurements.remove(measurement);
}
// MarineLitterSizeCategory
- if (source.getMarineLitterSizeCategory() == null) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else {
- SortingMeasurement measurement = catchBatchDao.getSortingMeasurement(
+ if (source.getMarineLitterSizeCategory() != null) {
+
+ SortingMeasurement measurement = batchHelper.setSortingMeasurement(
target,
marineLitterSizeCategory,
- recorderDepartmentId,
- true);
- measurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterSizeCategory().getIdAsInt()));
+ source.getMarineLitterSizeCategory().getIdAsInt()
+ );
notChangedSortingMeasurements.remove(measurement);
}
@@ -345,28 +300,31 @@
Preconditions.checkNotNull(target);
- // Load existing parent and root
SortingBatch parentBatch = getMarineLitterParentBatch(catchBatch);
- // Parent Batch
-
if (parentBatch == null) {
- throw new DataIntegrityViolationException(
- "Could not retrieve parent batch, for a given marineLitterBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a MarineLitterBatch.");
+
+ SortingBatch horsVracBatch = batchHelper.getOrCreateHorsVracBatch(
+ catchBatch
+ );
+
+ parentBatch = batchHelper.getOrCreateMarineLitterRootBatch(
+ catchBatch,
+ horsVracBatch,
+ null
+ );
}
- // Parent Batch
target.setParentBatch(parentBatch);
target.setRootBatch(catchBatch);
}
protected SortingBatch getMarineLitterParentBatch(CatchBatch catchBatch) {
- SortingBatch parentBatch = catchBatchDao.getSortingBatch(
- catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID, // hors vrac
+ SortingBatch parentBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Hors Vrac > Marine Litter",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_HORS_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, // marine litter
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
return parentBatch;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -29,7 +29,6 @@
import com.google.common.collect.Sets;
import fr.ifremer.adagio.core.dao.data.batch.Batch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
@@ -49,7 +48,6 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.FlushMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
@@ -81,9 +79,6 @@
@Autowired
protected ReferentialPersistenceService referentialService;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
-
@Resource(name = "batchPersistenceHelper")
protected BatchPersistenceHelper batchHelper;
@@ -95,20 +90,15 @@
public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId) {
Preconditions.checkNotNull(fishingOperationId);
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
- Preconditions.checkNotNull(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
- Collection<Batch> catchBatchChilds = catchBatch.getChildBatchs();
// Vrac / Species
- SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(
- catchBatchChilds,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
+ SortingBatch vracSpeciesBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Vrac > Species > Alive Itemized",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
);
// container of speciesBatch is arbitraty put on vrac type (there is
@@ -128,15 +118,16 @@
result.addChildren(target);
if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Species > " + target.getSpecies().getReferenceTaxonId() + " : " + target.getId());
+ log.info("Loaded CatchBatch Vrac > Species > Alive Itemized > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId());
}
}
// Hors-Vrac / Species
- SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(
- catchBatchChilds,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ SortingBatch horsVracSpeciesBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Hors Vrac > Species",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
if (horsVracSpeciesBatch != null) {
for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) {
SortingBatch source = (SortingBatch) batch;
@@ -149,7 +140,7 @@
entityToSpeciesBatch(source, target);
result.addChildren(target);
if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac > Species > " + target.getSpecies().getReferenceTaxonId() + " : " + target.getId());
+ log.info("Loaded CatchBatch Hors Vrac > Species > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId());
}
}
}
@@ -167,20 +158,11 @@
Preconditions.checkNotNull(bean.getFishingOperation());
Preconditions.checkNotNull(bean.getFishingOperation().getId());
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- // Load full batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(bean.getFishingOperation().getId(), false);
SortingBatch batch = SortingBatch.Factory.newInstance();
speciesBatchToEntity(bean, batch, parentBatchId, catchBatch);
- batch = catchBatchDao.createSortingBatch(batch, catchBatch);
+ bean = batchHelper.createSortingBatch(bean, catchBatch, batch);
- bean.setId(batch.getId());
-
- getCurrentSession().flush();
-
return bean;
}
@@ -189,23 +171,16 @@
Preconditions.checkNotNull(bean);
Preconditions.checkNotNull(bean.getId());
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
- Preconditions.checkNotNull(catchBatchId);
+ Integer batchId = bean.getIdAsInt();
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- SortingBatch batch = catchBatchDao.getSortingBatchById(catchBatch, bean.getIdAsInt());
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(batchId);
+ SortingBatch batch = batchHelper.getSortingBatchById(catchBatch, batchId);
String parentBatchId = null;
if (bean.getParentBatch() != null) {
parentBatchId = bean.getParentBatch().getId();
}
speciesBatchToEntity(bean, batch, parentBatchId, catchBatch);
- catchBatchDao.updateSortingBatch(batch, catchBatch);
- getCurrentSession().flush();
+ batchHelper.updateSortingBatch(batch, catchBatch);
return bean;
}
@@ -214,38 +189,22 @@
public void deleteSpeciesBatch(String id) {
Preconditions.checkNotNull(id);
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer batchId = Integer.valueOf(id);
- catchBatchDao.removeWithChildren(batchId);
+ batchHelper.removeWithChildren(batchId);
attachmentPersistenceService.deleteAllAttachment(
AttachementObjectTypeEnum.BATCH,
batchId);
-
- getCurrentSession().flush();
}
@Override
public void deleteSpeciesSubBatch(String id) {
Preconditions.checkNotNull(id);
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer speciesBatchId = Integer.valueOf(id);
- // get catch batch
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(speciesBatchId);
-
- Preconditions.checkNotNull(
- catchBatchId,
- "Could not find catchBatch for speciesBatch: " + speciesBatchId);
-
- CatchBatch catchBatch =
- catchBatchDao.loadFullTree(catchBatchId);
-
- // get species batch
- SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(speciesBatchId);
+ SortingBatch sortingBatch = batchHelper.getSortingBatchById(
catchBatch, speciesBatchId);
// get his children
@@ -261,7 +220,7 @@
if (log.isInfoEnabled()) {
log.info("Delete child [" + childBatchId + "] of species batch: " + id);
}
- catchBatchDao.removeWithChildren(childBatchId);
+ batchHelper.removeWithChildren(childBatchId);
// delete his attachment (if any)
attachmentPersistenceService.deleteAllAttachment(
@@ -269,9 +228,6 @@
childBatchId);
}
}
-
-
- getCurrentSession().flush();
}
@Override
@@ -281,7 +237,7 @@
Preconditions.checkNotNull(species);
Preconditions.checkNotNull(species.getReferenceTaxonId());
- catchBatchDao.setSortingBatchReferenceTaxon(
+ batchHelper.setSortingBatchReferenceTaxon(
batchId,
species.getReferenceTaxonId());
}
@@ -295,7 +251,8 @@
String speciesBatchId) {
Preconditions.checkNotNull(speciesBatchId);
- List<SortingBatch> frequencyChilds = batchHelper.getFrequencies(speciesBatchId);
+ List<SortingBatch> frequencyChilds =
+ batchHelper.getFrequencies(speciesBatchId);
List<SpeciesBatchFrequency> results = Lists.newArrayList();
for (SortingBatch child : frequencyChilds) {
SpeciesBatchFrequency target =
@@ -331,18 +288,15 @@
}
}
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer sortingBatchId = Integer.valueOf(speciesBatchId);
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(sortingBatchId);
if (catchBatch == null) {
return notNullFrequencies;
}
// Retrieve parent
- SortingBatch parentBatch = catchBatchDao.getSortingBatchById(catchBatch, sortingBatchId);
+ SortingBatch parentBatch = batchHelper.getSortingBatchById(catchBatch, sortingBatchId);
// Remember child ids, to remove unchanged item (see at bottom in this method)
List<Integer> notUpdatedChildIds = Lists.newArrayList();
@@ -366,7 +320,7 @@
speciesBatchFrequencyToEntity(source, target, parentBatch, rankOrder);
// Create the targeted batch, then update the source id
- catchBatchDao.createSortingBatch(target, catchBatch);
+ batchHelper.createSortingBatch(source, catchBatch, target);
// push back id of created sortingBatch
source.setId(target.getId());
@@ -377,7 +331,7 @@
} else {
// Existing batch
- target = catchBatchDao.loadSortingBatch(source.getIdAsInt(), catchBatch);
+ target = batchHelper.loadSortingBatch(source.getIdAsInt(), catchBatch);
// Fill the sorting batch from the source
speciesBatchFrequencyToEntity(source, target, parentBatch, rankOrder);
@@ -397,7 +351,7 @@
if (batchsToUpdate.size() > 0) {
// update some batchs
- catchBatchDao.updateSortingBatch(batchsToUpdate, catchBatch);
+ batchHelper.updateSortingBatch(batchsToUpdate, catchBatch);
}
if (notUpdatedChildIds.size() > 0) {
@@ -408,12 +362,10 @@
if (log.isInfoEnabled()) {
log.info("Remove obsolete frequency sortingBatch: " + batchId);
}
- catchBatchDao.removeWithChildren(batchId, catchBatch);
+ batchHelper.removeWithChildren(batchId, catchBatch);
}
}
- getCurrentSession().flush();
-
return Collections.unmodifiableList(notNullFrequencies);
}
@@ -447,7 +399,7 @@
if (source.getSortingMeasurements().size() == 1) {
sm = source.getSortingMeasurements().iterator().next();
} else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) {
- sm = catchBatchDao.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
+ sm = batchHelper.getInheritedSortingMeasurement(source);
}
if (sm != null) {
SampleCategoryEnum sampleCategory = enumeration.getSampleCategoryByPmfmId(sm.getPmfm().getId());
@@ -514,15 +466,11 @@
protected void speciesBatchToEntity(SpeciesBatch source,
SortingBatch target,
String parentBatchId,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch
- ) {
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch ) {
Preconditions.checkNotNull(source.getFishingOperation());
Preconditions.checkNotNull(source.getFishingOperation().getId());
- // Retrieve recorder department
- Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
-
Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
@@ -570,12 +518,14 @@
if (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 = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getSampleCategoryWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
} else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -588,20 +538,21 @@
samplingRatioText = samplingRatioText.replaceAll(",", ".");
target.setSamplingRatioText(samplingRatioText);
target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight());
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// Sorting measurement
- if ((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 = source.getSampleCategoryType().getFieldValue();
// Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
- SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, recorderDepartmentId,
- source.getSampleCategoryType(), source.getSampleCategoryValue());
+ SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(
+ target,
+ source.getSampleCategoryType(),
+ source.getSampleCategoryValue());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
}
@@ -649,9 +600,6 @@
Preconditions.checkNotNull(source.getBatch());
Preconditions.checkNotNull(source.getBatch().getId());
- // Retrieve recorder department
- Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
-
Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
@@ -678,21 +626,17 @@
target.setRankOrder(rankOrder);
// Weight or SampleCategoryWeight
- if (source.getWeight() == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(
+ if (source.getWeight() != null) {
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// Sorting measurement
- if ((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 = source.getLengthStepCaracteristic().getIdAsInt();
- SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, recorderDepartmentId, pmfmId,
+ SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, pmfmId,
source.getLengthStep());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -26,12 +26,19 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import fr.ifremer.adagio.core.dao.data.batch.Batch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidator;
+import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
+import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
import fr.ifremer.adagio.core.dao.referential.pmfm.Pmfm;
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
+import fr.ifremer.tutti.persistence.entities.TuttiEntity;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
@@ -39,6 +46,8 @@
import fr.ifremer.tutti.persistence.service.AbstractPersistenceService;
import fr.ifremer.tutti.persistence.service.MeasurementPersistenceHelper;
import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Component;
@@ -46,7 +55,9 @@
import javax.annotation.Resource;
import java.io.Serializable;
import java.text.MessageFormat;
+import java.util.Collection;
import java.util.List;
+import java.util.Set;
/**
* Helper around batches.
@@ -57,9 +68,9 @@
@Component("batchPersistenceHelper")
public class BatchPersistenceHelper extends AbstractPersistenceService {
-// /** Logger. */
-// private static final Log log =
-// LogFactory.getLog(BatchPersistenceHelper.class);
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(BatchPersistenceHelper.class);
public static final String BATCH_PMFM_ID = "pmfmId";
@@ -69,9 +80,76 @@
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
+ @Resource(name = "scientificCruiseCatchBatchValidator")
+ protected CatchBatchValidator catchBatchValidator;
+
@Autowired
protected MeasurementPersistenceHelper measurementPersistenceHelper;
+ @Override
+ public void init() {
+ super.init();
+ catchBatchDao.registerCatchBatchValidator(catchBatchValidator);
+ }
+
+ @Override
+ public void close() {
+ catchBatchDao.unregisterCatchBatchValidator(catchBatchValidator);
+ super.close();
+ }
+
+ public fr.ifremer.tutti.persistence.entities.data.CatchBatch createCatchBatch(fr.ifremer.tutti.persistence.entities.data.CatchBatch bean, CatchBatch catchBatch) {
+ catchBatch = catchBatchDao.create(catchBatch);
+ bean.setId(catchBatch.getId());
+ return bean;
+ }
+
+ public <D extends TuttiEntity> D createSortingBatch(D bean, CatchBatch catchBatch, SortingBatch batch) {
+ batch = catchBatchDao.createSortingBatch(batch, catchBatch);
+ bean.setId(batch.getId());
+ return bean;
+ }
+
+ public void removeWithChildren(Integer batchId) {
+ catchBatchDao.removeWithChildren(batchId);
+ }
+
+ public void removeWithChildren(Integer batchId, CatchBatch parentCatchBatch) {
+ catchBatchDao.removeWithChildren(batchId, parentCatchBatch);
+ }
+
+ public void updateSortingBatch(List<SortingBatch> sortingBatchs, CatchBatch parentCatchBatch) {
+ catchBatchDao.updateSortingBatch(sortingBatchs, parentCatchBatch);
+ }
+
+ public SortingBatch loadSortingBatch(Integer sortingBatchId, CatchBatch parentCatchBatch) {
+ return catchBatchDao.loadSortingBatch(sortingBatchId, parentCatchBatch);
+ }
+
+ public void update(CatchBatch catchBatch) {
+ catchBatchDao.update(catchBatch);
+ }
+
+ public void setSortingBatchReferenceTaxon(String batchId, Integer referenceTaxonId) {
+ catchBatchDao.setSortingBatchReferenceTaxon(batchId, referenceTaxonId);
+ }
+
+ public SortingBatch getSortingBatchById(CatchBatch catchBatch, Integer sortingBatchId) {
+ return catchBatchDao.getSortingBatchById(catchBatch, sortingBatchId);
+ }
+
+ public void updateSortingBatch(SortingBatch sortingBatch, CatchBatch parentCatchBatch) {
+ catchBatchDao.updateSortingBatch(sortingBatch, parentCatchBatch);
+ }
+
+ public SortingMeasurement getInheritedSortingMeasurement(SortingBatch sortingBatch) {
+ return catchBatchDao.getInheritedSortingMeasurement(sortingBatch, enumeration.PMFM_ID_SORTED_UNSORTED);
+ }
+
+ public QuantificationMeasurement setWeightMeasurementQuantificationMeasurement(Batch batch, Float weightValue) {
+ return catchBatchDao.setQuantificationMeasurement(batch, enumeration.PMFM_ID_WEIGHT_MEASURED, getRecorderDepartmentId(), weightValue, true);
+ }
+
public List<SortingBatch> getFrequencyChilds(SortingBatch sortingBatch) {
List<SortingBatch> result = Lists.newArrayList();
@@ -87,13 +165,7 @@
public List<SortingBatch> getFrequencies(String batchId) {
Preconditions.checkNotNull(batchId);
Integer sortingBatchId = Integer.valueOf(batchId);
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- Preconditions.checkNotNull(
- catchBatchId,
- "Could not find catchBatch for batch: " + batchId);
-
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
+ CatchBatch catchBatch = getRootCatchBatchByBatchId(sortingBatchId);
SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
catchBatch, sortingBatchId);
@@ -101,33 +173,45 @@
return frequencyChilds;
}
- /**
- * Check if the given {@code sortingBatch} is a frequency one.
- * <p/>
- * We test that:
- * <ul>
- * <li>batch has exactly one measurement</li>
- * <li>the measurement pmfm is not a sample category</li>
- * </ul>
- *
- * @param sortingBatch batch to check
- * @return {@code true} if given batch is a frequency batch,
- * {@code false} otherwise.
- */
- protected boolean isFrequencyBatch(SortingBatch sortingBatch) {
- boolean result = false;
- if (sortingBatch.getSortingMeasurements().size() == 1) {
- SortingMeasurement sm
- = sortingBatch.getSortingMeasurements().iterator().next();
- Pmfm pmfm = sm.getPmfm();
- SampleCategoryEnum sampleCategoryByPmfmId =
- enumeration.getSampleCategoryByPmfmId(pmfm.getId());
- result = sampleCategoryByPmfmId == null;
+ public fr.ifremer.adagio.core.dao.data.batch.CatchBatch getRootCatchBatchByFishingOperationId(String fishingOperationId, boolean validate) {
+ Preconditions.checkNotNull(fishingOperationId);
+ Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
+ Preconditions.checkNotNull(catchBatchId);
+
+ // whenever want to repair anything from Tutti
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch result;
+
+ if (validate) {
+
+ try {
+ result = catchBatchDao.loadFullTree(catchBatchId, true, false);
+ } catch (CatchBatchValidationException e) {
+ throw new InvalidBatchModelException(
+ "L'arbre d'échantillonage n'est pas compatible avec celui de Tutti.", e);
+ }
+ } else {
+ result = catchBatchDao.loadFullTree(catchBatchId);
}
+ Preconditions.checkNotNull(result);
return result;
}
+ public fr.ifremer.adagio.core.dao.data.batch.CatchBatch getRootCatchBatchByBatchId(Integer batchId) {
+ Preconditions.checkNotNull(batchId);
+
+ Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(batchId);
+ Preconditions.checkNotNull(catchBatchId);
+
+ // whenever want to repair anything from Tutti
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch result;
+
+ result = catchBatchDao.loadFullTree(catchBatchId);
+
+ Preconditions.checkNotNull(result);
+ return result;
+ }
+
public void setBatchParents(SampleCategoryEnum sampleCategoryType,
Serializable sampleCategoryValue,
SortingBatch target,
@@ -158,17 +242,21 @@
if (enumeration.QUALITATIVE_VRAC_ID.equals(qualitativeValueId)) {
// vrac
- parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, // vrac
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // Species | Benthos
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
+ parentBatch = getSortingBatch(
+ catchBatch,
+ "Vrac > (Species | Benthos) > Alive Itemized",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, // vrac
+ enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // Species | Benthos
+ enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
);
} else if (enumeration.QUALITATIVE_HORS_VRAC_ID.equals(qualitativeValueId)) {
// hors-vrac
- parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, // hors vrac
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId // Species | Benthos
+ parentBatch = getSortingBatch(
+ catchBatch,
+ "Hors vrac > (Species|Benthos)",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, // hors vrac
+ enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId // Species | Benthos
);
} else {
@@ -201,37 +289,213 @@
return qualitativeValueId;
}
- public Integer getRecorderDepartmentId() {
- // TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?)
- return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
+ public SortingBatch getSortingBatch(Batch source,
+ String debugMessage,
+ Integer... ids) {
+
+ return getSortingBatch(source.getChildBatchs(), debugMessage, ids);
}
-// public void setMeasurement(Measurement measurement,
-// Caracteristic caracteristic,
-// Serializable value) {
-// if (caracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
-// measurement.setAlphanumericalValue((String) value);
-// } else if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
-// measurement.setNumericalValue((Float) value);
-// } else if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
-// Integer qvId;
-// if (value instanceof CaracteristicQualitativeValue) {
-// qvId = ((CaracteristicQualitativeValue) value).getIdAsInt();
-// } else if (value instanceof Integer) {
-// qvId = (Integer) value;
-// }
-// // TODO BL : not used ? => to remove
-// else {
-// qvId = Integer.valueOf(value.toString());
-// }
-// QualitativeValue qv = load(QualitativeValueImpl.class, qvId);
-// measurement.setQualitativeValue(qv);
-// }
-// }
+ public SortingBatch getSortingBatch(Collection<Batch> childs,
+ String debugMessage,
+ Integer... ids) {
+ int nbParams = ids.length / 2;
+
+ Object[] params = new Object[nbParams * 3];
+ for (int i = 0; i < nbParams; i++) {
+ Integer sortingPmfmId = ids[2 * i];
+ Integer sortingQualitativeValueId = ids[2 * i + 1];
+ params[3 * i] = BatchPersistenceHelper.BATCH_PMFM_ID;
+ params[3 * i + 1] = sortingPmfmId;
+ params[3 * i + 2] = sortingQualitativeValueId;
+ }
+ SortingBatch result = catchBatchDao.getSortingBatch(childs, params);
+ if (result != null && debugMessage != null && log.isInfoEnabled()) {
+ log.info("Loaded " + debugMessage + ": " + result.getId());
+ }
+ return result;
+ }
+
+ public SortingBatch getOrCreateVracBatch(CatchBatch batch,
+ Float weight,
+ Float weightBeforeSampling) {
+ return getOrCreate(
+ batch,
+ batch,
+ enumeration.PMFM_ID_SORTED_UNSORTED,
+ enumeration.QUALITATIVE_VRAC_ID,
+ weight,
+ weightBeforeSampling,
+ (short) 1
+ );
+ }
+
+ public SortingBatch getOrCreateSpeciesVracRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ totalWeight,
+ (short) 1
+ );
+ }
+
+ public SortingBatch getOrCreateSpeciesVracAliveNotItemizeRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED,
+ totalWeight,
+ (short) 1
+ );
+ }
+
+ public SortingBatch getOrCreateSpeciesVracInertRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT,
+ totalWeight,
+ (short) 2
+ );
+ }
+
+ public SortingBatch getOrCreateSpeciesVracAliveItemizeRootBatch(CatchBatch target,
+ SortingBatch batch) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED,
+ null,
+ (short) 3
+ );
+ }
+
+ public SortingBatch getOrCreateBenthosVracRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
+ totalWeight,
+ (short) 2
+ );
+ }
+
+ public SortingBatch getOrCreateBenthosVracAliveNotItemizeRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED,
+ totalWeight,
+ (short) 1
+ );
+ }
+
+ public SortingBatch getOrCreateBenthosVracInertRootBatch(fr.ifremer.adagio.core.dao.data.batch.CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT,
+ totalWeight,
+ (short) 2
+ );
+ }
+
+ public SortingBatch getOrCreateBenthosVracAliveItemizeRootBatch(CatchBatch target,
+ SortingBatch batch) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED,
+ null,
+ (short) 3
+ );
+ }
+
+ public SortingBatch getOrCreateHorsVracBatch(CatchBatch batch) {
+ return getOrCreate(
+ batch,
+ batch,
+ enumeration.PMFM_ID_SORTED_UNSORTED,
+ enumeration.QUALITATIVE_HORS_VRAC_ID,
+ null,
+ (short) 2
+ );
+ }
+
+ public SortingBatch getOrCreateSpeciesHorsVracRootBatch(CatchBatch target,
+ SortingBatch batch) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ null,
+ (short) 1
+ );
+ }
+
+ public SortingBatch getOrCreateBenthosHorsVracRootBatch(CatchBatch target,
+ SortingBatch batch) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
+ null,
+ (short) 2
+ );
+ }
+
+ public SortingBatch getOrCreateMarineLitterRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER,
+ totalWeight,
+ (short) 3
+ );
+ }
+
+ public SortingBatch getOrCreateRejectedBatch(CatchBatch batch,
+ Float weight) {
+
+ return getOrCreate(
+ batch,
+ batch,
+ enumeration.PMFM_ID_SORTED_UNSORTED,
+ enumeration.QUALITATIVE_UNSORTED_ID,
+ weight,
+ (short) 3
+ );
+ }
+
public SortingMeasurement setSortingMeasurement(
SortingBatch sortingBatch,
- Integer recorderDepartmentId,
SampleCategoryEnum sampleCategory,
Serializable value) {
Preconditions.checkNotNull(sampleCategory);
@@ -241,14 +505,13 @@
Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
SortingMeasurement sortingMeasurement = catchBatchDao.getSortingMeasurement(
- sortingBatch, pmfmId, recorderDepartmentId, true);
+ sortingBatch, pmfmId, getRecorderDepartmentId(), true);
measurementPersistenceHelper.setMeasurement(sortingMeasurement, caracteristic, value);
return sortingMeasurement;
}
public SortingMeasurement setSortingMeasurement(
SortingBatch sortingBatch,
- Integer recorderDepartmentId,
Integer pmfmId,
Serializable value) {
Preconditions.checkNotNull(pmfmId);
@@ -256,7 +519,7 @@
Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
SortingMeasurement sortingMeasurement = catchBatchDao.getSortingMeasurement(
- sortingBatch, pmfmId, recorderDepartmentId, true);
+ sortingBatch, pmfmId, getRecorderDepartmentId(), true);
measurementPersistenceHelper.setMeasurement(sortingMeasurement,
caracteristic,
value);
@@ -289,4 +552,155 @@
return value;
}
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected Integer getRecorderDepartmentId() {
+ // TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?)
+ return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
+ }
+
+ /**
+ * Check if the given {@code sortingBatch} is a frequency one.
+ * <p/>
+ * We test that:
+ * <ul>
+ * <li>batch has exactly one measurement</li>
+ * <li>the measurement pmfm is not a sample category</li>
+ * </ul>
+ *
+ * @param sortingBatch batch to check
+ * @return {@code true} if given batch is a frequency batch,
+ * {@code false} otherwise.
+ */
+ protected boolean isFrequencyBatch(SortingBatch sortingBatch) {
+ boolean result = false;
+ if (sortingBatch.getSortingMeasurements().size() == 1) {
+ SortingMeasurement sm
+ = sortingBatch.getSortingMeasurements().iterator().next();
+ Pmfm pmfm = sm.getPmfm();
+ SampleCategoryEnum sampleCategoryByPmfmId =
+ enumeration.getSampleCategoryByPmfmId(pmfm.getId());
+ result = sampleCategoryByPmfmId == null;
+
+ }
+ return result;
+ }
+
+ protected SortingBatch getOrCreate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch target,
+ Batch batch,
+ Integer pmfmId,
+ Integer pmfmValue,
+ Float totalWeight,
+ short rankOrder) {
+ return getOrCreate(
+ target,
+ batch,
+ pmfmId,
+ pmfmValue,
+ totalWeight,
+ null,
+ rankOrder
+ );
+ }
+
+ protected SortingBatch getOrCreate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch,
+ Batch parentBatch,
+ Integer sortingPmfmId,
+ Integer sortingQualitativeValueId,
+ Float weight,
+ Float weightBeforeSampling,
+ short rankOrder) {
+ SortingBatch result = getSortingBatch(
+ parentBatch,
+ null,
+ sortingPmfmId,
+ sortingQualitativeValueId);
+ if (result == null) {
+
+ result = SortingBatch.Factory.newInstance();
+ if (parentBatch.getChildBatchs() == null) {
+ parentBatch.setChildBatchs(Sets.<Batch>newHashSet());
+ }
+ parentBatch.getChildBatchs().add(result);
+
+// Collection<QuantificationMeasurement> quantificationMeasurements = result.getQuantificationMeasurements();
+ Collection<SortingMeasurement> sortingMeasurements = result.getSortingMeasurements();
+
+ // Create lists to store all updates, then remove not updated items
+// Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet();
+// if (quantificationMeasurements != null) {
+// notChangedQuantificationMeasurements.addAll(quantificationMeasurements);
+// }
+ Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet();
+ if (sortingMeasurements != null) {
+ notChangedSortingMeasurements.addAll(sortingMeasurements);
+ }
+
+ // Some mandatory properties :
+ QualityFlagImpl qualityFlag = load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED);
+ result.setQualityFlag(qualityFlag);
+ result.setRootBatch(rootBatch);
+ result.setParentBatch(parentBatch);
+ result.setExhaustiveInventory(true);
+
+ // No taxon or taxon group
+ result.setReferenceTaxon(null);
+ result.setTaxonGroup(null);
+
+ result.setRankOrder(rankOrder);
+
+ // Sorting measurement
+ if (sortingPmfmId != null && sortingQualitativeValueId != null) {
+ SortingMeasurement sm = setSortingMeasurement(
+ result,
+ sortingPmfmId,
+ sortingQualitativeValueId);
+ notChangedSortingMeasurements.remove(sm);
+ }
+ // Removed not changed sorting measurements
+ if (sortingMeasurements != null) {
+ sortingMeasurements.removeAll(notChangedSortingMeasurements);
+ }
+
+ catchBatchDao.createSortingBatch(result, rootBatch);
+ }
+
+ Collection<QuantificationMeasurement> quantificationMeasurements = result.getQuantificationMeasurements();
+ Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet();
+ if (quantificationMeasurements != null) {
+ notChangedQuantificationMeasurements.addAll(quantificationMeasurements);
+ }
+
+ // Sampling Ratio
+ if (weightBeforeSampling == null || weight == null) {
+ result.setSamplingRatio(null);
+ result.setSamplingRatioText(null);
+ } else {
+ String samplingRatioText = weight + "/" + weightBeforeSampling;
+ samplingRatioText = samplingRatioText.replaceAll(",", ".");
+ result.setSamplingRatioText(samplingRatioText);
+ result.setSamplingRatio(weight / weightBeforeSampling);
+ }
+
+ // Weight
+ if (weightBeforeSampling != null || weight != null) {
+ Float batchReferenceWeight = weight;
+ if (batchReferenceWeight == null) {
+ batchReferenceWeight = weightBeforeSampling;
+ }
+ QuantificationMeasurement quantificationMeasurement = setWeightMeasurementQuantificationMeasurement(
+ result,
+ batchReferenceWeight);
+ notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ }
+ // Removed not changed quantification measurements
+ if (quantificationMeasurements != null) {
+ quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
+ }
+
+ return result;
+ }
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -60,6 +60,9 @@
@Autowired
protected TuttiEnumerationFile enumeration;
+ @Autowired
+ protected BatchPersistenceHelper batchHelper;
+
@Override
public boolean isEnable(CatchBatch catchBatch) {
// Apply validation only on catch batch for fishingOperation
@@ -81,9 +84,9 @@
List<CatchBatchValidationError> errors) {
// Vrac
- SortingBatch vracBatch = catchBatchDao.getSortingBatch(
+ SortingBatch vracBatch = batchHelper.getSortingBatch(
batchs,
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ "Vrac",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_VRAC_ID);
@@ -95,18 +98,31 @@
addError(errors, n_("tutti.persistence.batch.validation.vracNotFound"));
} else {
// Vrac > Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(
- vracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch speciesBatch = batchHelper.getSortingBatch(
+ vracBatch,
+ "Vrac > Species",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+
+ // Vrac > Benthos
+ SortingBatch benthosBatch = batchHelper.getSortingBatch(
+ vracBatch,
+ "Vrac > Benthos",
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+
if (speciesBatch == null) {
- addError(errors, n_("tutti.persistence.batch.validation.vracSpeciesNotFound"));
+
+ if (benthosBatch == null) {
+ addError(errors, n_("tutti.persistence.batch.validation.vracSpeciesNotFound"));
+ } else {
+ addWarning(errors, n_("tutti.persistence.batch.validation.vracSpeciesNotFound"));
+ }
} else {
// Vrac > Species > Alive not itemized
- SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(
- speciesBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch(
+ speciesBatch,
+ "Vrac > Species > Alive not itemized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
if (livingNotItemizedBatch == null) {
@@ -114,9 +130,9 @@
}
// Vrac > Species > Inert
- SortingBatch inertBatch = catchBatchDao.getSortingBatch(
- speciesBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch inertBatch = batchHelper.getSortingBatch(
+ speciesBatch,
+ "Vrac > Species > Inert",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
if (inertBatch == null) {
@@ -124,9 +140,9 @@
}
// Vrac > Species > Alive itemized
- SortingBatch aliveItemizedBatch = catchBatchDao.getSortingBatch(
- speciesBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch aliveItemizedBatch = batchHelper.getSortingBatch(
+ speciesBatch,
+ "Vrac > Species > Alive itemized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED);
if (aliveItemizedBatch == null) {
@@ -136,20 +152,18 @@
// TODO verifier que les espèces en haut de grappe ont bien la catégorie voulue (sorted-unsorted)
}
- // Vrac > Benthos
- SortingBatch benthosBatch = catchBatchDao.getSortingBatch(
- vracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
if (benthosBatch == null) {
- addError(errors, n_("tutti.persistence.batch.validation.vracBenthosNotFound"));
+ if (speciesBatch == null) {
+ addError(errors, n_("tutti.persistence.batch.validation.vracBenthosNotFound"));
+ } else {
+ addWarning(errors, n_("tutti.persistence.batch.validation.vracBenthosNotFound"));
+ }
} else {
// Vrac > Benthos > Alive not itemized
- SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(
- benthosBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch(
+ benthosBatch,
+ "Vrac > Benthos > Alive not itemized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
if (livingNotItemizedBatch == null) {
@@ -157,9 +171,9 @@
}
// Vrac > Benthos > Inert
- SortingBatch inertBatch = catchBatchDao.getSortingBatch(
- benthosBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch inertBatch = batchHelper.getSortingBatch(
+ benthosBatch,
+ "Vrac > Benthos > Inert",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
if (inertBatch == null) {
@@ -167,31 +181,30 @@
}
// Vrac > Benthos > Alive itermized
- SortingBatch aliveItemizedBatch = catchBatchDao.getSortingBatch(
- benthosBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch aliveItemizedBatch = batchHelper.getSortingBatch(
+ benthosBatch,
+ "Vrac > Benthos > Alive itermized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED);
if (aliveItemizedBatch == null) {
addWarning(errors, n_("tutti.persistence.batch.validation.vracBenthosAliveItemizedNotFound"));
}
}
- // TODO : Plankton...
}
// Hors Vrac
- SortingBatch horsVracBatch = catchBatchDao.getSortingBatch(
+ SortingBatch horsVracBatch = batchHelper.getSortingBatch(
batchs,
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ "Hors Vrac",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_HORS_VRAC_ID);
if (horsVracBatch == null) {
- addWarning(errors, n_("tutti.persistence.batch.validation.horsVracSpeciesNotFound"));
+ addWarning(errors, n_("tutti.persistence.batch.validation.horsVracNotFound"));
} else {
// Hors Vrac > Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch speciesBatch = batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > Species",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
if (speciesBatch == null) {
@@ -199,31 +212,30 @@
}
// Hors Vrac > Benthos
- SortingBatch benthosBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch benthosBatch = batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > Benthos",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
if (benthosBatch == null) {
addWarning(errors, n_("tutti.persistence.batch.validation.horsVracBenthosNotFound"));
}
// Hors Vrac > Marine Litter
- SortingBatch marineLitterBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch marineLitterBatch = batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > Marine Litter",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
if (marineLitterBatch == null) {
addWarning(errors, n_("tutti.persistence.batch.validation.horsVracMarineLitterNotFound"));
}
- // TODO : Plankton...
}
// Unsorted
- SortingBatch unsortedBatch = catchBatchDao.getSortingBatch(
+ SortingBatch unsortedBatch = batchHelper.getSortingBatch(
batchs,
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ "Unsorted",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_UNSORTED_ID);
if (unsortedBatch == null) {
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-05-01 13:30:06 UTC (rev 906)
@@ -18,6 +18,7 @@
tutti.persistence.attachment.deleteFile.error=
tutti.persistence.batch.validation.horsVracBenthosNotFound=
tutti.persistence.batch.validation.horsVracMarineLitterNotFound=
+tutti.persistence.batch.validation.horsVracNotFound=
tutti.persistence.batch.validation.horsVracSpeciesNotFound=
tutti.persistence.batch.validation.unsortedNotFound=
tutti.persistence.batch.validation.vracBenthosAliveItemizedNotFound=
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-05-01 13:30:06 UTC (rev 906)
@@ -18,6 +18,7 @@
tutti.persistence.attachment.deleteFile.error=Erreur lors de la suppression de la pièce jointe %s
tutti.persistence.batch.validation.horsVracBenthosNotFound=Lot 'Hors Vrac > Benthos' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.horsVracMarineLitterNotFound=Lot 'Hors Vrac > Macro-déchet' non trouvé, ou configuré avec d'autres critères de classement.
+tutti.persistence.batch.validation.horsVracNotFound=Lot 'Hors Vrac' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.horsVracSpeciesNotFound=Lot 'Hors Vrac > Espèces' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.unsortedNotFound=Lot 'Hors Vrac > Espèces' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.vracBenthosAliveItemizedNotFound=Lot 'Vrac > Benthos > Vivant Trié' non trouvé, ou configuré avec d'autres critères de classement.
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -24,8 +24,8 @@
* #L%
*/
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.DatabaseResource;
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import org.junit.Before;
import org.junit.ClassRule;
@@ -68,7 +68,7 @@
assertNotNull(fishingOperation.getId());
}
- @Test(expected = CatchBatchValidationException.class)
+ @Test(expected = InvalidBatchModelException.class)
public void getCatchBatchFromFishingOperation() throws Exception {
//TODO-TC Change test when data will be Tutti-aware
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -24,8 +24,8 @@
* #L%
*/
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.DatabaseResource;
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
@@ -188,7 +188,7 @@
CatchBatch reloadedCatchBatch = null;
try {
reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
- } catch (CatchBatchValidationException e) {
+ } catch (InvalidBatchModelException e) {
Assert.fail(e.getMessage());
}
assertCatchBatch(createdCatchBatch, reloadedCatchBatch, true);
@@ -205,7 +205,7 @@
CatchBatch reloadedCatchBatch = null;
try {
reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
- } catch (CatchBatchValidationException e) {
+ } catch (InvalidBatchModelException e) {
Assert.fail(e.getMessage());
}
assertCatchBatch(savedCatchBatch, reloadedCatchBatch, true);
1
0
r905 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 15:21:10 +0200 (Wed, 01 May 2013)
New Revision: 905
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/905
Log:
fixes #2389: [TECH] Ne pas supprimer le r?\195?\169pertoire des protocoles lors de l'action Exporter et fermer
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-05-01 13:18:36 UTC (rev 904)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-05-01 13:21:10 UTC (rev 905)
@@ -111,7 +111,6 @@
progressionModel.setMessage(_("tutti.exportDb.closeDb"));
-
TuttiActionHelper.runInternalAction(getHandler(), CloseDbAction.class);
PersistenceService persistenceService =
@@ -138,8 +137,8 @@
File attachmentDirectory = persistenceConfig.getDbAttachmentDirectory();
TuttiIOUtil.cleanDirectory(attachmentDirectory, _("tutti.io.directory.delete.error", attachmentDirectory));
- File protocolDirectory = persistenceConfig.getProtocolDirectory();
- TuttiIOUtil.cleanDirectory(protocolDirectory, _("tutti.io.directory.delete.error", protocolDirectory));
+// File protocolDirectory = persistenceConfig.getProtocolDirectory();
+// TuttiIOUtil.cleanDirectory(protocolDirectory, _("tutti.io.directory.delete.error", protocolDirectory));
getModel().setDbExist(false);
}
1
0
r904 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 15:18:36 +0200 (Wed, 01 May 2013)
New Revision: 904
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/904
Log:
refs #2383: [TECH] - Mise ?\195?\160 jour de la base : ?\195?\169crasement des donn?\195?\169es si on force la mise ?\195?\160 jour
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
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-05-01 13:17:24 UTC (rev 903)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-05-01 13:18:36 UTC (rev 904)
@@ -41,7 +41,6 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.Version;
import org.nuiton.util.updater.ApplicationInfo;
import org.nuiton.util.updater.ApplicationUpdater;
import org.nuiton.util.updater.ApplicationUpdaterCallback;
@@ -161,10 +160,10 @@
public void startUpdate(ApplicationInfo info) {
if (UpdateType.DB.name().toLowerCase().equals(info.name)) {
- if (Version.VZERO.toString().equals(info.oldVersion)) {
+ if (dbInstalled) {
progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.installation", info.newVersion));
- } else {
+ } else if (dbUpdated) {
progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.update", info.newVersion));
}
}
@@ -362,12 +361,12 @@
persistenceConfig.generateExternalDbFiles(true);
- if (ApplicationUpdater.ZERO_VERSION.equals(info.oldVersion)) {
+ if (dbInstalled) {
// first database, just copy it to correct directory
prepareFirstDatabase(info);
- } else {
+ } else if (dbUpdated) {
// launch a referential synchronize operation
synchronizetDatabase(info);
1
0
r903 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 15:17:24 +0200 (Wed, 01 May 2013)
New Revision: 903
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/903
Log:
refs #2369: [IMP/EXP] - L'export de base avec suppression ne fonctionne pas
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-05-01 13:16:06 UTC (rev 902)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-05-01 13:17:24 UTC (rev 903)
@@ -24,7 +24,6 @@
* #L%
*/
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
@@ -72,9 +71,9 @@
// clean db context
getContext().clearDbContext();
- TuttiIOUtil.deleteDirectory(
- getConfig().getServiceConfig().getPersistenceConfig().getCacheDirectory(),
- _("tutti.dbManager.action.closeDb.deleteCache.error"));
+// TuttiIOUtil.deleteDirectory(
+// getConfig().getServiceConfig().getPersistenceConfig().getCacheDirectory(),
+// _("tutti.dbManager.action.closeDb.deleteCache.error"));
}
@Override
1
0
r902 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 15:16:06 +0200 (Wed, 01 May 2013)
New Revision: 902
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/902
Log:
improve NoDbImpl implementation
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-04-30 20:56:38 UTC (rev 901)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-05-01 13:16:06 UTC (rev 902)
@@ -68,498 +68,498 @@
@Override
public void clearAllCaches() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllProgramZone() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllCountry() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllHarbour() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllFishingOperationStrata(String zoneId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllFishingOperationSubStrata(String zoneId, String strataId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllFishingOperationLocation(String zoneId, String strataId, String subStrataId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Vessel> getAllScientificVessel() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Vessel> getAllFishingVessel() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Species> getAllSpecies() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Species> getAllReferentSpecies() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Species> getAllSpecies(TuttiProtocol protocol) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Species> getAllReferentSpecies(TuttiProtocol protocol) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Species getSpeciesByReferenceTaxonIdWithVernacularCode(Integer referenceTaxonId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Caracteristic> getAllCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Caracteristic> getAllNumericCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getSizeCategoryCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getSexCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getSortedUnsortedCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getMaturityCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getAgeCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getMarineLitterCategoryCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getMarineLitterSizeCategoryCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getVerticalOpeningCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getHorizontalOpeningWingCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getHorizontalOpeningDoorCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getDeadOrAliveCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getSampleIdCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getOtolitheIdCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getPmfmIdCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getWeightMeasuredCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public boolean isTemporary(TuttiReferentialEntity entity) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Gear> getAllScientificGear() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Gear> getAllFishingGear() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Person> getAllPerson() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Person getPerson(Integer personId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Gear getGear(Integer gearCode) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Vessel getVessel(String vesselCode) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Species> importTemporarySpecies(List<Species> species) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Vessel> importTemporaryVessel(List<Vessel> vessels) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Person> importTemporaryPerson(List<Person> persons) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Gear> importTemporaryGear(List<Gear> gears) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<ObjectType> getAllObjectType() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public ObjectType getObjectType(String objectTypeCode) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Program> getAllProgram() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Program getProgram(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Program createProgram(Program bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Program saveProgram(Program bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Cruise> getAllCruise(String programId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Cruise getCruise(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Cruise createCruise(Cruise bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Cruise saveCruise(Cruise bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<String> getAllProtocolNames() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiProtocol> getAllProtocol() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public boolean isProtocolExist(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public TuttiProtocol getProtocol(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public TuttiProtocol createProtocol(TuttiProtocol bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public TuttiProtocol saveProtocol(TuttiProtocol bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteProtocol(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<FishingOperation> getAllFishingOperation(String cruiseId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public FishingOperation getFishingOperation(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public FishingOperation createFishingOperation(FishingOperation bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public FishingOperation saveFishingOperation(FishingOperation bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public CatchBatch getCatchBatchFromFishingOperation(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public CatchBatch createCatchBatch(CatchBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public CatchBatch saveCatchBatch(CatchBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public SpeciesBatch saveSpeciesBatch(SpeciesBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteSpeciesBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteSpeciesSubBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void changeSpeciesBatchSpecies(String batchId, Species species) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String speciesBatchId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(String speciesBatchId, List<SpeciesBatchFrequency> frequencies) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public BenthosBatch saveBenthosBatch(BenthosBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteBenthosBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteBenthosSubBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void changeBenthosBatchSpecies(String batchId, Species species) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<BenthosBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId, List<BenthosBatchFrequency> frequencies) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deletePlanktonBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public BatchContainer<MarineLitterBatch> getRootMarineLitterBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public MarineLitterBatch createMarineLitterBatch(MarineLitterBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public MarineLitterBatch saveMarineLitterBatch(MarineLitterBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteMarineLitterBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public AccidentalBatch createAccidentalBatch(AccidentalBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public AccidentalBatch saveAccidentalBatch(AccidentalBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteAccidentalBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Attachment> getAllAttachments(AttachementObjectTypeEnum objectType,
Integer objectId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public File getAttachmentFile(String attachmentId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Attachment createAttachment(Attachment attachment, File file) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Attachment saveAttachment(Attachment attachment) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteAttachment(String attachmentId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
//------------------------------------------------------------------------//
@@ -568,22 +568,22 @@
@Override
public List<IndividualObservationBatch> getAllIndividualObservationBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public IndividualObservationBatch createIndividualObservationBatch(IndividualObservationBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public IndividualObservationBatch saveIndividualObservationBatch(IndividualObservationBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteIndividualObservationBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
@@ -593,4 +593,8 @@
@Override
public void close() throws IOException {
}
+
+ protected RuntimeException notImplemented() {
+ return new RuntimeException("method not implemented");
+ }
}
1
0