Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- 4058 discussions
r1377 - in trunk: . tutti-persistence tutti-service tutti-ui-swing
by maven-release@users.forge.codelutin.com 21 Nov '13
by maven-release@users.forge.codelutin.com 21 Nov '13
21 Nov '13
Author: maven-release
Date: 2013-11-21 17:48:42 +0100 (Thu, 21 Nov 2013)
New Revision: 1377
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1377
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/pom.xml
trunk/tutti-persistence/pom.xml
trunk/tutti-service/pom.xml
trunk/tutti-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-11-21 16:48:33 UTC (rev 1376)
+++ trunk/pom.xml 2013-11-21 16:48:42 UTC (rev 1377)
@@ -32,7 +32,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>3.0-rc-1</version>
+ <version>3.0-rc-2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Tutti</name>
@@ -86,12 +86,12 @@
</modules>
<scm>
- <url>http://svn.forge.codelutin.com/svn/tutti/tags/tutti-3.0-rc-1</url>
+ <url>http://svn.forge.codelutin.com/svn/tutti/trunk</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-3.0-rc-1
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-3.0-rc-1
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
</developerConnection>
</scm>
<distributionManagement>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-11-21 16:48:33 UTC (rev 1376)
+++ trunk/tutti-persistence/pom.xml 2013-11-21 16:48:42 UTC (rev 1377)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>3.0-rc-1</version>
+ <version>3.0-rc-2-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-11-21 16:48:33 UTC (rev 1376)
+++ trunk/tutti-service/pom.xml 2013-11-21 16:48:42 UTC (rev 1377)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>3.0-rc-1</version>
+ <version>3.0-rc-2-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-11-21 16:48:33 UTC (rev 1376)
+++ trunk/tutti-ui-swing/pom.xml 2013-11-21 16:48:42 UTC (rev 1377)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>3.0-rc-1</version>
+ <version>3.0-rc-2-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
1
0
Author: maven-release
Date: 2013-11-21 17:48:33 +0100 (Thu, 21 Nov 2013)
New Revision: 1376
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1376
Log:
[maven-release-plugin] copy for tag tutti-3.0-rc-1
Added:
tags/tutti-3.0-rc-1/
1
0
r1375 - in trunk: . tutti-persistence tutti-service tutti-ui-swing
by maven-release@users.forge.codelutin.com 21 Nov '13
by maven-release@users.forge.codelutin.com 21 Nov '13
21 Nov '13
Author: maven-release
Date: 2013-11-21 17:48:25 +0100 (Thu, 21 Nov 2013)
New Revision: 1375
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1375
Log:
[maven-release-plugin] prepare release tutti-3.0-rc-1
Modified:
trunk/pom.xml
trunk/tutti-persistence/pom.xml
trunk/tutti-service/pom.xml
trunk/tutti-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-11-21 16:46:18 UTC (rev 1374)
+++ trunk/pom.xml 2013-11-21 16:48:25 UTC (rev 1375)
@@ -32,7 +32,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>3.0-rc-1-SNAPSHOT</version>
+ <version>3.0-rc-1</version>
<packaging>pom</packaging>
<name>Tutti</name>
@@ -86,12 +86,12 @@
</modules>
<scm>
- <url>http://svn.forge.codelutin.com/svn/tutti/trunk</url>
+ <url>http://svn.forge.codelutin.com/svn/tutti/tags/tutti-3.0-rc-1</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-3.0-rc-1
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-3.0-rc-1
</developerConnection>
</scm>
<distributionManagement>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-11-21 16:46:18 UTC (rev 1374)
+++ trunk/tutti-persistence/pom.xml 2013-11-21 16:48:25 UTC (rev 1375)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>3.0-rc-1-SNAPSHOT</version>
+ <version>3.0-rc-1</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-11-21 16:46:18 UTC (rev 1374)
+++ trunk/tutti-service/pom.xml 2013-11-21 16:48:25 UTC (rev 1375)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>3.0-rc-1-SNAPSHOT</version>
+ <version>3.0-rc-1</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-11-21 16:46:18 UTC (rev 1374)
+++ trunk/tutti-ui-swing/pom.xml 2013-11-21 16:48:25 UTC (rev 1375)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>3.0-rc-1-SNAPSHOT</version>
+ <version>3.0-rc-1</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
1
0
r1374 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content
by tchemit@users.forge.codelutin.com 21 Nov '13
by tchemit@users.forge.codelutin.com 21 Nov '13
21 Nov '13
Author: tchemit
Date: 2013-11-21 17:46:18 +0100 (Thu, 21 Nov 2013)
New Revision: 1374
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1374
Log:
hide report action
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-11-21 16:31:54 UTC (rev 1373)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-11-21 16:46:18 UTC (rev 1374)
@@ -47,7 +47,6 @@
import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI;
-import fr.ifremer.tutti.ui.swing.content.report.ReportUI;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.CloseableUI;
import fr.ifremer.tutti.ui.swing.util.RemoveablePropertyChangeListener;
@@ -469,12 +468,12 @@
icon = ui.getMenuActionValidateCatches().getIcon();
break;
- case REPORT:
-
- screenUI = new ReportUI(ui);
- screenTitle = _("tutti.report.title");
- icon = ui.getMenuFileReport().getIcon();
- break;
+// case REPORT:
+//
+// screenUI = new ReportUI(ui);
+// screenTitle = _("tutti.report.title");
+// icon = ui.getMenuFileReport().getIcon();
+// break;
}
JButton showHelp = ui.getShowHelp();
1
0
r1373 - in trunk: tutti-persistence/src/license tutti-service/src/license
by tchemit@users.forge.codelutin.com 21 Nov '13
by tchemit@users.forge.codelutin.com 21 Nov '13
21 Nov '13
Author: tchemit
Date: 2013-11-21 17:31:54 +0100 (Thu, 21 Nov 2013)
New Revision: 1373
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1373
Log:
fix third parties
Modified:
trunk/tutti-persistence/src/license/THIRD-PARTY.properties
trunk/tutti-service/src/license/THIRD-PARTY.properties
Modified: trunk/tutti-persistence/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/tutti-persistence/src/license/THIRD-PARTY.properties 2013-11-21 16:31:32 UTC (rev 1372)
+++ trunk/tutti-persistence/src/license/THIRD-PARTY.properties 2013-11-21 16:31:54 UTC (rev 1373)
@@ -22,29 +22,9 @@
# Please fill the missing licenses for dependencies :
#
#
-#Mon May 27 20:19:31 CEST 2013
+#Thu Nov 21 17:08:16 CET 2013
antlr--antlr--2.7.6=BSD License
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=BSD License
javax.persistence--persistence-api--1.0.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-org.andromda--andromda-core--3.3.1=BSD License
-org.andromda--andromda-utils--3.3.1=BSD License
-org.andromda.cartridges--andromda-hibernate-cartridge--3.3.1=BSD License
-org.andromda.cartridges--andromda-java-cartridge--3.3.1=BSD License
-org.andromda.cartridges--andromda-spring-cartridge--3.3.1=BSD License
-org.andromda.metafacades--andromda-metafacades-uml--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-common--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-datatype--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-meta--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-persistence--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-presentation--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-process--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-screen--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-service--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-webservice--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-xml--3.3.1=BSD License
-org.andromda.translationlibraries--andromda-ocl-translation-core--3.3.1=BSD License
-org.andromda.translationlibraries--andromda-ocl-validation-library--3.3.1=BSD License
-xalan--xalan--2.7.0=The Apache Software License, Version 2.0
-xerces--xercesImpl--2.6.0=The Apache Software License, Version 2.0
Modified: trunk/tutti-service/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/tutti-service/src/license/THIRD-PARTY.properties 2013-11-21 16:31:32 UTC (rev 1372)
+++ trunk/tutti-service/src/license/THIRD-PARTY.properties 2013-11-21 16:31:54 UTC (rev 1373)
@@ -21,7 +21,6 @@
# - MPL 1.1
# - New BSD License
# - Public Domain
-# - The AndroMDA Project
# - The Apache Software License, Version 2.0
# - The MIT License
# - license.txt
@@ -29,30 +28,9 @@
# Please fill the missing licenses for dependencies :
#
#
-#Thu Oct 31 15:46:39 CET 2013
+#Thu Nov 21 17:08:17 CET 2013
antlr--antlr--2.7.6=BSD License
-commons-cli--commons-cli--1.0=The Apache Software License, Version 2.0
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=BSD License
javax.persistence--persistence-api--1.0.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-org.andromda--andromda-core--3.3.1=BSD License
-org.andromda--andromda-utils--3.3.1=BSD License
-org.andromda.cartridges--andromda-hibernate-cartridge--3.3.1=BSD License
-org.andromda.cartridges--andromda-java-cartridge--3.3.1=BSD License
-org.andromda.cartridges--andromda-spring-cartridge--3.3.1=BSD License
-org.andromda.metafacades--andromda-metafacades-uml--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-common--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-datatype--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-meta--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-persistence--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-presentation--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-process--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-screen--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-service--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-webservice--3.3.1=BSD License
-org.andromda.profiles.emf.uml2--andromda-profile-xml--3.3.1=BSD License
-org.andromda.translationlibraries--andromda-ocl-translation-core--3.3.1=BSD License
-org.andromda.translationlibraries--andromda-ocl-validation-library--3.3.1=BSD License
-xalan--xalan--2.7.0=The Apache Software License, Version 2.0
-xerces--xercesImpl--2.6.0=The Apache Software License, Version 2.0
1
0
r1372 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content
by tchemit@users.forge.codelutin.com 21 Nov '13
by tchemit@users.forge.codelutin.com 21 Nov '13
21 Nov '13
Author: tchemit
Date: 2013-11-21 17:31:32 +0100 (Thu, 21 Nov 2013)
New Revision: 1372
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1372
Log:
hide report action
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css 2013-11-21 16:09:10 UTC (rev 1371)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css 2013-11-21 16:31:32 UTC (rev 1372)
@@ -32,6 +32,7 @@
title: "tutti.main.title.applicationName";
defaultCloseOperation: {JFrame.DO_NOTHING_ON_CLOSE};
iconImage:{SwingUtil.createImageIcon("allegro_32.png").getImage()};
+ iconImage:{SwingUtil.createImageIcon("allegro_32.png").getImage()};
}
#menuFile {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx 2013-11-21 16:09:10 UTC (rev 1371)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx 2013-11-21 16:31:32 UTC (rev 1372)
@@ -70,9 +70,9 @@
<JMenuItem id='menuFileUpdateReport'/>
<JSeparator/>
<JMenuItem id='menuFileManageDb'/>
+ <!--<JSeparator/>-->
+ <!--<JMenuItem id='menuFileReport'/>-->
<JSeparator/>
- <JMenuItem id='menuFileReport'/>
- <JSeparator/>
<JMenuItem id='menuFileExit'/>
</JMenu>
1
0
21 Nov '13
Author: tchemit
Date: 2013-11-21 17:09:10 +0100 (Thu, 21 Nov 2013)
New Revision: 1371
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1371
Log:
- update to version 3.0-rc-1
- round number in sumatra export
- prepare release
Added:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java
Removed:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java
Modified:
trunk/pom.xml
trunk/tutti-persistence/pom.xml
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
trunk/tutti-service/pom.xml
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java
trunk/tutti-ui-swing/pom.xml
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/pom.xml 2013-11-21 16:09:10 UTC (rev 1371)
@@ -32,7 +32,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.10-SNAPSHOT</version>
+ <version>3.0-rc-1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Tutti</name>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-persistence/pom.xml 2013-11-21 16:09:10 UTC (rev 1371)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.10-SNAPSHOT</version>
+ <version>3.0-rc-1-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -337,7 +337,7 @@
*
* @param value the float to round.
* @return the rounded value
- * @since 2.10
+ * @since 3.0-rc-1
*/
public static float roundKiloGram(float value) {
BigDecimal sumB = new BigDecimal(value);
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-service/pom.xml 2013-11-21 16:09:10 UTC (rev 1371)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.10-SNAPSHOT</version>
+ <version>3.0-rc-1-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -1,13 +1,36 @@
package fr.ifremer.tutti.service.export;
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.SpeciesAbleBatch;
/**
* To store a species or batch entry within his speices informations,
- * his sorted weight, total weight and percentage amoong the total catch
- * weight.
+ * his sorted weight, total weight and optional his total number.
*
- * @since 2.10
+ * @since 3.0-rc-1
*/
public class ExportBatchEntry {
Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java (from rev 1370, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -0,0 +1,362 @@
+package fr.ifremer.tutti.service.export;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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 com.google.common.base.Predicate;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.catches.WeightComputingService;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Contains the global context for a catch export.
+ * <p/>
+ * Created on 11/21/13.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 3.0-rc-1
+ */
+public class ExportCatchContext {
+
+ final FishingOperation fishingOperation;
+
+ final CatchBatch catchBatch;
+
+ final BatchContainer<SpeciesBatch> rootSpeciesBatch;
+
+ final BatchContainer<BenthosBatch> rootBenthosBatch;
+
+ final BatchContainer<MarineLitterBatch> marineLitterBatches;
+
+ final Predicate<SpeciesAbleBatch> vracPredicate;
+
+ public static ExportCatchContext newExportContext(PersistenceService persistenceService,
+ WeightComputingService weightComputingService,
+ String fishingOperationId) {
+
+ FishingOperation fishingOperation =
+ persistenceService.getFishingOperation(fishingOperationId);
+
+ CatchBatch catchBatch =
+ persistenceService.getCatchBatchFromFishingOperation(fishingOperationId);
+
+ BatchContainer<SpeciesBatch> rootSpeciesBatch =
+ weightComputingService.getComputedSpeciesBatches(fishingOperationId);
+
+ BatchContainer<BenthosBatch> rootBenthosBatch =
+ weightComputingService.getComputedBenthosBatches(fishingOperationId);
+
+ BatchContainer<MarineLitterBatch> marineLitterBatches =
+ weightComputingService.getComputedMarineLitterBatches(
+ fishingOperationId,
+ catchBatch.getMarineLitterTotalWeight());
+ weightComputingService.computeCatchBatchWeights(catchBatch,
+ rootSpeciesBatch,
+ rootBenthosBatch,
+ marineLitterBatches);
+
+ Predicate<SpeciesAbleBatch> vracPredicate = persistenceService.getVracBatchPredicate();
+
+ ExportCatchContext result = new ExportCatchContext(vracPredicate,
+ fishingOperation,
+ catchBatch,
+ rootSpeciesBatch,
+ rootBenthosBatch,
+ marineLitterBatches);
+ return result;
+
+ }
+
+ private ExportCatchContext(Predicate<SpeciesAbleBatch> vracPredicate,
+ FishingOperation fishingOperation,
+ CatchBatch catchBatch,
+ BatchContainer<SpeciesBatch> rootSpeciesBatch,
+ BatchContainer<BenthosBatch> rootBenthosBatch,
+ BatchContainer<MarineLitterBatch> marineLitterBatches) {
+ this.vracPredicate = vracPredicate;
+ this.fishingOperation = fishingOperation;
+ this.catchBatch = catchBatch;
+ this.rootSpeciesBatch = rootSpeciesBatch;
+ this.rootBenthosBatch = rootBenthosBatch;
+ this.marineLitterBatches = marineLitterBatches;
+ }
+
+ public FishingOperation getFishingOperation() {
+ return fishingOperation;
+ }
+
+ public float getCatchTotalWeight() {
+ float result = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getCatchTotalWeight(),
+ catchBatch.getCatchTotalComputedWeight());
+ return result;
+ }
+
+ public float getCatchTotalSortedWeight() {
+ return catchBatch.getSpeciesTotalSampleSortedComputedWeight() +
+ catchBatch.getBenthosTotalSampleSortedComputedWeight();
+ }
+
+ public boolean withSpeciesBatches() {
+ return rootSpeciesBatch != null && !rootSpeciesBatch.isEmptyChildren();
+ }
+
+ public boolean withBenthosBatches() {
+ return rootBenthosBatch != null && !rootBenthosBatch.isEmptyChildren();
+ }
+
+ public List<ExportBatchEntry> getSpeciesBatchEntry(boolean computeNumber) {
+ List<ExportBatchEntry> catchList = Lists.newArrayList();
+
+ if (withSpeciesBatches()) {
+
+ Map<Species, ExportBatchEntry> catches = Maps.newLinkedHashMap();
+
+ // ratio total species weight / total sorted sampled species weight
+ float rate = getSpeciesElevationRate();
+
+ List<SpeciesBatch> batches = rootSpeciesBatch.getChildren();
+ for (SpeciesBatch batch : batches) {
+
+ createExportBatchCatch(
+ batch,
+ catches,
+ rate,
+ computeNumber);
+ }
+ catchList.addAll(catches.values());
+ }
+ return catchList;
+ }
+
+ public List<ExportBatchEntry> getBenthosBatchEntry(boolean computeNumber) {
+ List<ExportBatchEntry> catchList = Lists.newArrayList();
+
+ if (withBenthosBatches()) {
+
+ Map<Species, ExportBatchEntry> catches = Maps.newLinkedHashMap();
+
+ // ratio total species weight / total sorted sampled species weight
+ float rate = getBenthosElevationRate();
+
+ List<BenthosBatch> batches = rootBenthosBatch.getChildren();
+ for (BenthosBatch batch : batches) {
+
+ createExportBatchCatch(
+ batch,
+ catches,
+ rate,
+ computeNumber);
+ }
+
+ catchList.addAll(catches.values());
+ }
+ return catchList;
+ }
+
+ public ExportBatchEntry getInertAndLivingNotItemizedCatch() {
+
+ ExportBatchEntry result = new ExportBatchEntry(null);
+
+ float speciesRatio = getSpeciesElevationRate();
+ float benthosRatio = getBenthosElevationRate();
+
+ Float speciesInterWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalInertWeight(),
+ catchBatch.getSpeciesTotalInertComputedWeight());
+
+ if (speciesInterWeight != null) {
+ result.addSortedWeight(speciesInterWeight);
+ result.addTotalWeight(speciesInterWeight * speciesRatio);
+ }
+
+ Float speciesLivingNotItemizedWeigth = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
+ catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
+
+ if (speciesLivingNotItemizedWeigth != null) {
+ result.addSortedWeight(speciesLivingNotItemizedWeigth);
+ result.addTotalWeight(speciesLivingNotItemizedWeigth * speciesRatio);
+ }
+
+ Float benthosInterWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalInertWeight(),
+ catchBatch.getBenthosTotalInertComputedWeight());
+
+ if (benthosInterWeight != null) {
+ result.addSortedWeight(benthosInterWeight);
+ result.addTotalWeight(benthosInterWeight * benthosRatio);
+ }
+
+ Float benthosLivingNotItemizedWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalLivingNotItemizedWeight(),
+ catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
+
+ if (benthosLivingNotItemizedWeight != null) {
+ result.addSortedWeight(benthosLivingNotItemizedWeight);
+ result.addTotalWeight(benthosLivingNotItemizedWeight * benthosRatio);
+ }
+
+ return result;
+ }
+
+ public boolean isVracBatch(SpeciesAbleBatch batch) {
+ return vracPredicate.apply(batch);
+ }
+
+ protected float getSpeciesElevationRate() {
+
+ float globalRatio = (getCatchTotalWeight() - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight();
+
+ float speciesTotalSortedWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalSortedWeight(),
+ catchBatch.getSpeciesTotalSortedComputedWeight());
+
+ // ratio total species weight / total sorted sampled species weight
+ float result = globalRatio * speciesTotalSortedWeight;
+ if (catchBatch.getSpeciesTotalSampleSortedComputedWeight() > 0) {
+ result /= catchBatch.getSpeciesTotalSampleSortedComputedWeight();
+ }
+ return result;
+ }
+
+ protected float getBenthosElevationRate() {
+
+ float globalRatio = (getCatchTotalWeight() - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight();
+
+ float benthosTotalSortedWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalSortedWeight(),
+ catchBatch.getBenthosTotalSortedComputedWeight());
+
+ // ratio total benthos weight / total sorted sampled benthos weight
+ float result = globalRatio * benthosTotalSortedWeight;
+ if (catchBatch.getBenthosTotalSampleSortedComputedWeight() > 0) {
+ result /= catchBatch.getBenthosTotalSampleSortedComputedWeight();
+ }
+ return result;
+ }
+
+ protected void createExportBatchCatch(SpeciesAbleBatch batch,
+ Map<Species, ExportBatchEntry> catches,
+ float ratio,
+ boolean computeNumber) {
+
+ Species species = batch.getSpecies();
+
+ ExportBatchEntry ktch = catches.get(species);
+ if (ktch == null) {
+ ktch = new ExportBatchEntry(batch);
+ catches.put(species, ktch);
+ }
+
+ float sortedWeight = TuttiEntities.getValueOrComputedValue(
+ batch.getSampleCategoryWeight(),
+ batch.getSampleCategoryComputedWeight());
+
+ ktch.addSortedWeight(sortedWeight);
+
+ boolean isVracBatch = isVracBatch(batch);
+ float speciesTotalWeight = sortedWeight;
+ if (isVracBatch) {
+ speciesTotalWeight *= ratio;
+ }
+ ktch.addTotalWeight(speciesTotalWeight);
+
+ if (computeNumber) {
+ float number = Math.round(computeNumber(batch, 1.0f));
+ if (isVracBatch) {
+ number *= ratio;
+ }
+ ktch.addNumber(Math.round(number));
+ }
+ }
+
+ protected float computeNumber(SpeciesAbleBatch batch, float rf) {
+ float result;
+
+ float weight = TuttiEntities.getValueOrComputedValue(
+ batch.getSampleCategoryWeight(),
+ batch.getSampleCategoryComputedWeight());
+
+ if (batch.isChildBatchsEmpty()) {
+
+ // on a leaf, get his weight
+
+ Integer number = TuttiEntities.getValueOrComputedValue(
+ batch.getNumber(),
+ batch.getComputedNumber());
+ if (number == null) {
+
+ // no count
+ number = 0;
+ }
+
+ // get the sample weight
+ Float subweight = TuttiEntities.getValueOrComputedValue(
+ batch.getWeight(),
+ batch.getComputedWeight());
+
+ if (subweight != null) {
+
+ // with sub sample, update the raising factor
+ rf *= weight / subweight;
+ }
+
+ result = number.floatValue() * rf;
+ } else {
+
+ // get total weight of all childs
+ float totalWeight = 0.f;
+ for (SpeciesAbleBatch child : batch.getChildBatchs()) {
+ totalWeight += TuttiEntities.getValueOrComputedValue(
+ child.getSampleCategoryWeight(),
+ child.getSampleCategoryComputedWeight());
+ }
+
+ result = 0f;
+
+ float rf2 = rf * weight / totalWeight;
+ // sum result of each child
+ for (SpeciesAbleBatch child : batch.getChildBatchs()) {
+
+ result += computeNumber(child, rf2);
+ }
+
+ }
+ return result;
+ }
+}
Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -36,6 +36,7 @@
import fr.ifremer.tutti.service.TuttiServiceContext;
import fr.ifremer.tutti.service.catches.WeightComputingService;
import fr.ifremer.tutti.service.export.ExportBatchEntry;
+import fr.ifremer.tutti.service.export.ExportCatchContext;
import freemarker.cache.ClassTemplateLoader;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.Configuration;
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -1,337 +0,0 @@
-package fr.ifremer.tutti.service.export.pdf;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.catches.WeightComputingService;
-import fr.ifremer.tutti.service.export.ExportBatchEntry;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created on 11/21/13.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since XXX
- */
-public class ExportCatchContext {
-
- final FishingOperation fishingOperation;
-
- final CatchBatch catchBatch;
-
- final BatchContainer<SpeciesBatch> rootSpeciesBatch;
-
- final BatchContainer<BenthosBatch> rootBenthosBatch;
-
- final BatchContainer<MarineLitterBatch> marineLitterBatches;
-
- final Predicate<SpeciesAbleBatch> vracPredicate;
-
- public static ExportCatchContext newExportContext(PersistenceService persistenceService,
- WeightComputingService weightComputingService,
- String fishingOperationId) {
-
- FishingOperation fishingOperation =
- persistenceService.getFishingOperation(fishingOperationId);
-
- CatchBatch catchBatch =
- persistenceService.getCatchBatchFromFishingOperation(fishingOperationId);
-
- BatchContainer<SpeciesBatch> rootSpeciesBatch =
- weightComputingService.getComputedSpeciesBatches(fishingOperationId);
-
- BatchContainer<BenthosBatch> rootBenthosBatch =
- weightComputingService.getComputedBenthosBatches(fishingOperationId);
-
- BatchContainer<MarineLitterBatch> marineLitterBatches =
- weightComputingService.getComputedMarineLitterBatches(
- fishingOperationId,
- catchBatch.getMarineLitterTotalWeight());
- weightComputingService.computeCatchBatchWeights(catchBatch,
- rootSpeciesBatch,
- rootBenthosBatch,
- marineLitterBatches);
-
- Predicate<SpeciesAbleBatch> vracPredicate = persistenceService.getVracBatchPredicate();
-
- ExportCatchContext result = new ExportCatchContext(vracPredicate,
- fishingOperation,
- catchBatch,
- rootSpeciesBatch,
- rootBenthosBatch,
- marineLitterBatches);
- return result;
-
- }
-
- private ExportCatchContext(Predicate<SpeciesAbleBatch> vracPredicate,
- FishingOperation fishingOperation,
- CatchBatch catchBatch,
- BatchContainer<SpeciesBatch> rootSpeciesBatch,
- BatchContainer<BenthosBatch> rootBenthosBatch,
- BatchContainer<MarineLitterBatch> marineLitterBatches) {
- this.vracPredicate = vracPredicate;
- this.fishingOperation = fishingOperation;
- this.catchBatch = catchBatch;
- this.rootSpeciesBatch = rootSpeciesBatch;
- this.rootBenthosBatch = rootBenthosBatch;
- this.marineLitterBatches = marineLitterBatches;
- }
-
- public FishingOperation getFishingOperation() {
- return fishingOperation;
- }
-
- public float getCatchTotalWeight() {
- float result = TuttiEntities.getValueOrComputedValue(
- catchBatch.getCatchTotalWeight(),
- catchBatch.getCatchTotalComputedWeight());
- return result;
- }
-
- public float getCatchTotalSortedWeight() {
- return catchBatch.getSpeciesTotalSampleSortedComputedWeight() +
- catchBatch.getBenthosTotalSampleSortedComputedWeight();
- }
-
- public boolean withSpeciesBatches() {
- return rootSpeciesBatch != null && !rootSpeciesBatch.isEmptyChildren();
- }
-
- public boolean withBenthosBatches() {
- return rootBenthosBatch != null && !rootBenthosBatch.isEmptyChildren();
- }
-
- public List<ExportBatchEntry> getSpeciesBatchEntry(boolean computeNumber) {
- List<ExportBatchEntry> catchList = Lists.newArrayList();
-
- if (withSpeciesBatches()) {
-
- Map<Species, ExportBatchEntry> catches = Maps.newLinkedHashMap();
-
- // ratio total species weight / total sorted sampled species weight
- float speciesRatio = getSpeciesElevationRate();
-
- List<SpeciesBatch> batches = rootSpeciesBatch.getChildren();
- for (SpeciesBatch batch : batches) {
-
- createExportBatchCatch(
- batch,
- catches,
- speciesRatio,
- computeNumber);
- }
- catchList.addAll(catches.values());
- }
- return catchList;
- }
-
- public List<ExportBatchEntry> getBenthosBatchEntry(boolean computeNumber) {
- List<ExportBatchEntry> catchList = Lists.newArrayList();
-
- if (withBenthosBatches()) {
-
- Map<Species, ExportBatchEntry> catches = Maps.newLinkedHashMap();
-
- // ratio total species weight / total sorted sampled species weight
- float speciesRatio = getBenthosElevationRate();
-
- List<BenthosBatch> batches = rootBenthosBatch.getChildren();
- for (BenthosBatch batch : batches) {
-
- createExportBatchCatch(
- batch,
- catches,
- speciesRatio,
- computeNumber);
- }
-
- catchList.addAll(catches.values());
- }
- return catchList;
- }
-
- public ExportBatchEntry getInertAndLivingNotItemizedCatch() {
-
- ExportBatchEntry result = new ExportBatchEntry(null);
-
- float speciesRatio = getSpeciesElevationRate();
- float benthosRatio = getBenthosElevationRate();
-
- Float speciesInterWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalInertWeight(),
- catchBatch.getSpeciesTotalInertComputedWeight());
-
- if (speciesInterWeight != null) {
- result.addSortedWeight(speciesInterWeight);
- result.addTotalWeight(speciesInterWeight * speciesRatio);
- }
-
- Float speciesLivingNotItemizedWeigth = TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
- catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
-
- if (speciesLivingNotItemizedWeigth != null) {
- result.addSortedWeight(speciesLivingNotItemizedWeigth);
- result.addTotalWeight(speciesLivingNotItemizedWeigth * speciesRatio);
- }
-
- Float benthosInterWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalInertWeight(),
- catchBatch.getBenthosTotalInertComputedWeight());
-
- if (benthosInterWeight != null) {
- result.addSortedWeight(benthosInterWeight);
- result.addTotalWeight(benthosInterWeight * benthosRatio);
- }
-
- Float benthosLivingNotItemizedWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalLivingNotItemizedWeight(),
- catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
-
- if (benthosLivingNotItemizedWeight != null) {
- result.addSortedWeight(benthosLivingNotItemizedWeight);
- result.addTotalWeight(benthosLivingNotItemizedWeight * benthosRatio);
- }
-
- return result;
- }
-
- public boolean isVracBatch(SpeciesAbleBatch batch) {
- return vracPredicate.apply(batch);
- }
-
- protected float getSpeciesElevationRate() {
-
- float globalRatio = (getCatchTotalWeight() - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight();
-
- float speciesTotalSortedWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalSortedWeight(),
- catchBatch.getSpeciesTotalSortedComputedWeight());
-
- // ratio total species weight / total sorted sampled species weight
- float result = globalRatio * speciesTotalSortedWeight;
- if (catchBatch.getSpeciesTotalSampleSortedComputedWeight() > 0) {
- result /= catchBatch.getSpeciesTotalSampleSortedComputedWeight();
- }
- return result;
- }
-
- protected float getBenthosElevationRate() {
-
- float globalRatio = (getCatchTotalWeight() - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight();
-
- float benthosTotalSortedWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalSortedWeight(),
- catchBatch.getBenthosTotalSortedComputedWeight());
-
- // ratio total benthos weight / total sorted sampled benthos weight
- float result = globalRatio * benthosTotalSortedWeight;
- if (catchBatch.getBenthosTotalSampleSortedComputedWeight() > 0) {
- result /= catchBatch.getBenthosTotalSampleSortedComputedWeight();
- }
- return result;
- }
-
- protected void createExportBatchCatch(SpeciesAbleBatch batch,
- Map<Species, ExportBatchEntry> catches,
- float ratio,
- boolean computeNumber) {
-
- Species species = batch.getSpecies();
-
- ExportBatchEntry ktch = catches.get(species);
- if (ktch == null) {
- ktch = new ExportBatchEntry(batch);
- catches.put(species, ktch);
- }
-
- float sortedWeight = TuttiEntities.getValueOrComputedValue(
- batch.getSampleCategoryWeight(),
- batch.getSampleCategoryComputedWeight());
-
- ktch.addSortedWeight(sortedWeight);
-
- boolean isVracBatch = isVracBatch(batch);
- float speciesTotalWeight = sortedWeight;
- if (isVracBatch) {
- speciesTotalWeight *= ratio;
- }
- ktch.addTotalWeight(speciesTotalWeight);
-
- if (computeNumber) {
- int number = Math.round(computeNumber(batch, 1.0f));
- if (isVracBatch) {
- number *= ratio;
- }
- ktch.addNumber(number);
- }
- }
-
- protected float computeNumber(SpeciesAbleBatch batch, float rf) {
- float result;
-
- float weight = TuttiEntities.getValueOrComputedValue(
- batch.getSampleCategoryWeight(),
- batch.getSampleCategoryComputedWeight());
-
- if (batch.isChildBatchsEmpty()) {
-
- // on a leaf, get his weight
-
- Integer number = TuttiEntities.getValueOrComputedValue(
- batch.getNumber(),
- batch.getComputedNumber());
- if (number == null) {
-
- // no count
- number = 0;
- }
-
- // get the sample weight
- Float subweight = TuttiEntities.getValueOrComputedValue(
- batch.getWeight(),
- batch.getComputedWeight());
-
- if (subweight != null) {
-
- // with sub sample, update the raising factor
- rf *= weight / subweight;
- }
-
- result = number.floatValue() * rf;
- } else {
-
- // get total weight of all childs
- float totalWeight = 0.f;
- for (SpeciesAbleBatch child : batch.getChildBatchs()) {
- totalWeight += TuttiEntities.getValueOrComputedValue(
- child.getSampleCategoryWeight(),
- child.getSampleCategoryComputedWeight());
- }
-
- result = 0f;
-
- float rf2 = rf * weight / totalWeight;
- // sum result of each child
- for (SpeciesAbleBatch child : batch.getChildBatchs()) {
-
- result += computeNumber(child, rf2);
- }
-
- }
- return result;
- }
-}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.service.export.pdf;
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.service.export.ExportBatchEntry;
/**
@@ -7,7 +31,7 @@
* his sorted weight, total weight and percentage amoong the total catch
* weight.
*
- * @since 2.10
+ * @since 3.0-rc-1
*/
public class PdfExportBatchEntry extends ExportBatchEntry {
Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -36,7 +36,7 @@
import fr.ifremer.tutti.service.TuttiServiceContext;
import fr.ifremer.tutti.service.catches.WeightComputingService;
import fr.ifremer.tutti.service.export.ExportBatchEntry;
-import fr.ifremer.tutti.service.export.pdf.ExportCatchContext;
+import fr.ifremer.tutti.service.export.ExportCatchContext;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.service.export.pdf;
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.service.PersistenceService;
import fr.ifremer.tutti.service.ServiceDbResource;
import fr.ifremer.tutti.service.TuttiServiceContext;
@@ -16,7 +40,7 @@
* Created on 11/19/13.
*
* @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.10
+ * @since 3.0-rc-1
*/
public class CatchesPdfExportServiceTest {
Property changes on: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-ui-swing/pom.xml 2013-11-21 16:09:10 UTC (rev 1371)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.10-SNAPSHOT</version>
+ <version>3.0-rc-1-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -56,7 +56,7 @@
/**
* Rows to delete after all.
*
- * @since 2.10
+ * @since 3.0-rc-1
*/
protected Set<BenthosBatchRowModel> rowToRemove;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -56,14 +56,14 @@
/**
* Rows to delete after all.
*
- * @since 2.10
+ * @since 3.0-rc-1
*/
protected Set<BenthosBatchRowModel> rowToRemove;
/**
* Parent batch of rows to delete.
*
- * @since 2.10
+ * @since 3.0-rc-1
*/
protected BenthosBatchRowModel parentBatch;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -49,7 +49,7 @@
/**
* Rows to delete after all.
*
- * @since 2.10
+ * @since 3.0-rc-1
*/
protected Set<SpeciesBatchRowModel> rowToRemove;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-11-21 15:41:34 UTC (rev 1370)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-11-21 16:09:10 UTC (rev 1371)
@@ -56,14 +56,14 @@
/**
* Rows to delete after all.
*
- * @since 2.10
+ * @since 3.0-rc-1
*/
protected Set<SpeciesBatchRowModel> rowToRemove;
/**
* Parent batch of rows to delete.
*
- * @since 2.10
+ * @since 3.0-rc-1
*/
protected SpeciesBatchRowModel parentBatch;
1
0
21 Nov '13
Author: tchemit
Date: 2013-11-21 16:41:34 +0100 (Thu, 21 Nov 2013)
New Revision: 1370
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1370
Log:
fixes #3803: [CAPTURE] ?\195?\169l?\195?\169vations : marche pas en .csv et .pdf depuis l'onglet r?\195?\169sum?\195?\169 (improve export design, use unique code for all export, ...)
Added:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/AccidentalCatchExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/AccidentalCatchExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ExportSampleCategory.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GearCaracteristicExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GearCaracteristicExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/IndividualObservationExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/IndividualObservationExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/MarineLitterExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/MarineLitterExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ParameterExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ParameterExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SpeciesExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SpeciesExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SurveyExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SurveyExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/sumatra/
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportServiceTest.java
Removed:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportSampleCategory.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/GearCaracteristicExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/GearCaracteristicExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ParameterExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ParameterExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SpeciesExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SpeciesExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SurveyExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SurveyExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchesSumatraExportService.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/ExportCatchesReportServiceTest.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/CatchesSumatraExportServiceTest.java
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationForSumatraAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationReportAction.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -24,6 +24,7 @@
* #L%
*/
+import com.google.common.base.Predicate;
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
@@ -269,12 +270,10 @@
Caracteristic getCaracteristic(Integer pmfmId);
+ Predicate<SpeciesAbleBatch> getVracBatchPredicate();
+
boolean isVracBatch(SpeciesAbleBatch speciesBatch);
-// boolean isVracSpeciesBatch(SpeciesBatch speciesBatch);
-
-// boolean isVracBenthosBatch(BenthosBatch benthosBatch);
-
boolean isTemporary(TuttiReferentialEntity entity);
List<Gear> getAllScientificGear();
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-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -139,12 +139,8 @@
@Autowired
protected DatabaseSchemaDao databaseSchemaDao;
- protected Predicate<SpeciesAbleBatch> speciesAbleBatchVracPredicate;
+ protected Predicate<SpeciesAbleBatch> batchVracPredicate;
-// protected Predicate<SpeciesBatch> speciesBatchVracPredicate;
-//
-// protected Predicate<BenthosBatch> benthosBatchVracPredicate;
-
@Override
public String getImplementationName() {
return "Persistence Adagio implementation";
@@ -229,9 +225,7 @@
TuttiEnumerationFile enumerationFile = getEnumerationFile();
- speciesAbleBatchVracPredicate = TuttiEntities.newSpeciesAbleBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
-// speciesBatchVracPredicate = TuttiEntities.newSpeciesBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
-// benthosBatchVracPredicate = TuttiEntities.newBenthosBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
+ batchVracPredicate = TuttiEntities.newSpeciesAbleBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
}
@Override
@@ -421,18 +415,13 @@
@Override
public boolean isVracBatch(SpeciesAbleBatch speciesBatch) {
- return speciesAbleBatchVracPredicate.apply(speciesBatch);
+ return batchVracPredicate.apply(speciesBatch);
}
-// @Override
-// public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
-// return speciesBatchVracPredicate.apply(speciesBatch);
-// }
-//
-// @Override
-// public boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
-// return benthosBatchVracPredicate.apply(benthosBatch);
-// }
+ @Override
+ public Predicate<SpeciesAbleBatch> getVracBatchPredicate() {
+ return batchVracPredicate;
+ }
@Override
public boolean isTemporary(TuttiReferentialEntity entity) {
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-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -24,6 +24,7 @@
* #L%
*/
+import com.google.common.base.Predicate;
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
@@ -97,16 +98,6 @@
throw notImplemented();
}
-// @Override
-// public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
-// throw notImplemented();
-// }
-//
-// @Override
-// public boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
-// throw notImplemented();
-// }
-
@Override
public void clearAllCaches() {
throw notImplemented();
@@ -263,6 +254,11 @@
}
@Override
+ public Predicate<SpeciesAbleBatch> getVracBatchPredicate() {
+ throw notImplemented();
+ }
+
+ @Override
public boolean isTemporary(TuttiReferentialEntity entity) {
throw notImplemented();
}
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-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -26,6 +26,7 @@
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import fr.ifremer.tutti.TuttiBusinessException;
@@ -837,6 +838,11 @@
}
@Override
+ public Predicate<SpeciesAbleBatch> getVracBatchPredicate() {
+ return driver.getVracBatchPredicate();
+ }
+
+ @Override
public boolean isTemporary(TuttiReferentialEntity entity) {
return driver.isTemporary(entity);
}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,493 +0,0 @@
-package fr.ifremer.tutti.service.catches;
-
-/*
- * #%L
- * Tutti :: Service
- * $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 com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ifremer.tutti.TuttiBusinessException;
-import fr.ifremer.tutti.TuttiTechnicalException;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.AbstractTuttiService;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.TuttiServiceContext;
-import freemarker.cache.ClassTemplateLoader;
-import freemarker.ext.beans.BeansWrapper;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xhtmlrenderer.pdf.ITextRenderer;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.0
- */
-public class ExportCatchesReportService extends AbstractTuttiService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportCatchesReportService.class);
-
- protected Configuration freemarkerConfiguration;
-
- protected PersistenceService persistenceService;
-
- protected WeightComputingService weightComputingService;
-
- public ExportCatchesReportService() {
- super();
-
- freemarkerConfiguration = new Configuration();
-
- // needed to overwrite "Defaults to default system encoding."
- // fix encoding issue on some systems
- freemarkerConfiguration.setEncoding(Locale.getDefault(), "UTF-8");
-
- // specific template loader to get template from jars (classpath)
- ClassTemplateLoader templateLoader = new ClassTemplateLoader(ExportCatchesReportService.class, "/ftl");
- freemarkerConfiguration.setTemplateLoader(templateLoader);
-
- // pour les maps dans les template (entre autre)
- freemarkerConfiguration.setObjectWrapper(new BeansWrapper());
- }
-
- @Override
- public void setServiceContext(TuttiServiceContext context) {
- super.setServiceContext(context);
- persistenceService = getService(PersistenceService.class);
- weightComputingService = getService(WeightComputingService.class);
- }
-
- /**
- * Generate the PDF report for the fiven cruise.
- *
- * @param targetFile pdf file to generate
- * @param locale generated pdf locale
- * @throws TuttiBusinessException
- */
- public void generateCruisePDFFile(File targetFile,
- String cruiseId,
- Locale locale) throws TuttiBusinessException {
-
-
- List<String> allFishingOperation =
- persistenceService.getAllFishingOperationIds(cruiseId);
-
- List<Map<String, Object>> operations = Lists.newArrayList();
- for (String operationId : allFishingOperation) {
-
- prepareOperation(operationId, operations);
-
- }
-
- generatePdf(targetFile, locale, operations);
- }
-
- /**
- * Generate the PDF report for the given fishing operation.
- *
- * @param targetFile pdf file to generate
- * @param fishingOperationId id of the fishing operation to export
- * @param locale generated pdf locale
- * @throws TuttiBusinessException
- * @since 2.7
- */
- public void generateFishingOperationPDFFile(File targetFile,
- String fishingOperationId,
- Locale locale) throws TuttiBusinessException {
-
- List<Map<String, Object>> operations = Lists.newArrayList();
-
- prepareOperation(fishingOperationId, operations);
-
- generatePdf(targetFile, locale, operations);
- }
-
- protected void prepareOperation(String fishingOperationId,
- List<Map<String, Object>> operations) {
-
- // get operation and catch data
- boolean withCatchBatch =
- persistenceService.isFishingOperationWithCatchBatch(
- fishingOperationId);
-
- if (!withCatchBatch) {
- if (log.isWarnEnabled()) {
- log.warn("Skip fishing operation " + fishingOperationId +
- " since no catchBatch associated.");
- }
- return;
- }
-
- FishingOperation fishingOperation =
- persistenceService.getFishingOperation(fishingOperationId);
-
- CatchBatch catchBatch =
- persistenceService.getCatchBatchFromFishingOperation(fishingOperationId);
-
- BatchContainer<SpeciesBatch> rootSpeciesBatch =
- weightComputingService.getComputedSpeciesBatches(fishingOperationId);
-
- BatchContainer<BenthosBatch> rootBenthosBatch =
- weightComputingService.getComputedBenthosBatches(fishingOperationId);
-
- BatchContainer<MarineLitterBatch> marineLitterBatches =
- weightComputingService.getComputedMarineLitterBatches(
- fishingOperationId,
- catchBatch.getMarineLitterTotalWeight());
- weightComputingService.computeCatchBatchWeights(catchBatch,
- rootSpeciesBatch,
- rootBenthosBatch,
- marineLitterBatches);
-
- // create operation data model
- Map<String, Object> op = createOperation(fishingOperation);
-
- float totalWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getCatchTotalWeight(),
- catchBatch.getCatchTotalComputedWeight());
-
- op.put("totalWeight", totalWeight);
-
- op.put("totalSortedWeight", catchBatch.getSpeciesTotalSampleSortedComputedWeight() + catchBatch.getBenthosTotalSampleSortedComputedWeight());
-
- // create catches data model
-
- // Species
-
- Map<Species, SpeciesBatchEntry> catches = Maps.newHashMap();
-
- float globalRatio = (totalWeight - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight();
-
- float speciesTotalSortedWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalSortedWeight(),
- catchBatch.getSpeciesTotalSortedComputedWeight());
-
- // ratio total species weight / total sorted sampled species weight
- float speciesRatio = globalRatio * speciesTotalSortedWeight;
- if (catchBatch.getSpeciesTotalSampleSortedComputedWeight() > 0) {
- speciesRatio /= catchBatch.getSpeciesTotalSampleSortedComputedWeight();
- }
-
- // create catches rows
- if (rootSpeciesBatch != null) {
-
- List<SpeciesBatch> speciesBatches = rootSpeciesBatch.getChildren();
- for (SpeciesBatch batch : speciesBatches) {
-
- createSpeciesCatch(batch, catches, speciesRatio);
- }
- }
-
- List<SpeciesBatchEntry> catchList = Lists.newArrayList(catches.values());
-
- // Benthos
-
- float benthosTotalSortedWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalSortedWeight(),
- catchBatch.getBenthosTotalSortedComputedWeight());
-
- // ratio total benthos weight / total sorted sampled benthos weight
- float benthosRatio = globalRatio * benthosTotalSortedWeight;
- if (catchBatch.getBenthosTotalSampleSortedComputedWeight() > 0) {
- benthosRatio /= catchBatch.getBenthosTotalSampleSortedComputedWeight();
- }
-
- // add the benthos row
- if (rootBenthosBatch != null) {
-
- if (CollectionUtils.isNotEmpty(rootBenthosBatch.getChildren())) {
- SpeciesBatchEntry benthosCatch =
- createBenthosCatch(rootBenthosBatch, benthosRatio);
- catchList.add(benthosCatch);
- }
- }
-
- // Inert and living not itemized
- SpeciesBatchEntry inertLivingNotItemizedCatch =
- createInertAndLivingNotItemizedCatch(catchBatch,
- speciesRatio,
- benthosRatio);
- if (inertLivingNotItemizedCatch.getSortedWeight() > 0f) {
- catchList.add(inertLivingNotItemizedCatch);
- }
-
- if (log.isDebugEnabled()) {
-
- // recompute total for check
- float computedTotalWeight = 0f;
- float computedPercentage = 0f;
- for (SpeciesBatchEntry entry : catchList) {
- entry.computePercentage(totalWeight);
- computedTotalWeight += entry.getTotalWeight();
- computedPercentage += entry.getPercentage();
- }
- log.debug("TotalWeight: " + totalWeight);
- log.debug("ComputedTotalWeight: " + computedTotalWeight);
- log.debug("ComputedPercentage: " + computedPercentage);
- }
- op.put("catches", catchList);
- operations.add(op);
- }
-
- protected void generatePdf(File targetFile, Locale locale, List<Map<String, Object>> operations) {
-
- Map<String, Object> data = Maps.newHashMap();
- data.put("operations", operations);
- // generate the report
- OutputStream os = null;
- try {
-
- // render freemarker template
- Template mapTemplate = freemarkerConfiguration.getTemplate("catchesReport.ftl", locale);
-
- Writer out = new StringWriter();
- mapTemplate.process(data, out);
- out.flush();
-
- // render template output as pdf
- os = new FileOutputStream(targetFile);
-
- ITextRenderer renderer = new ITextRenderer();
- renderer.setDocumentFromString(out.toString());
- renderer.layout();
- renderer.createPDF(os);
-
- os.close();
-
- } catch (Exception ex) {
- throw new TuttiTechnicalException(_("tutti.service.operations.exportCatchesReport.error"), ex);
- } finally {
- IOUtils.closeQuietly(os);
- }
- }
-
- protected Map<String, Object> createOperation(FishingOperation fishingOperation) {
- Map<String, Object> op = Maps.newHashMap();
- op.put("number", fishingOperation.getFishingOperationNumber());
- op.put("station", fishingOperation.getStationNumber());
- op.put("rigNumber", fishingOperation.getMultirigAggregation());
- op.put("startDate", fishingOperation.getGearShootingStartDate());
- op.put("endDate", fishingOperation.getGearShootingEndDate());
-
- return op;
- }
-
- protected void createSpeciesCatch(SpeciesBatch batch,
- Map<Species, SpeciesBatchEntry> catches,
- float ratio) {
-
- Species species = batch.getSpecies();
-
- SpeciesBatchEntry ktch = catches.get(species);
- if (ktch == null) {
- Species speciesWithVerncularCode =
- persistenceService.getSpeciesByReferenceTaxonIdWithVernacularCode(species.getReferenceTaxonId());
-
- ktch = new SpeciesBatchEntry(
- species.getRefTaxCode(),
- species.getName(),
- speciesWithVerncularCode.getVernacularCode()
- );
- catches.put(species, ktch);
- }
-
- float sortedWeight = TuttiEntities.getValueOrComputedValue(
- batch.getSampleCategoryWeight(),
- batch.getSampleCategoryComputedWeight());
-
- ktch.addSortedWeight(sortedWeight);
-
- float speciesTotalWeight = sortedWeight;
- if (persistenceService.isVracBatch(batch)) {
- speciesTotalWeight *= ratio;
- }
- ktch.addTotalWeight(speciesTotalWeight);
- }
-
- protected SpeciesBatchEntry createBenthosCatch(BatchContainer<BenthosBatch> rootBenthosBatch,
- float ratio) {
- SpeciesBatchEntry ktch = new SpeciesBatchEntry(
- _("tutti.service.operations.exportCatchesReport.specialRows.benthos.code"),
- "",
- _("tutti.service.operations.exportCatchesReport.specialRows.benthos.name")
- );
-
- float sortedWeight = 0f;
- float benthosTotalWeight = 0f;
- List<BenthosBatch> benthosBatches = rootBenthosBatch.getChildren();
- for (BenthosBatch batch : benthosBatches) {
- float batchWeight = TuttiEntities.getValueOrComputedValue(
- batch.getSampleCategoryWeight(),
- batch.getSampleCategoryComputedWeight());
- sortedWeight += batchWeight;
- if (persistenceService.isVracBatch(batch)) {
- batchWeight *= ratio;
- }
- benthosTotalWeight += batchWeight;
- }
- ktch.addSortedWeight(sortedWeight);
- ktch.addTotalWeight(benthosTotalWeight);
-
- return ktch;
- }
-
- protected SpeciesBatchEntry createInertAndLivingNotItemizedCatch(CatchBatch catchBatch,
- float speciesRatio,
- float benthosRatio) {
- SpeciesBatchEntry ktch = new SpeciesBatchEntry(
- _("tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.code"),
- "",
- _("tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.name"));
-
- float sortedWeight = 0f;
- float totalWeight = 0f;
-
- Float speciesInterWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalInertWeight(),
- catchBatch.getSpeciesTotalInertComputedWeight());
-
- if (speciesInterWeight != null) {
- sortedWeight += speciesInterWeight;
- totalWeight += speciesInterWeight * speciesRatio;
- }
-
- Float speciesLivingNotItemizedWeigth = TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
- catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
-
- if (speciesLivingNotItemizedWeigth != null) {
- sortedWeight += speciesLivingNotItemizedWeigth;
- totalWeight += speciesLivingNotItemizedWeigth * speciesRatio;
- }
-
- Float benthosInterWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalInertWeight(),
- catchBatch.getBenthosTotalInertComputedWeight());
-
- if (benthosInterWeight != null) {
- sortedWeight += benthosInterWeight;
- totalWeight += benthosInterWeight * benthosRatio;
- }
-
- Float benthosLivingNotItemizedWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalLivingNotItemizedWeight(),
- catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
-
- if (benthosLivingNotItemizedWeight != null) {
- sortedWeight += benthosLivingNotItemizedWeight;
- totalWeight += benthosLivingNotItemizedWeight * benthosRatio;
- }
-
- ktch.addSortedWeight(sortedWeight);
- ktch.addTotalWeight(totalWeight);
-
- return ktch;
- }
-
- /**
- * To store a species or batch entry within his speices informations,
- * his sorted weight, total weight and percentage amoong the total catch
- * weight.
- *
- * @since 2.10
- */
- public static class SpeciesBatchEntry {
-
- protected final String code;
-
- protected final String scientificName;
-
- protected final String commonName;
-
- float sortedWeight;
-
- float totalWeight;
-
- float percentage;
-
- SpeciesBatchEntry(String code, String scientificName, String commonName) {
- this.code = code;
- this.scientificName = scientificName;
- this.commonName = commonName;
- }
-
- public void addSortedWeight(float weight) {
- sortedWeight += weight;
- }
-
- public void addTotalWeight(float weight) {
- totalWeight += weight;
- }
-
- public void computePercentage(float totalWeight) {
- this.percentage = 100 * this.totalWeight / totalWeight;
- }
-
- public String getCode() {
- return code;
- }
-
- public String getScientificName() {
- return scientificName;
- }
-
- public String getCommonName() {
- return commonName;
- }
-
- public float getSortedWeight() {
- return sortedWeight;
- }
-
- public float getTotalWeight() {
- return totalWeight;
- }
-
- public float getPercentage() {
- return percentage;
- }
- }
-}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -301,8 +301,10 @@
marineLitterTotalComputedWeight += rowWeight;
}
}
- catchBatch.setMarineLitterTotalComputedWeight(
- TuttiEntities.roundKiloGram(marineLitterTotalComputedWeight));
+ if (marineLitterTotalComputedWeight != null) {
+ catchBatch.setMarineLitterTotalComputedWeight(
+ TuttiEntities.roundKiloGram(marineLitterTotalComputedWeight));
+ }
Float marineLitterTotalWeight = catchBatch.getMarineLitterTotalWeight();
if (marineLitterTotalWeight == null) {
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,170 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.2
- */
-public class AccidentalCatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<AccidentalCatchExportRow> {
-
- protected final Caracteristic caracteristicDeadOrAliveSize;
-
- protected final Caracteristic caracteristicGender;
-
- protected final Caracteristic caracteristicWeight;
-
- protected final Caracteristic caracteristicPmfmId;
-
- public AccidentalCatchExportModel(
- char separator,
- Caracteristic caracteristicDeadOrAliveSize,
- Caracteristic caracteristicGender,
- Caracteristic caracteristicWeight,
- Caracteristic caracteristicPmfmId) {
- super(separator);
-
- this.caracteristicDeadOrAliveSize = caracteristicDeadOrAliveSize;
- this.caracteristicGender = caracteristicGender;
- this.caracteristicWeight = caracteristicWeight;
- this.caracteristicPmfmId = caracteristicPmfmId;
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
- newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
- newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
-
- newColumnForExport("BatchId", AccidentalCatchExportRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("ReferenceTaxonId", AccidentalBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("ReferenceTaxonName", AccidentalBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
- newColumnForExport("Commentaire", AccidentalBatch.PROPERTY_COMMENT);
- newColumnForExport("CaracteristicId", AccidentalCatchExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
- newColumnForExport("CaracteristicValue", AccidentalCatchExportRow.PROPERTY_CARACTERISTIC_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- }
-
- public void prepareRows(PersistenceService persistenceService,
- List<AccidentalCatchExportRow> rows,
- Cruise cruise,
- FishingOperation operation) {
-
- List<AccidentalBatch> observations =
- persistenceService.getAllAccidentalBatch(operation.getId());
-
- if (CollectionUtils.isNotEmpty(observations)) {
- for (AccidentalBatch child : observations) {
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicDeadOrAliveSize,
- child.getDeadOrAlive());
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicGender,
- child.getGender());
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicWeight,
- child.getWeight());
-
- if (child.getLengthStepCaracteristic() != null) {
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicPmfmId,
- child.getLengthStepCaracteristic().getIdAsInt());
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- child.getLengthStepCaracteristic(),
- child.getSize());
- }
-
- CaracteristicMap caracteristics = child.getCaracteristics();
- if (MapUtils.isNotEmpty(caracteristics)) {
- for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- entry.getKey(),
- entry.getValue());
- }
- }
- }
- }
- }
-
- private void addCaracteristicRow(List<AccidentalCatchExportRow> rows,
- Cruise cruise,
- FishingOperation operation,
- AccidentalBatch child,
- Caracteristic caracteristic,
- Serializable caracteristicValue) {
- if (caracteristicValue != null) {
-
- AccidentalCatchExportRow row = new AccidentalCatchExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setBatch(child);
- row.setCaracteristic(caracteristic);
- row.setCaracteristicValue(caracteristicValue);
- rows.add(row);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportRow.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,139 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.AccidentalBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * A row in a accidental catch export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.2
- */
-public class AccidentalCatchExportRow implements Serializable {
-
- public static final String PROPERTY_BATCH = "batch";
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_BATCH_ID = "batchId";
-
- public static final String PROPERTY_CARACTERISTIC = "caracteristic";
-
- public static final String PROPERTY_CARACTERISTIC_VALUE = "caracteristicValue";
-
- protected Cruise cruise;
-
- protected FishingOperation fishingOperation;
-
- protected AccidentalBatch batch;
-
- protected Caracteristic caracteristic;
-
- protected Serializable caracteristicValue;
-
- public void setCruise(Cruise cruise) {
- this.cruise = cruise;
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- public void setBatch(AccidentalBatch batch) {
- this.batch = batch;
- }
-
- public void setCaracteristic(Caracteristic caracteristic) {
- this.caracteristic = caracteristic;
- }
-
- public void setCaracteristicValue(Serializable caracteristicValue) {
- this.caracteristicValue = caracteristicValue;
- }
-
- public Integer getBatchId() {
- return batch.getIdAsInt();
- }
-
- public Caracteristic getCaracteristic() {
- return caracteristic;
- }
-
- public Serializable getCaracteristicValue() {
- return caracteristicValue;
- }
-
- public String getComment() {
- return batch.getComment();
- }
-
- public Species getSpecies() {
- return batch.getSpecies();
- }
-
- public Date getBeginDate() {
- return cruise.getBeginDate();
- }
-
- public Program getProgram() {
- return cruise.getProgram();
- }
-
- public String getSurveyPart() {
- return cruise.getSurveyPart();
- }
-
- public String getStationNumber() {
- return fishingOperation.getStationNumber();
- }
-
- public Integer getFishingOperationNumber() {
- return fishingOperation.getFishingOperationNumber();
- }
-
- public Gear getGear() {
- return fishingOperation.getGear();
- }
-
- public Vessel getVessel() {
- return fishingOperation.getVessel();
- }
-
- public String getMultirigAggregation() {
- return fishingOperation.getMultirigAggregation();
- }
-
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,457 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.apache.commons.collections.CollectionUtils;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * Model of a catch export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<CatchExportRow> {
-
- public static final String WEIGHT_OR_VOL_TYPE = "Poids";
-
- protected SampleCategoryModel sampleCategoryModel;
-
- public CatchExportModel(char separator,
- SampleCategoryModel sampleCategoryModel,
- DecoratorService decoratorService) {
- super(separator);
- this.sampleCategoryModel = sampleCategoryModel;
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
- newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
- newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
- newColumnForExport("Taxon", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.INTEGER);
- newColumnForExport("Nom_scientifique", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
- newColumnForExport("Commentaire", SpeciesBatch.PROPERTY_COMMENT);
-
- for (SampleCategoryModelEntry entry : sampleCategoryModel.getCategory()) {
- addSampleCategory(entry.getCanonicalLabel(), entry.getOrder());
- }
-
- // mensuration
-
- newNullableColumnForExport("Code_Longueur", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_ID);
- newNullableColumnForExportByDecorator("Libelle_Longueur", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
- newNullableColumnForExport("Taille", CatchExportRow.FREQUENCY_LENGTH_STEP, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("NumOrdre_Taille_H2", CatchExportRow.FREQUENCY_RANK_ORDER, TuttiCsvUtil.INTEGER);
- newNullableColumnForExport("Poids_Classe_Taille", CatchExportRow.FREQUENCY_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Unite_Taille", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_UNIT);
- newNullableColumnForExport("Precision_Mesure", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_PRECISION, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Nbr", CatchExportRow.BATCH_NUMBER, TuttiCsvUtil.INTEGER);
-
- newColumnForExport("Poids_Reference", CatchExportRow.REFERENCE_WEIGHT, TuttiCsvUtil.PRIMITIVE_FLOAT);
- newColumnForExport("Coef_Elev_Espece_Capture", CatchExportRow.RAISING_FACTOR, TuttiCsvUtil.PRIMITIVE_FLOAT);
- }
-
- public void prepareRows(PersistenceService persistenceService,
- List<CatchExportRow> rows,
- Cruise cruise,
- FishingOperation operation,
- BatchContainer<SpeciesBatch> rootSpeciesBatch,
- BatchContainer<BenthosBatch> rootBenthosBatch,
- Float speciesCatchRaisingFactor,
- Float benthosCatchRaisingFactor) {
-
- Caracteristic weightMeasuredCaracteristic = persistenceService.getWeightMeasuredCaracteristic();
- String batchWeightUnit = weightMeasuredCaracteristic.getUnit();
-
- for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) {
- CatchExportRow row = new CatchExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setSpecies(speciesBatch.getSpecies());
- row.setBatchWeightUnit(batchWeightUnit);
-
- if (persistenceService.isVracBatch(speciesBatch)) {
-
- // compute species total weight in catch
-
- Float sortedBatchWeight = TuttiEntities.getValueOrComputedValue(
- speciesBatch.getSampleCategoryWeight(),
- speciesBatch.getSampleCategoryComputedWeight());
-
- float totalBatchWeight = sortedBatchWeight == null ? 0 : speciesCatchRaisingFactor *
- sortedBatchWeight;
-
- prepareSortedRows(persistenceService,
- row,
- rows,
- speciesBatch,
- totalBatchWeight);
- } else {
- prepareUnsortedRows(row, rows, speciesBatch);
- }
-
- }
- for (BenthosBatch benthosBatch : rootBenthosBatch.getChildren()) {
- CatchExportRow row = new CatchExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setSpecies(benthosBatch.getSpecies());
- row.setBatchWeightUnit(batchWeightUnit);
-
- if (persistenceService.isVracBatch(benthosBatch)) {
-
- // compute species total weight in catch
-
- Float sortedBatchWeight = TuttiEntities.getValueOrComputedValue(
- benthosBatch.getSampleCategoryWeight(),
- benthosBatch.getSampleCategoryComputedWeight());
-
- float totalBatchWeight = sortedBatchWeight == null ? 0 : benthosCatchRaisingFactor *
- sortedBatchWeight;
-
- prepareSortedRows(persistenceService,
- row,
- rows,
- benthosBatch,
- totalBatchWeight);
- } else {
- prepareUnsortedRows(row, rows, benthosBatch);
- }
- }
- }
-
- protected void prepareSortedRows(PersistenceService persistenceService,
- CatchExportRow currentRow,
- List<CatchExportRow> rows,
- SpeciesBatch speciesBatch,
- final float totalBatchWeight) {
-
- currentRow.addComment(speciesBatch.getComment());
-
- prepareBatch(currentRow,
- speciesBatch.getSampleCategoryId(),
- speciesBatch.getSampleCategoryValue(),
- speciesBatch.getSampleCategoryWeight(),
- speciesBatch.getSampleCategoryComputedWeight(),
- speciesBatch.getWeight(),
- speciesBatch.getNumber(),
- speciesBatch.getRankOrder());
-
- if (speciesBatch.isChildBatchsEmpty()) {
-
- // on a leaf, get frequencies
-
- List<SpeciesBatchFrequency> speciesBatchFrequency =
- persistenceService.getAllSpeciesBatchFrequency(speciesBatch.getId());
-
- if (CollectionUtils.isEmpty(speciesBatchFrequency)) {
-
- // no frequency
-
- CatchExportRow row = currentRow.copy();
-
- // Get reference weight
-
- Float referenceWeight = TuttiEntities.getValueOrComputedValue(
- speciesBatch.getWeight(),
- speciesBatch.getComputedWeight());
-
- if (referenceWeight == null) {
-
- referenceWeight = TuttiEntities.getValueOrComputedValue(
- speciesBatch.getSampleCategoryWeight(),
- speciesBatch.getSampleCategoryComputedWeight());
- }
- setRaisingFactor(row, totalBatchWeight, referenceWeight);
- rows.add(row);
- } else {
-
- // there is some frequencies
-
- boolean withNoWeightOnFrequencies =
- speciesBatchFrequency.get(0).getWeight() == null;
-
- Float referenceWeight = null;
-
- if (withNoWeightOnFrequencies) {
-
- // no weight on frequencies use upper reference weight
-
- referenceWeight = TuttiEntities.getValueOrComputedValue(
- speciesBatch.getWeight(),
- speciesBatch.getComputedWeight());
-
- if (referenceWeight == null) {
- referenceWeight = TuttiEntities.getValueOrComputedValue(
- speciesBatch.getSampleCategoryWeight(),
- speciesBatch.getSampleCategoryComputedWeight());
- }
- }
-
- for (SpeciesBatchFrequency batchFrequency : speciesBatchFrequency) {
- CatchExportRow row = currentRow.copy();
- row.setSpeciesFrequency(batchFrequency);
- rows.add(row);
-
- if (!withNoWeightOnFrequencies) {
-
- // use concrete frequency weight
- referenceWeight = batchFrequency.getWeight();
- }
-
- setRaisingFactor(row, totalBatchWeight, referenceWeight);
- }
- }
-
- } else {
-
- for (SpeciesBatch childBatch : speciesBatch.getChildBatchs()) {
- prepareSortedRows(persistenceService,
- currentRow,
- rows,
- childBatch,
- totalBatchWeight
- );
- }
- }
-
- // remove last comment (otherwise next brother will have this one too...)
- currentRow.popLastComment();
- }
-
- protected void prepareUnsortedRows(CatchExportRow currentRow,
- List<CatchExportRow> rows,
- SpeciesBatch speciesBatch) {
-
-
- prepareBatch(currentRow,
- speciesBatch.getSampleCategoryId(),
- speciesBatch.getSampleCategoryValue(),
- speciesBatch.getSampleCategoryWeight(),
- speciesBatch.getSampleCategoryComputedWeight(),
- speciesBatch.getWeight(),
- speciesBatch.getNumber(),
- speciesBatch.getRankOrder());
-
- CatchExportRow row = currentRow.copy();
- row.addComment(speciesBatch.getComment());
- float referenceWeight = TuttiEntities.getValueOrComputedValue(
- speciesBatch.getSampleCategoryWeight(),
- speciesBatch.getSampleCategoryComputedWeight());
-
- setRaisingFactor(row, referenceWeight, referenceWeight);
- rows.add(row);
- }
-
- protected void prepareSortedRows(PersistenceService persistenceService,
- CatchExportRow currentRow,
- List<CatchExportRow> rows,
- BenthosBatch benthosBatch,
- final float totalBatchWeight) {
-
- currentRow.addComment(benthosBatch.getComment());
-
- prepareBatch(currentRow,
- benthosBatch.getSampleCategoryId(),
- benthosBatch.getSampleCategoryValue(),
- benthosBatch.getSampleCategoryWeight(),
- benthosBatch.getSampleCategoryComputedWeight(),
- benthosBatch.getWeight(),
- benthosBatch.getNumber(),
- benthosBatch.getRankOrder());
-
- if (benthosBatch.isChildBatchsEmpty()) {
-
- // on a leaf, get frequencies
-
- List<BenthosBatchFrequency> benthosBatchFrequency =
- persistenceService.getAllBenthosBatchFrequency(benthosBatch.getId());
-
- if (CollectionUtils.isEmpty(benthosBatchFrequency)) {
-
- // no frequency
-
- CatchExportRow row = currentRow.copy();
-
- // Get reference weight
-
- Float referenceWeight = TuttiEntities.getValueOrComputedValue(
- benthosBatch.getWeight(),
- benthosBatch.getComputedWeight());
-
- if (referenceWeight == null) {
- referenceWeight = TuttiEntities.getValueOrComputedValue(
- benthosBatch.getSampleCategoryWeight(),
- benthosBatch.getSampleCategoryComputedWeight());
- }
-
- setRaisingFactor(row, totalBatchWeight, referenceWeight);
- rows.add(row);
- } else {
-
- // there is some frequencies
-
- Float referenceWeight = null;
-
- boolean withNoWeightOnFrequencies =
- benthosBatchFrequency.get(0).getWeight() == null;
-
- if (withNoWeightOnFrequencies) {
-
- // no weight on frequencies use upper reference weight
-
- referenceWeight = TuttiEntities.getValueOrComputedValue(
- benthosBatch.getWeight(),
- benthosBatch.getComputedWeight());
-
- if (referenceWeight == null) {
- referenceWeight = TuttiEntities.getValueOrComputedValue(
- benthosBatch.getSampleCategoryWeight(),
- benthosBatch.getSampleCategoryComputedWeight());
- }
- }
-
- for (BenthosBatchFrequency batchFrequency : benthosBatchFrequency) {
- CatchExportRow row = currentRow.copy();
- row.setBenthosFrequency(batchFrequency);
- rows.add(row);
-
- if (!withNoWeightOnFrequencies) {
-
- // use concrete frequency weight
- referenceWeight = batchFrequency.getWeight();
- }
-
- setRaisingFactor(row, totalBatchWeight, referenceWeight);
- }
- }
-
- } else {
-
- for (BenthosBatch childBatch : benthosBatch.getChildBatchs()) {
- prepareSortedRows(persistenceService,
- currentRow,
- rows,
- childBatch,
- totalBatchWeight);
- }
- }
-
- // remove last comment (otherwise next brother will have this one too...)
- currentRow.popLastComment();
- }
-
- protected void prepareUnsortedRows(CatchExportRow currentRow,
- List<CatchExportRow> rows,
- BenthosBatch benthosBatch) {
-
- prepareBatch(currentRow,
- benthosBatch.getSampleCategoryId(),
- benthosBatch.getSampleCategoryValue(),
- benthosBatch.getSampleCategoryWeight(),
- benthosBatch.getSampleCategoryComputedWeight(),
- benthosBatch.getWeight(),
- benthosBatch.getNumber(),
- benthosBatch.getRankOrder());
-
- CatchExportRow row = currentRow.copy();
- row.addComment(benthosBatch.getComment());
-
- Float referenceWeight = TuttiEntities.getValueOrComputedValue(
- benthosBatch.getSampleCategoryWeight(),
- benthosBatch.getSampleCategoryComputedWeight());
-
- setRaisingFactor(row, referenceWeight, referenceWeight);
-
- rows.add(row);
- }
-
- protected void setRaisingFactor(CatchExportRow row,
- float totalBatchWeight,
- Float referenceWeight) {
- row.setReferenceWeight(referenceWeight);
- row.setRaisingFactor(referenceWeight == null ? 1.0f : (totalBatchWeight / referenceWeight));
- }
-
- protected void prepareBatch(CatchExportRow currentRow,
- Integer sampleCategoryId,
- Serializable sampleCategoryValue,
- Float sampleCategoryWeight,
- Float sampleCategoryComputedWeight,
- Float batchWeight,
- Integer batchNumber,
- Integer batchRankOrder) {
- currentRow.setBatchNumber(batchNumber);
-
- ExportSampleCategory<Serializable> sampleCategory =
- new ExportSampleCategory<Serializable>();
- SampleCategoryModelEntry categoryById =
- sampleCategoryModel.getCategoryById(sampleCategoryId);
- sampleCategory.setCategoryDef(categoryById);
- sampleCategory.setCategoryValue(sampleCategoryValue);
- sampleCategory.setCategoryWeight(sampleCategoryWeight);
- sampleCategory.setSampleWeight(batchWeight);
-
- sampleCategory.setComputedWeight(sampleCategoryComputedWeight);
- sampleCategory.setWeightOrVolType(WEIGHT_OR_VOL_TYPE);
- sampleCategory.setRankOrder(batchRankOrder);
-
- currentRow.addSampleCategory(sampleCategory);
- }
-
- protected void addSampleCategory(String headerPrefix, int categoryOrder) {
-
- String categoryName = CatchExportRow.SAMPLE_CATEGORY;
- newIndexNullableColumnForExport(headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- newIndexNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName, categoryOrder, ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER);
- newIndexNullableColumnForExport("Tot_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT);
- newIndexNullableColumnForExport("Ech_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT);
- newIndexNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE);
- newNullableColumnForExport("Unite_Volume_Poids_" + headerPrefix, CatchExportRow.BATCH_WEIGHT_UNIT);
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,254 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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 com.google.common.base.Joiner;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-/**
- * A row in a catch export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class CatchExportRow implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(CatchExportRow.class);
-
- public static final String FREQUENCY_LENGTH_STEP = "frequency.lengthStep";
-
- public static final String FREQUENCY_NUMBER = "frequency.number";
-
- public static final String FREQUENCY_WEIGHT = "frequency.weight";
-
- public static final String FREQUENCY_LENGTH_STEP_CARACTERISTIC = "frequency.lengthStepCaracteristic";
-
- public static final String FREQUENCY_RANK_ORDER = "frequency.rankOrder";
-
- public static final String SAMPLE_CATEGORY = "sampleCategory";
-
- public static final String REFERENCE_WEIGHT = "referenceWeight";
-
- public static final String RAISING_FACTOR = "raisingFactor";
-
- public static final String BATCH_NUMBER = "batchNumber";
-
- public static final String BATCH_WEIGHT_UNIT = "batchWeightUnit";
-
- protected Cruise cruise;
-
- protected FishingOperation fishingOperation;
-
- protected final List<ExportSampleCategory> sampleCategory = Lists.newLinkedList();
-
- protected SpeciesBatchFrequency speciesFrequency;
-
- protected BenthosBatchFrequency benthosFrequency;
-
- protected Species species;
-
- protected Float referenceWeight;
-
- protected float raisingFactor;
-
- protected Integer batchNumber;
-
- protected String batchWeightUnit;
-
- protected final List<String> comment = Lists.newArrayList();
-
- public void setCruise(Cruise cruise) {
- this.cruise = cruise;
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- public void setReferenceWeight(Float referenceWeight) {
- this.referenceWeight = referenceWeight;
- }
-
- public void setRaisingFactor(float raisingFactor) {
- this.raisingFactor = raisingFactor;
- }
-
- public void setBatchNumber(Integer batchNumber) {
- this.batchNumber = batchNumber;
- }
-
- public void addSampleCategory(ExportSampleCategory sampleCategory) {
- int order = sampleCategory.getCategoryDef().getOrder();
- while (this.sampleCategory.size() <= order) {
- this.sampleCategory.add(null);
- }
- this.sampleCategory.set(order, sampleCategory);
- }
-
- public void setSpeciesFrequency(SpeciesBatchFrequency speciesFrequency) {
- Preconditions.checkNotNull(speciesFrequency);
- this.speciesFrequency = speciesFrequency;
- this.batchNumber = speciesFrequency.getNumber();
- }
-
- public void setBenthosFrequency(BenthosBatchFrequency benthosFrequency) {
- Preconditions.checkNotNull(benthosFrequency);
- this.benthosFrequency = benthosFrequency;
- this.batchNumber = benthosFrequency.getNumber();
- }
-
- public Date getBeginDate() {
- return cruise.getBeginDate();
- }
-
- public Program getProgram() {
- return cruise.getProgram();
- }
-
- public String getSurveyPart() {
- return cruise.getSurveyPart();
- }
-
- public Vessel getVessel() {
- return cruise.getVessel();
- }
-
- public String getStationNumber() {
- return fishingOperation.getStationNumber();
- }
-
- public Integer getFishingOperationNumber() {
- return fishingOperation.getFishingOperationNumber();
- }
-
- public Gear getGear() {
- return fishingOperation.getGear();
- }
-
- public String getMultirigAggregation() {
- return fishingOperation.getMultirigAggregation();
- }
-
- public Object getFrequency() {
- return speciesFrequency == null ? benthosFrequency : speciesFrequency;
- }
-
- public List<ExportSampleCategory> getSampleCategory() {
- return sampleCategory;
- }
-
- public Species getSpecies() {
- return species;
- }
-
- public void setSpecies(Species species) {
- this.species = species;
- }
-
- public Float getReferenceWeight() {
- return referenceWeight;
- }
-
- public float getRaisingFactor() {
- return raisingFactor;
- }
-
- public Integer getBatchNumber() {
- return batchNumber;
- }
-
- public String getBatchWeightUnit() {
- return batchWeightUnit;
- }
-
- public void setBatchWeightUnit(String batchWeightUnit) {
- this.batchWeightUnit = batchWeightUnit;
- }
-
- public CatchExportRow copy() {
- CatchExportRow result = new CatchExportRow();
- result.setCruise(cruise);
- result.setFishingOperation(fishingOperation);
-// result.setSpeciesCategory(speciesCategory);
- result.sampleCategory.addAll(sampleCategory);
- if (benthosFrequency != null) {
- result.setBenthosFrequency(benthosFrequency);
- }
- if (speciesFrequency != null) {
- result.setSpeciesFrequency(speciesFrequency);
- }
- result.setSpecies(species);
- result.setRaisingFactor(raisingFactor);
- result.setReferenceWeight(referenceWeight);
- result.setBatchNumber(batchNumber);
- result.setBatchWeightUnit(batchWeightUnit);
- result.comment.addAll(comment);
-
- return result;
- }
-
- public void addComment(String comment) {
- String safeComment = StringUtils.isEmpty(comment) ? "" : comment;
- if (log.isDebugEnabled()) {
- log.debug("Add comment: " + safeComment);
- }
- this.comment.add(safeComment);
- }
-
- public void popLastComment() {
- if (!comment.isEmpty()) {
- this.comment.remove(this.comment.size() - 1);
- }
- }
-
- public String getComment() {
- String result;
- if (comment.isEmpty()) {
- result = "";
- } else {
- result = Joiner.on('|').join(comment);
- }
- return result;
- }
-}
\ No newline at end of file
Added: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,53 @@
+package fr.ifremer.tutti.service.export;
+
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
+
+/**
+ * To store a species or batch entry within his speices informations,
+ * his sorted weight, total weight and percentage amoong the total catch
+ * weight.
+ *
+ * @since 2.10
+ */
+public class ExportBatchEntry {
+
+ protected final SpeciesAbleBatch batch;
+
+ protected float sortedWeight;
+
+ protected float totalWeight;
+
+ protected int totalNumber;
+
+ public ExportBatchEntry(SpeciesAbleBatch batch) {
+ this.batch = batch;
+ }
+
+ public SpeciesAbleBatch getBatch() {
+ return batch;
+ }
+
+ public void addSortedWeight(float weight) {
+ sortedWeight += weight;
+ }
+
+ public void addTotalWeight(float weight) {
+ totalWeight += weight;
+ }
+
+ public void addNumber(int number) {
+ totalNumber += number;
+ }
+
+ public float getSortedWeight() {
+ return sortedWeight;
+ }
+
+ public float getTotalWeight() {
+ return totalWeight;
+ }
+
+ public int getTotalNumber() {
+ return totalNumber;
+ }
+}
Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportSampleCategory.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportSampleCategory.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportSampleCategory.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,95 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-
-import java.io.Serializable;
-
-/**
- * Export sample category (extends {@link SampleCategory} to some computed
- * stuff.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class ExportSampleCategory<S extends Serializable> extends SampleCategory<S> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_CATEGORY_CARACTERISTIC = "categoryCaracteristic";
-
- public static final String PROPERTY_CATEGORY_VALUE = "categoryValue";
-
- public static final String PROPERTY_CATEGORY_WEIGHT = "categoryWeight";
-
- public static final String PROPERTY_NUMBER = "number";
-
- public static final String PROPERTY_COMPUTED_WEIGHT = "computedWeight";
-
- public static final String PROPERTY_COMPUTED_NUMBER = "computedNumber";
-
- public static final String PROPERTY_WEIGHT_OR_VOL_TYPE = "weightOrVolType";
-
- public static final String PROPERTY_RANK_ORDER = "rankOrder";
-
- public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
-
- private Integer rankOrder;
-
- private String weightOrVolType;
-
- private Float sampleWeight;
-
- public String getWeightOrVolType() {
- return weightOrVolType;
- }
-
- public void setWeightOrVolType(String weightOrVolType) {
- this.weightOrVolType = weightOrVolType;
- }
-
- public Integer getRankOrder() {
- return rankOrder;
- }
-
- public void setRankOrder(Integer rankOrder) {
- this.rankOrder = rankOrder;
- }
-
- public Float getSampleWeight() {
- return sampleWeight;
- }
-
- public void setSampleWeight(Float sampleWeight) {
- this.sampleWeight = sampleWeight;
- }
-
- public Caracteristic getCategoryCaracteristic() {
- return categoryDef.getCaracteristic();
- }
-
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/GearCaracteristicExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/GearCaracteristicExportModel.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/GearCaracteristicExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,76 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-/**
- * To export gear caracteristics.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.3.2
- */
-public class GearCaracteristicExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<GearCaracteristicExportRow> {
-
- public GearCaracteristicExportModel(char separator, DecoratorService decoratorService) {
- super(separator);
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Engin", GearCaracteristicExportRow.PROPERTY_GEAR, Gear.PROPERTY_NAME);
- newColumnForExport("Code_PMFM", GearCaracteristicExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
- newColumnForExportByDecorator("Libelle_PMFM", GearCaracteristicExportRow.PROPERTY_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
- newColumnForExport("Valeur", GearCaracteristicExportRow.PROPERTY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- }
-
- public void prepareRows(List<GearCaracteristicExportRow> rows, Cruise cruise,
- Gear gear) {
- CaracteristicMap caracteristics = gear.getCaracteristics();
- if (caracteristics != null) {
- for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
- Caracteristic caracteristic = entry.getKey();
- Serializable value = entry.getValue();
- GearCaracteristicExportRow row = new GearCaracteristicExportRow();
- row.setCruise(cruise);
- row.setGear(gear);
- row.setCaracteristic(caracteristic);
- row.setValue(value);
- rows.add(row);
- }
- }
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/GearCaracteristicExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/GearCaracteristicExportRow.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/GearCaracteristicExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,98 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * A row in a gear caracteristics export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.3.2
- */
-public class GearCaracteristicExportRow implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_GEAR = "gear";
-
- public static final String PROPERTY_CARACTERISTIC = "caracteristic";
-
- public static final String PROPERTY_VALUE = "value";
-
- protected Cruise cruise;
-
- protected Gear gear;
-
- protected Caracteristic caracteristic;
-
- private Serializable value;
-
- public void setCruise(Cruise cruise) {
- this.cruise = cruise;
- }
-
- public void setGear(Gear gear) {
- this.gear = gear;
- }
-
- public void setCaracteristic(Caracteristic caracteristic) {
- this.caracteristic = caracteristic;
- }
-
- public void setValue(Serializable value) {
- this.value = value;
- }
-
- public Date getBeginDate() {
- return cruise.getBeginDate();
- }
-
- public Program getProgram() {
- return cruise.getProgram();
- }
-
- public String getSurveyPart() {
- return cruise.getSurveyPart();
- }
-
- public Gear getGear() {
- return gear;
- }
-
- public Caracteristic getCaracteristic() {
- return caracteristic;
- }
-
- public Serializable getValue() {
- return value;
- }
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,170 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Model of a individual observation export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.1
- */
-public class IndividualObservationExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<IndividualObservationExportRow> {
-
-// protected final Caracteristic caracteristicSample;
-//
-// protected final Caracteristic caracteristicOtolithe;
-
- protected final Caracteristic caracteristicWeight;
-
- protected final Caracteristic caracteristicPmfmId;
-
- public IndividualObservationExportModel(
- char separator,
-// Caracteristic caracteristicSample,
-// Caracteristic caracteristicOtolithe,
- Caracteristic caracteristicWeight,
- Caracteristic caracteristicPmfmId) {
- super(separator);
-
-// this.caracteristicSample = caracteristicSample;
-// this.caracteristicOtolithe = caracteristicOtolithe;
- this.caracteristicWeight = caracteristicWeight;
- this.caracteristicPmfmId = caracteristicPmfmId;
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
- newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
- newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
-
- newColumnForExport("BatchId", IndividualObservationExportRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("ReferenceTaxonId", IndividualObservationBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("ReferenceTaxonName", IndividualObservationBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
- newColumnForExport("Commentaire", IndividualObservationBatch.PROPERTY_COMMENT);
- newColumnForExport("CaracteristicId", IndividualObservationExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
- newColumnForExport("CaracteristicValue", IndividualObservationExportRow.PROPERTY_CARACTERISTIC_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- }
-
- public void prepareRows(PersistenceService persistenceService,
- List<IndividualObservationExportRow> rows,
- Cruise cruise,
- FishingOperation operation) {
-
- List<IndividualObservationBatch> observations =
- persistenceService.getAllIndividualObservationBatch(operation.getId());
-
- if (CollectionUtils.isNotEmpty(observations)) {
- for (IndividualObservationBatch child : observations) {
-
-// addCaracteristicRow(rows,
-// cruise,
-// operation,
-// child,
-// caracteristicSample,
-// child.getSamplingCode());
-//
-// addCaracteristicRow(rows,
-// cruise,
-// operation,
-// child,
-// caracteristicOtolithe,
-// child.getCalcifiedPieceSamplingCode());
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicWeight,
- child.getWeight());
-
- if (child.getLengthStepCaracteristic() != null) {
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicPmfmId,
- child.getLengthStepCaracteristic().getIdAsInt());
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- child.getLengthStepCaracteristic(),
- child.getSize());
- }
-
- CaracteristicMap caracteristics = child.getCaracteristics();
- if (MapUtils.isNotEmpty(caracteristics)) {
- for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- entry.getKey(),
- entry.getValue());
- }
- }
- }
- }
- }
-
- private void addCaracteristicRow(List<IndividualObservationExportRow> rows,
- Cruise cruise,
- FishingOperation operation,
- IndividualObservationBatch child,
- Caracteristic caracteristic,
- Serializable caracteristicValue) {
- if (caracteristicValue != null) {
-
- IndividualObservationExportRow row = new IndividualObservationExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setBatch(child);
- row.setCaracteristic(caracteristic);
- row.setCaracteristicValue(caracteristicValue);
- rows.add(row);
- }
- }
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportRow.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,138 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * A row in a individual observation export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.1
- */
-public class IndividualObservationExportRow implements Serializable {
-
- public static final String PROPERTY_BATCH = "batch";
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_BATCH_ID = "batchId";
-
- public static final String PROPERTY_CARACTERISTIC = "caracteristic";
-
- public static final String PROPERTY_CARACTERISTIC_VALUE = "caracteristicValue";
-
- protected Cruise cruise;
-
- protected FishingOperation fishingOperation;
-
- protected IndividualObservationBatch batch;
-
- protected Caracteristic caracteristic;
-
- protected Serializable caracteristicValue;
-
- public void setCruise(Cruise cruise) {
- this.cruise = cruise;
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- public void setBatch(IndividualObservationBatch batch) {
- this.batch = batch;
- }
-
- public void setCaracteristic(Caracteristic caracteristic) {
- this.caracteristic = caracteristic;
- }
-
- public void setCaracteristicValue(Serializable caracteristicValue) {
- this.caracteristicValue = caracteristicValue;
- }
-
- public Integer getBatchId() {
- return batch.getIdAsInt();
- }
-
- public Caracteristic getCaracteristic() {
- return caracteristic;
- }
-
- public Serializable getCaracteristicValue() {
- return caracteristicValue;
- }
-
- public String getComment() {
- return batch.getComment();
- }
-
- public Date getBeginDate() {
- return cruise.getBeginDate();
- }
-
- public Program getProgram() {
- return cruise.getProgram();
- }
-
- public String getSurveyPart() {
- return cruise.getSurveyPart();
- }
-
- public String getStationNumber() {
- return fishingOperation.getStationNumber();
- }
-
- public Integer getFishingOperationNumber() {
- return fishingOperation.getFishingOperationNumber();
- }
-
- public Gear getGear() {
- return fishingOperation.getGear();
- }
-
- public Vessel getVessel() {
- return fishingOperation.getVessel();
- }
-
- public String getMultirigAggregation() {
- return fishingOperation.getMultirigAggregation();
- }
-
- public Species getSpecies() {
- return batch.getSpecies();
- }
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,86 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.BatchContainer;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.apache.commons.collections.CollectionUtils;
-
-import java.util.List;
-
-/**
- * Model of a marine litter export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.1
- */
-public class MarineLitterExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<MarineLitterExportRow> {
-
- public MarineLitterExportModel(char separator) {
- super(separator);
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
- newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
- newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
-
- newColumnForExport("MarineLitterCategory", MarineLitterBatch.PROPERTY_MARINE_LITTER_CATEGORY, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- newColumnForExport("MarineLitterSizeCategory", MarineLitterBatch.PROPERTY_MARINE_LITTER_SIZE_CATEGORY, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- newColumnForExport("Number", MarineLitterBatch.PROPERTY_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Weight", MarineLitterBatch.PROPERTY_WEIGHT, TuttiCsvUtil.FLOAT);
- newColumnForExport("Commentaire", MarineLitterBatch.PROPERTY_COMMENT);
- }
-
- public void prepareRows(PersistenceService persistenceService,
- List<MarineLitterExportRow> rows,
- Cruise cruise,
- FishingOperation operation) {
-
- BatchContainer<MarineLitterBatch> rootMarineLitterBatch =
- persistenceService.getRootMarineLitterBatch(operation.getId());
-
- List<MarineLitterBatch> children = rootMarineLitterBatch.getChildren();
- if (CollectionUtils.isNotEmpty(children)) {
- for (MarineLitterBatch child : children) {
- MarineLitterExportRow row = new MarineLitterExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setBatch(child);
- rows.add(row);
- }
- }
- }
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportRow.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,121 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * A row in a marine litter export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.1
- */
-public class MarineLitterExportRow implements Serializable {
-
- public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
-
- public static final String PROPERTY_BATCH = "batch";
-
- private static final long serialVersionUID = 1L;
-
- protected Cruise cruise;
-
- protected FishingOperation fishingOperation;
-
- protected MarineLitterBatch batch;
-
- public void setCruise(Cruise cruise) {
- this.cruise = cruise;
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- public void setBatch(MarineLitterBatch batch) {
- this.batch = batch;
- }
-
- public CaracteristicQualitativeValue getMarineLitterCategory() {
- return batch.getMarineLitterCategory();
- }
-
- public CaracteristicQualitativeValue getMarineLitterSizeCategory() {
- return batch.getMarineLitterSizeCategory();
- }
-
- public Integer getNumber() {
- return batch.getNumber();
- }
-
- public Float getWeight() {
- return batch.getWeight();
- }
-
- public String getComment() {
- return batch.getComment();
- }
-
- public Date getBeginDate() {
- return cruise.getBeginDate();
- }
-
- public Program getProgram() {
- return cruise.getProgram();
- }
-
- public String getSurveyPart() {
- return cruise.getSurveyPart();
- }
-
- public String getStationNumber() {
- return fishingOperation.getStationNumber();
- }
-
- public Integer getFishingOperationNumber() {
- return fishingOperation.getFishingOperationNumber();
- }
-
- public Gear getGear() {
- return fishingOperation.getGear();
- }
-
- public Vessel getVessel() {
- return fishingOperation.getVessel();
- }
-
- public String getMultirigAggregation() {
- return fishingOperation.getMultirigAggregation();
- }
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportModel.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,166 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.decorator.Decorator;
-
-import java.util.List;
-
-/**
- * Model of a operation export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class OperationExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<OperationExportRow> {
-
-
- protected final Caracteristic verticalOpeningCaracteristic;
-
- protected final Caracteristic horizontalOpeningWingCaracteristic;
-
- protected final Caracteristic horizontalOpeningDoorCaracteristic;
-
- public OperationExportModel(char separator,
- Caracteristic verticalOpeningCaracteristic,
- Caracteristic horizontalOpeningWingCaracteristic,
- Caracteristic horizontalOpeningDoorCaracteristic,
- Decorator<Vessel> vesselDecorator) {
- super(separator);
- this.verticalOpeningCaracteristic = verticalOpeningCaracteristic;
- this.horizontalOpeningWingCaracteristic = horizontalOpeningWingCaracteristic;
- this.horizontalOpeningDoorCaracteristic = horizontalOpeningDoorCaracteristic;
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
-
- newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
- newColumnForExport("Navire", FishingOperation.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
- newColumnForExport("DateDeb_Op", FishingOperation.PROPERTY_GEAR_SHOOTING_START_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
- newColumnForExport("LatDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LATITUDE, TuttiCsvUtil.FLOAT);
- newColumnForExport("LongDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LONGITUDE, TuttiCsvUtil.FLOAT);
- newColumnForExport("DateFin_Op", FishingOperation.PROPERTY_GEAR_SHOOTING_END_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
- newColumnForExport("LatFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_LATITUDE, TuttiCsvUtil.FLOAT);
- newColumnForExport("LongFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_LONGITUDE, TuttiCsvUtil.FLOAT);
- newColumnForExport("Duree", OperationExportRow.PROPERTY_DURATION);
- newColumnForExport("Strate", FishingOperation.PROPERTY_STRATA, TuttiLocation.PROPERTY_NAME, "NA");
- newColumnForExport("Sous-Strate", FishingOperation.PROPERTY_SUB_STRATA, TuttiLocation.PROPERTY_NAME, "NA");
- newColumnForExport("Localite", FishingOperation.PROPERTY_LOCATION, TuttiLocation.PROPERTY_NAME, "NA");
- newColumnForExport("Validite_OP", FishingOperation.PROPERTY_FISHING_OPERATION_VALID, TuttiCsvUtil.BOOLEAN);
- newColumnForExport("Rectiligne", FishingOperation.PROPERTY_FISHING_OPERATION_RECTILIGNE, TuttiCsvUtil.BOOLEAN);
- newColumnForExport("Distance", FishingOperation.PROPERTY_TRAWL_DISTANCE, TuttiCsvUtil.FLOAT);
- newColumnForExport("Ouv_Verticale", OperationExportRow.PROPERTY_VERTICAL_OPENING_GEAR_USE_FEATURE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- newColumnForExport("Ouv_Horizontale_Ailes", OperationExportRow.PROPERTY_HORIZONTAL_OPENING_WING_GEAR_USE_FEATURE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- newColumnForExport("Ouv_Horizontale_Panneaux", OperationExportRow.PROPERTY_HORIZONTAL_OPENING_DOOR_GEAR_USE_FEATURE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- newColumnForExport("Saisisseur", FishingOperation.PROPERTY_RECORDER_PERSON, TuttiCsvUtil.LIST_PERSON_FORMATTER);
- newColumnForExport("NavireAssocie", FishingOperation.PROPERTY_SECONDARY_VESSEL, TuttiCsvUtil.newListVesselFormatter(vesselDecorator));
- newColumnForExport("Commentaire", FishingOperation.PROPERTY_COMMENT);
-
- newNullableColumnForExport("Poids_Total", OperationExportRow.PROPERTY_CATCH_TOTAL_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Vrac", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Vrac_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_HorsVrac", OperationExportRow.PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_HorsVrac_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Non_Trie", OperationExportRow.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Non_Trie_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Tremis", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Tremis_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Carroussel", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Carroussel_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece", OperationExportRow.PROPERTY_SPECIES_TOTAL_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Espece_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece_Vrac", OperationExportRow.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Espece_Vrac_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece_Vrac_Trie", OperationExportRow.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Espece_Vrac_Trie_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece_HorsVrac", OperationExportRow.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Espece_HorsVrac_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece_Inerte_Trie", OperationExportRow.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Espece_Inerte_Trie_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece_Vivant_non_detaille_trie", OperationExportRow.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Espece_Vivant_non_detaille_trie_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos", OperationExportRow.PROPERTY_BENTHOS_TOTAL_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Benthos_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos_Vrac", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Benthos_Vrac_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos_Vrac_Trie", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Benthos_Vrac_Trie_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos_HorsVrac", OperationExportRow.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Benthos_HorsVrac_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos_Inerte_Trie", OperationExportRow.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Benthos_Inerte_Trie_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos_Vivant_non_detaille_trie", OperationExportRow.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Macro_Dechet", OperationExportRow.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Poids_Total_Macro_Dechet_Calcule", OperationExportRow.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
- }
-
- public void prepareRows(List<OperationExportRow> rows,
- Cruise cruise,
- FishingOperation operation,
- CatchBatch catchBatch) {
-
- OperationExportRow row = new OperationExportRow(
- verticalOpeningCaracteristic,
- horizontalOpeningWingCaracteristic,
- horizontalOpeningDoorCaracteristic);
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setCatchBatch(catchBatch);
- rows.add(row);
-
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,499 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Person;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-/**
- * A row in a operation export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class OperationExportRow implements Serializable {
-
- public static final String PROPERTY_DURATION = "duration";
-
- public static final String PROPERTY_VERTICAL_OPENING_GEAR_USE_FEATURE = "verticalOpeningGearUseFeature";
-
- public static final String PROPERTY_HORIZONTAL_OPENING_WING_GEAR_USE_FEATURE = "horizontalOpeningWingGearUseFeature";
-
- public static final String PROPERTY_HORIZONTAL_OPENING_DOOR_GEAR_USE_FEATURE = "horizontalOpeningDoorGearUseFeature";
-
- public static final String PROPERTY_CATCH_TOTAL_WEIGHT = "catchTotalWeight";
-
- public static final String PROPERTY_CATCH_TOTAL_WEIGHT_COMPUTED = "catchTotalWeightComputed";
-
- public static final String PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT = "catchTotalSortedTremisWeight";
-
- public static final String PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT_COMPUTED = "catchTotalSortedTremisWeightComputed";
-
- public static final String PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT = "catchTotalSortedCarousselWeight";
-
- public static final String PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT_COMPUTED = "catchTotalSortedCarousselWeightComputed";
-
- public static final String PROPERTY_CATCH_TOTAL_SORTED_WEIGHT = "catchTotalSortedWeight";
-
- public static final String PROPERTY_CATCH_TOTAL_SORTED_WEIGHT_COMPUTED = "catchTotalSortedWeightComputed";
-
- public static final String PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT = "catchTotalUnsortedWeight";
-
- public static final String PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT_COMPUTED = "catchTotalUnsortedWeightComputed";
-
- public static final String PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT = "catchTotalRejectedWeight";
-
- public static final String PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT_COMPUTED = "catchTotalRejectedWeightComputed";
-
-
- public static final String PROPERTY_SPECIES_TOTAL_WEIGHT = "speciesTotalWeight";
-
- public static final String PROPERTY_SPECIES_TOTAL_WEIGHT_COMPUTED = "speciesTotalWeightComputed";
-
- public static final String PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT = "speciesTotalSortedWeight";
-
- public static final String PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT_COMPUTED = "speciesTotalSortedWeightComputed";
-
- public static final String PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT = "speciesTotalUnsortedWeight";
-
- public static final String PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT_COMPUTED = "speciesTotalUnsortedWeightComputed";
-
- public static final String PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT = "speciesTotalSampleSortedWeight";
-
- public static final String PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED = "speciesTotalSampleSortedWeightComputed";
-
- public static final String PROPERTY_SPECIES_TOTAL_INERT_WEIGHT = "speciesTotalInertWeight";
-
- public static final String PROPERTY_SPECIES_TOTAL_INERT_WEIGHT_COMPUTED = "speciesTotalInertWeightComputed";
-
- public static final String PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT = "speciesTotalLivingNotItemizedWeight";
-
- public static final String PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED = "speciesTotalLivingNotItemizedWeightComputed";
-
- public static final String PROPERTY_BENTHOS_TOTAL_WEIGHT = "benthosTotalWeight";
-
- public static final String PROPERTY_BENTHOS_TOTAL_WEIGHT_COMPUTED = "benthosTotalWeightComputed";
-
- public static final String PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT = "benthosTotalSortedWeight";
-
- public static final String PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT_COMPUTED = "benthosTotalSortedWeightComputed";
-
- public static final String PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT = "benthosTotalUnsortedWeight";
-
- public static final String PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT_COMPUTED = "benthosTotalUnsortedWeightComputed";
-
- public static final String PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT = "benthosTotalSampleSortedWeight";
-
- public static final String PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED = "benthosTotalSampleSortedWeightComputed";
-
- public static final String PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT = "benthosTotalInertWeight";
-
- public static final String PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT_COMPUTED = "benthosTotalInertWeightComputed";
-
- public static final String PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT = "benthosTotalLivingNotItemizedWeight";
-
- public static final String PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED = "benthosTotalLivingNotItemizedWeightComputed";
-
- public static final String PROPERTY_MARINE_LITTER_TOTAL_WEIGHT = "marineLitterTotalWeight";
-
- public static final String PROPERTY_MARINE_LITTER_TOTAL_WEIGHT_COMPUTED = "marineLitterTotalWeightComputed";
-
- private static final long serialVersionUID = 1L;
-
- protected Cruise cruise;
-
- protected FishingOperation fishingOperation;
-
- protected CatchBatch catchBatch;
-
- private Caracteristic verticalOpeningCaracteristic;
-
- private Caracteristic horizontalOpeningWingCaracteristic;
-
- private Caracteristic horizontalOpeningDoorCaracteristic;
-
- public OperationExportRow(Caracteristic verticalOpeningCaracteristic,
- Caracteristic horizontalOpeningWingCaracteristic,
- Caracteristic horizontalOpeningDoorCaracteristic) {
-
- this.verticalOpeningCaracteristic = verticalOpeningCaracteristic;
- this.horizontalOpeningWingCaracteristic = horizontalOpeningWingCaracteristic;
- this.horizontalOpeningDoorCaracteristic = horizontalOpeningDoorCaracteristic;
- }
-
- public void setCruise(Cruise cruise) {
- this.cruise = cruise;
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- public void setCatchBatch(CatchBatch catchBatch) {
- this.catchBatch = catchBatch;
- }
-
- public Date getBeginDate() {
- return cruise.getBeginDate();
- }
-
- public Program getProgram() {
- return cruise.getProgram();
- }
-
- public String getSurveyPart() {
- return cruise.getSurveyPart();
- }
-
- public String getStationNumber() {
- return fishingOperation.getStationNumber();
- }
-
- public Integer getFishingOperationNumber() {
- return fishingOperation.getFishingOperationNumber();
- }
-
- public String getMultirigAggregation() {
- return fishingOperation.getMultirigAggregation();
- }
-
- public Gear getGear() {
- return fishingOperation.getGear();
- }
-
- public Vessel getVessel() {
- return fishingOperation.getVessel();
- }
-
- public Date getGearShootingStartDate() {
- return fishingOperation.getGearShootingStartDate();
- }
-
- public Float getGearShootingStartLatitude() {
- return fishingOperation.getGearShootingStartLatitude();
- }
-
- public Float getGearShootingStartLongitude() {
- return fishingOperation.getGearShootingStartLongitude();
- }
-
- public Date getGearShootingEndDate() {
- return fishingOperation.getGearShootingEndDate();
- }
-
- public Float getGearShootingEndLatitude() {
- return fishingOperation.getGearShootingEndLatitude();
- }
-
- public Float getGearShootingEndLongitude() {
- return fishingOperation.getGearShootingEndLongitude();
- }
-
- public TuttiLocation getStrata() {
- return fishingOperation.getStrata();
- }
-
- public TuttiLocation getSubStrata() {
- return fishingOperation.getSubStrata();
- }
-
- public TuttiLocation getLocation() {
- return fishingOperation.getLocation();
- }
-
- public Boolean getFishingOperationValid() {
- return fishingOperation.getFishingOperationValid();
- }
-
- public boolean isFishingOperationRectiligne() {
- return fishingOperation.isFishingOperationRectiligne();
- }
-
- public Float getTrawlDistance() {
- return fishingOperation.getTrawlDistance();
- }
-
- public String getComment() {
- return fishingOperation.getComment();
- }
-
- public List<Person> getRecorderPerson() {
- return fishingOperation.getRecorderPerson();
- }
-
- public List<Vessel> getSecondaryVessel() {
- return fishingOperation.getSecondaryVessel();
- }
-
- public String getDuration() {
- return TuttiEntities.getDuration(
- getGearShootingStartDate(),
- getGearShootingEndDate(),
- "mm");
- }
-
- public Serializable getVerticalOpeningGearUseFeature() {
- Serializable result = getGearUseFeature(verticalOpeningCaracteristic);
- return result;
- }
-
- public Serializable getHorizontalOpeningWingGearUseFeature() {
- Serializable result = getGearUseFeature(horizontalOpeningWingCaracteristic);
- return result;
- }
-
- public Serializable getHorizontalOpeningDoorGearUseFeature() {
- Serializable result = getGearUseFeature(horizontalOpeningDoorCaracteristic);
- return result;
- }
-
- public Float getCatchTotalWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getCatchTotalWeight(),
- catchBatch.getCatchTotalComputedWeight());
- }
-
- public Boolean getCatchTotalWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getCatchTotalWeight(),
- catchBatch.getCatchTotalComputedWeight());
- }
-
- public Float getCatchTotalSortedTremisWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getCatchTotalSortedTremisWeight(), null);
- }
-
- public Boolean getCatchTotalSortedTremisWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getCatchTotalSortedTremisWeight(), null);
- }
-
- public Float getCatchTotalSortedCarousselWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getCatchTotalSortedCarousselWeight(), null);
- }
-
- public Boolean getCatchTotalSortedCarousselWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getCatchTotalSortedCarousselWeight(), null);
- }
-
- public Float getCatchTotalSortedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- null, catchBatch.getCatchTotalSortedComputedWeight());
- }
-
- public Boolean getCatchTotalSortedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- null, catchBatch.getCatchTotalSortedComputedWeight());
- }
-
- public Float getCatchTotalUnsortedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- null, catchBatch.getCatchTotalUnsortedComputedWeight());
- }
-
- public Boolean getCatchTotalUnsortedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- null, catchBatch.getCatchTotalUnsortedComputedWeight());
- }
-
- public Float getCatchTotalRejectedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getCatchTotalRejectedWeight(),
- catchBatch.getCatchTotalRejectedComputedWeight());
- }
-
- public Boolean getCatchTotalRejectedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getCatchTotalRejectedWeight(),
- catchBatch.getCatchTotalRejectedComputedWeight());
- }
-
- public Float getSpeciesTotalWeight() {
- return TuttiEntities.getValueOrComputedValue(
- null, catchBatch.getSpeciesTotalComputedWeight());
- }
-
- public Boolean getSpeciesTotalWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- null, catchBatch.getSpeciesTotalComputedWeight());
- }
-
- public Float getSpeciesTotalSortedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalSortedWeight(),
- catchBatch.getSpeciesTotalSortedComputedWeight());
- }
-
- public Boolean getSpeciesTotalSortedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getSpeciesTotalSortedWeight(),
- catchBatch.getSpeciesTotalSortedComputedWeight());
- }
-
- public Float getSpeciesTotalUnsortedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- null, catchBatch.getSpeciesTotalUnsortedComputedWeight());
- }
-
- public Boolean getSpeciesTotalUnsortedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- null, catchBatch.getSpeciesTotalUnsortedComputedWeight());
- }
-
- public Float getSpeciesTotalSampleSortedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalSampleSortedComputedWeight(),
- catchBatch.getSpeciesTotalSampleSortedComputedWeight());
- }
-
- public Boolean getSpeciesTotalSampleSortedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- null, catchBatch.getSpeciesTotalSampleSortedComputedWeight());
- }
-
- public Float getSpeciesTotalInertWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalInertWeight(),
- catchBatch.getSpeciesTotalInertComputedWeight());
- }
-
- public Boolean getSpeciesTotalInertWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getSpeciesTotalInertWeight(),
- catchBatch.getSpeciesTotalInertComputedWeight());
- }
-
- public Float getSpeciesTotalLivingNotItemizedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
- catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
- }
-
- public Boolean getSpeciesTotalLivingNotItemizedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
- catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
- }
-
- public Float getBenthosTotalWeight() {
- return TuttiEntities.getValueOrComputedValue(
- null, catchBatch.getBenthosTotalComputedWeight());
- }
-
- public Boolean getBenthosTotalWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- null, catchBatch.getBenthosTotalComputedWeight());
- }
-
- public Float getBenthosTotalSortedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalSortedWeight(),
- catchBatch.getBenthosTotalSortedComputedWeight());
- }
-
- public Boolean getBenthosTotalSortedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getBenthosTotalSortedWeight(),
- catchBatch.getBenthosTotalSortedComputedWeight());
- }
-
- public Float getBenthosTotalUnsortedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- null, catchBatch.getBenthosTotalUnsortedComputedWeight());
- }
-
- public Boolean getBenthosTotalUnsortedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- null, catchBatch.getBenthosTotalUnsortedComputedWeight());
- }
-
- public Float getBenthosTotalSampleSortedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- null, catchBatch.getBenthosTotalSampleSortedComputedWeight());
- }
-
- public Boolean getBenthosTotalSampleSortedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- null, catchBatch.getBenthosTotalSampleSortedComputedWeight());
- }
-
- public Float getBenthosTotalInertWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalInertWeight(),
- catchBatch.getBenthosTotalInertComputedWeight());
- }
-
- public Boolean getBenthosTotalInertWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getBenthosTotalInertWeight(),
- catchBatch.getBenthosTotalInertComputedWeight());
- }
-
- public Float getBenthosTotalLivingNotItemizedWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalLivingNotItemizedWeight(),
- catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
- }
-
- public Boolean getBenthosTotalLivingNotItemizedWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getBenthosTotalLivingNotItemizedWeight(),
- catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
- }
-
- public Float getMarineLitterTotalWeight() {
- return TuttiEntities.getValueOrComputedValue(
- catchBatch.getMarineLitterTotalWeight(),
- catchBatch.getMarineLitterTotalComputedWeight());
- }
-
- public Boolean getMarineLitterTotalWeightComputed() {
- return TuttiEntities.getValueOrComputedValueComputed(
- catchBatch.getMarineLitterTotalWeight(),
- catchBatch.getMarineLitterTotalComputedWeight());
- }
-
- protected Serializable getGearUseFeature(Caracteristic caracteristic) {
- CaracteristicMap gearUseFeatures = fishingOperation.getGearUseFeatures();
- Serializable serializable = gearUseFeatures == null ? null : gearUseFeatures.get(caracteristic);
- return serializable;
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ParameterExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ParameterExportModel.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ParameterExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,94 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Model of a parameter export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class ParameterExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<ParameterExportRow> {
-
- public ParameterExportModel(char separator, DecoratorService decoratorService) {
- super(separator);
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
-
- newColumnForExport("Code_PMFM", ParameterExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
- newColumnForExportByDecorator("Libelle_PMFm", ParameterExportRow.PROPERTY_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
- newColumnForExport("Valeur", ParameterExportRow.PROPERTY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- }
-
- public void prepareRows(List<ParameterExportRow> rows,
- Cruise cruise,
- FishingOperation operation) {
-
- CaracteristicMap gearUseFeatures = operation.getGearUseFeatures();
- if (gearUseFeatures != null) {
- for (Map.Entry<Caracteristic, Serializable> entry : gearUseFeatures.entrySet()) {
- Caracteristic caracteristic = entry.getKey();
-
- ParameterExportRow row = new ParameterExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setCaracteristic(caracteristic);
- row.setValue(entry.getValue());
- rows.add(row);
- }
- }
- CaracteristicMap vesselUseFeatures = operation.getVesselUseFeatures();
- if (vesselUseFeatures != null) {
- for (Map.Entry<Caracteristic, Serializable> entry : vesselUseFeatures.entrySet()) {
- Caracteristic caracteristic = entry.getKey();
-
- ParameterExportRow row = new ParameterExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setCaracteristic(caracteristic);
- row.setValue(entry.getValue());
- rows.add(row);
- }
- }
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ParameterExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ParameterExportRow.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ParameterExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,105 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * A row in a parameter export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class ParameterExportRow implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_CARACTERISTIC = "caracteristic";
-
- public static final String PROPERTY_VALUE = "value";
-
-
- protected Cruise cruise;
-
- protected FishingOperation fishingOperation;
-
- protected Caracteristic caracteristic;
-
- private Serializable value;
-
- public void setCruise(Cruise cruise) {
- this.cruise = cruise;
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- public void setCaracteristic(Caracteristic caracteristic) {
- this.caracteristic = caracteristic;
- }
-
- public void setValue(Serializable value) {
- this.value = value;
- }
-
- public Date getBeginDate() {
- return cruise.getBeginDate();
- }
-
- public Program getProgram() {
- return cruise.getProgram();
- }
-
- public String getSurveyPart() {
- return cruise.getSurveyPart();
- }
-
- public String getStationNumber() {
- return fishingOperation.getStationNumber();
- }
-
- public Integer getFishingOperationNumber() {
- return fishingOperation.getFishingOperationNumber();
- }
-
- public String getMultirigAggregation() {
- return fishingOperation.getMultirigAggregation();
- }
-
- public Caracteristic getCaracteristic() {
- return caracteristic;
- }
-
- public Serializable getValue() {
- return value;
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SpeciesExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SpeciesExportModel.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SpeciesExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,77 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.BatchContainer;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-
-import java.util.List;
-
-/**
- * To export a species used in data to export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.3
- */
-public class SpeciesExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<SpeciesExportRow> {
-
- public SpeciesExportModel(char separator) {
- super(separator);
- newColumnForExport("Id", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("Code_Rubin", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_REF_TAX_CODE);
- newColumnForExport("Nom Scientifique", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_NAME);
- newColumnForExport("Code campagne", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_SURVEY_CODE);
- }
-
- public void prepareBatchRows(TuttiExportService.ExportContext exportContext,
- BatchContainer<SpeciesBatch> rootSpeciesBatch,
- BatchContainer<BenthosBatch> rootBenthosBatch) {
-
- for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) {
-
- exportContext.addSpecies(speciesBatch.getSpecies());
- }
- for (BenthosBatch benthosBatch : rootBenthosBatch.getChildren()) {
- exportContext.addSpecies(benthosBatch.getSpecies());
- }
- }
-
- public void prepareIndividualRows(TuttiExportService.ExportContext exportContext,
- List<IndividualObservationExportRow> rows) {
- for (IndividualObservationExportRow row : rows) {
- exportContext.addSpecies(row.getSpecies());
- }
- }
-
- public void prepareAccidentalRows(TuttiExportService.ExportContext exportContext,
- List<AccidentalCatchExportRow> rows) {
- for (AccidentalCatchExportRow row : rows) {
- exportContext.addSpecies(row.getSpecies());
- }
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SpeciesExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SpeciesExportRow.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SpeciesExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,52 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.referential.Species;
-
-import java.io.Serializable;
-
-/**
- * A species in a export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.3
- */
-public class SpeciesExportRow implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String SPECIES = "species";
-
- protected Species species;
-
- public Species getSpecies() {
- return species;
- }
-
- public void setSpecies(Species species) {
- this.species = species;
- }
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SurveyExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SurveyExportModel.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SurveyExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,72 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-
-import java.util.List;
-
-/**
- * Model of a survey export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class SurveyExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<SurveyExportRow> {
-
- public SurveyExportModel(char separator) {
- super(separator);
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
- newColumnForExport("Pays", SurveyExportRow.PROPERTY_COUNTRY);
- newColumnForExport("Zone_Etude", Program.PROPERTY_ZONE, TuttiLocation.PROPERTY_NAME);
- newColumnForExport("Campagne", Cruise.PROPERTY_NAME);
- newColumnForExport("Id_Sismer", SurveyExportRow.PROPERTY_ID_SISMER);
-// newColumnForExport("Nombre_de_poche", Cruise.PROPERTY_MULTIRIG_NUMBER, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("Date_Deb_Campagne", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
- newColumnForExport("Port_Deb_Campagne", Cruise.PROPERTY_DEPARTURE_LOCATION, TuttiLocation.PROPERTY_NAME);
- newColumnForExport("Date_Fin_Campagne", Cruise.PROPERTY_END_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
- newColumnForExport("Port_Fin_Campagne", Cruise.PROPERTY_RETURN_LOCATION, TuttiLocation.PROPERTY_NAME);
-// newColumnForExport("Engin", Cruise.PROPERTY_GEAR, TuttiCsvUtil.LIST_GEAR_FORMATTER);
- newColumnForExport("Chef_Mission", Cruise.PROPERTY_HEAD_OF_MISSION, TuttiCsvUtil.LIST_PERSON_FORMATTER);
- newColumnForExport("Resp_Salle_Tri", Cruise.PROPERTY_HEAD_OF_SORT_ROOM, TuttiCsvUtil.LIST_PERSON_FORMATTER);
- newColumnForExport("Commentaire", Cruise.PROPERTY_COMMENT);
- }
-
- public void prepareRows(List<SurveyExportRow> rows,
- Cruise cruise,
- TuttiLocation country) {
- SurveyExportRow row = new SurveyExportRow();
- row.setCruise(cruise);
- row.setCountry(country);
- rows.add(row);
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SurveyExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SurveyExportRow.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SurveyExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,128 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrder;
-import fr.ifremer.tutti.persistence.entities.referential.Person;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-/**
- * A row in a survey export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class SurveyExportRow implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_COUNTRY = "country";
-
- public static final String PROPERTY_ID_SISMER = "idSismer";
-
- protected Cruise cruise;
-
- protected TuttiLocation country;
-
- public void setCruise(Cruise cruise) {
- this.cruise = cruise;
- }
-
- public void setCountry(TuttiLocation country) {
- this.country = country;
- }
-
- public Date getBeginDate() {
- return cruise.getBeginDate();
- }
-
- public Program getProgram() {
- return cruise.getProgram();
- }
-
- public String getSurveyPart() {
- return cruise.getSurveyPart();
- }
-
- public TuttiLocation getZone() {
- return cruise.getProgram().getZone();
- }
-
- public Vessel getVessel() {
- return cruise.getVessel();
- }
-
- public String getCountry() {
- return country.getLabel();
- }
-
- public String getName() {
- return cruise.getName();
- }
-
- public List<GearWithOriginalRankOrder> getGear() {
- return cruise.getGear();
- }
-
- public TuttiLocation getDepartureLocation() {
- return cruise.getDepartureLocation();
- }
-
- public Date getEndDate() {
- return cruise.getEndDate();
- }
-
- public TuttiLocation getReturnLocation() {
- return cruise.getReturnLocation();
- }
-
- public String getComment() {
- return cruise.getComment();
- }
-
- public List<Person> getHeadOfMission() {
- return cruise.getHeadOfMission();
- }
-
- public List<Person> getHeadOfSortRoom() {
- return cruise.getHeadOfSortRoom();
- }
-
- public Integer getMultirigNumber() {
- return cruise.getMultirigNumber();
- }
-
- // see http://forge.codelutin.com/issues/2877
- public String getIdSismer() {
- return "";
- }
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,953 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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 com.google.common.base.Charsets;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.io.Files;
-import fr.ifremer.tutti.TuttiBusinessException;
-import fr.ifremer.tutti.TuttiIOUtil;
-import fr.ifremer.tutti.TuttiTechnicalException;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Gears;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import fr.ifremer.tutti.service.AbstractTuttiService;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-import fr.ifremer.tutti.service.TuttiServiceContext;
-import fr.ifremer.tutti.service.catches.WeightComputingService;
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.decorator.Decorator;
-
-import java.io.BufferedWriter;
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To export data in the generic format.
- * <p/>
- * See http://forge.codelutin.com/issues/1875.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class TuttiExportService extends AbstractTuttiService {
-
- private static final Log log =
- LogFactory.getLog(TuttiExportService.class);
-
- protected PersistenceService persistenceService;
-
- protected DecoratorService decoratorService;
-
- protected WeightComputingService weightComputingService;
-
- protected char csvSeparator;
-
- protected Caracteristic verticalOpeningCaracteristic;
-
- protected Caracteristic horizontalOpeningWingCaracteristic;
-
- protected Caracteristic horizontalOpeningDoorCaracteristic;
-
- protected TuttiLocation country;
-
- protected SampleCategoryModel sampleCategoryModel;
-
- protected Caracteristic deadOrAliveCaracteristic;
-
- protected Caracteristic genderCaracteristic;
-
- protected Caracteristic weightMeasuredCaracteristic;
-
- protected Caracteristic pmfmIdCaracteristic;
-
- @Override
- public void setServiceContext(TuttiServiceContext context) {
- super.setServiceContext(context);
- persistenceService = getService(PersistenceService.class);
- decoratorService = getService(DecoratorService.class);
- weightComputingService = getService(WeightComputingService.class);
-
- sampleCategoryModel = context.getSampleCategoryModel();
-
- csvSeparator = context.getConfig().getCsvSeparator();
- verticalOpeningCaracteristic = persistenceService.getVerticalOpeningCaracteristic();
- horizontalOpeningWingCaracteristic = persistenceService.getHorizontalOpeningWingCaracteristic();
- horizontalOpeningDoorCaracteristic = persistenceService.getHorizontalOpeningDoorCaracteristic();
- weightMeasuredCaracteristic = persistenceService.getWeightMeasuredCaracteristic();
- pmfmIdCaracteristic = persistenceService.getPmfmIdCaracteristic();
- deadOrAliveCaracteristic = persistenceService.getDeadOrAliveCaracteristic();
- genderCaracteristic = persistenceService.getSexCaracteristic();
-
- List<TuttiLocation> allCountry = persistenceService.getAllCountry();
- String countryId = context.getConfig().getExportCountryId();
- country = TuttiEntities.splitById(allCountry).get(countryId);
- }
-
- public void exportProgram(String programId,
- File exportFile,
- ProgressionModel progressionModel) {
- Preconditions.checkNotNull(programId);
- Preconditions.checkNotNull(exportFile);
-
- Program program = persistenceService.getProgram(programId);
- Preconditions.checkNotNull(program);
-
- if (log.isDebugEnabled()) {
- log.debug("Will export program: " + programId);
- }
- List<Cruise> allCruise = persistenceService.getAllCruise(programId);
-
- File basedir = new File(context.getConfig().newTempFile(
- "exportProgram"), "exportProgram-" + programId);
-
- TuttiIOUtil.forceMkdir(basedir, _("tutti.service.mkDir.error", basedir));
-
- ExportContext exportContext = createExportContext(basedir);
-
- try {
- for (Cruise cruise : allCruise) {
- // load full cruise
- cruise = persistenceService.getCruise(cruise.getId());
- exportCruise(cruise, exportContext, progressionModel);
- }
- TuttiIOUtil.close(exportContext, _("tutti.service.export.closeContext.error"));
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.buildZip", exportFile));
-
- TuttiIOUtil.zip(basedir, exportFile, _("tutti.service.export.zip.error", exportFile));
- progressionModel.increments(1);
- } finally {
- IOUtils.closeQuietly(exportContext);
- }
- }
-
- public void exportCruise(String cruiseId,
- File exportFile,
- ProgressionModel progressionModel) {
-
- Preconditions.checkNotNull(cruiseId);
- Preconditions.checkNotNull(exportFile);
-
- Cruise cruise = persistenceService.getCruise(cruiseId);
- Preconditions.checkNotNull(cruise);
-
- if (log.isDebugEnabled()) {
- log.debug("Will export cruise: " + cruiseId);
- }
-
- // check cruise fishing operations
- TuttiBusinessException checkError = null;
- try {
- checkCruise(progressionModel, cruise);
- } catch (TuttiBusinessException e) {
- // error while checking cruise
- if (log.isDebugEnabled()) {
- log.debug("Got a check cruise error", e);
- }
- checkError = e;
- }
-
- File basedir = new File(context.getConfig().newTempFile(
- "exportCruise"), "exportCruise-" + cruiseId);
-
- TuttiIOUtil.forceMkdir(basedir, _("tutti.service.mkDir.error", basedir));
-
- ExportContext exportContext = createExportContext(basedir);
-
- try {
- exportCruise(cruise, exportContext, progressionModel);
- TuttiIOUtil.close(exportContext, _("tutti.service.export.closeContext.error"));
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.buildZip", exportFile));
-
- TuttiIOUtil.zip(basedir, exportFile, _("tutti.service.export.zip.error", exportFile));
- progressionModel.increments(1);
- } finally {
- IOUtils.closeQuietly(exportContext);
- }
-
- if (checkError != null) {
- // rethrow error
- throw checkError;
- }
- }
-
- protected ExportContext createExportContext(File basedir) {
-
-
- List<Species> allReferentSpecies = persistenceService.getAllReferentSpecies();
- Map<String, Species> speciesById = TuttiEntities.splitById(allReferentSpecies);
-
- return new ExportContext(
- basedir,
- csvSeparator,
- decoratorService,
- verticalOpeningCaracteristic,
- horizontalOpeningWingCaracteristic,
- horizontalOpeningDoorCaracteristic,
- weightMeasuredCaracteristic,
- deadOrAliveCaracteristic,
- genderCaracteristic,
- pmfmIdCaracteristic,
- sampleCategoryModel,
- speciesById);
- }
-
- protected void checkCruise(ProgressionModel progressionModel, Cruise cruise) {
- Preconditions.checkNotNull(cruise);
-
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.checkCruise", cruise.getName()));
-
- // check cruise fishing operations
- Map<String, String> errors =
- weightComputingService.checkCruise(cruise.getId());
-
- progressionModel.increments(1);
-
- if (MapUtils.isNotEmpty(errors)) {
-
- // there is some fishing operations with some errors
-
- Decorator<Cruise> cruiseDecorator =
- decoratorService.getDecoratorByType(Cruise.class);
-
- Decorator<FishingOperation> fishingOperationDecorator =
- decoratorService.getDecoratorByType(FishingOperation.class);
- StringBuilder sb = new StringBuilder();
- for (Map.Entry<String, String> entry : errors.entrySet()) {
- String fishingOperationId = entry.getKey();
- FishingOperation fishingOperation = persistenceService.getFishingOperation(fishingOperationId);
- String fishingOperationStr = fishingOperationDecorator.toString(fishingOperation);
- sb.append(_("tutti.service.export.invalid.fishingOperation", fishingOperationStr, entry.getValue()));
- }
- String cruiseStr = cruiseDecorator.toString(cruise);
- throw new TuttiBusinessException(
- _("tutti.service.export.invalid.cruise", cruiseStr, sb.toString()));
- }
- }
-
- protected void exportCruise(Cruise cruise,
- ExportContext exportContext,
- ProgressionModel progressionModel) {
-
- List<FishingOperation> operations =
- persistenceService.getAllFishingOperation(cruise.getId());
-
- // load fully operations
- List<FishingOperation> loadedOperations =
- Lists.newArrayListWithCapacity(operations.size());
- for (FishingOperation operation : operations) {
- FishingOperation loadedOeration =
- persistenceService.getFishingOperation(operation.getId());
- loadedOperations.add(loadedOeration);
- }
-
- String cruiseName = cruise.getName();
- progressionModel.setMessage(
- _("tutti.service.exportCruise.exportSurvey", cruiseName));
- exportSurvey(exportContext, cruise);
- progressionModel.increments(1);
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.exportGearCaracteristics", cruiseName));
- exportGearCaracteristics(exportContext, cruise);
- progressionModel.increments(1);
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.exportOperations", cruiseName));
- exportOperations(exportContext, cruise, loadedOperations);
- progressionModel.increments(1);
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.exportParameters", cruiseName));
- exportParameters(exportContext, cruise, loadedOperations);
- progressionModel.increments(1);
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.exportMarineLitters", cruiseName));
- exportMarineLitters(exportContext, cruise, loadedOperations);
- progressionModel.increments(1);
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.exportIndividualObservations", cruiseName));
- exportIndividualObservations(exportContext, cruise, loadedOperations);
- progressionModel.increments(1);
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.exportAccidentalCatches", cruiseName));
- exportAccidentalCatch(exportContext, cruise, loadedOperations);
- progressionModel.increments(1);
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.exportCatches", cruiseName));
- exportCatches(exportContext, cruise, loadedOperations);
- progressionModel.increments(1);
-
- progressionModel.setMessage(
- _("tutti.service.exportCruise.exportSpecies", cruiseName));
-
- exportSpecies(exportContext, exportContext.getSpeciesToExport());
- progressionModel.increments(1);
- }
-
- protected void exportSurvey(ExportContext exportContext,
- Cruise cruise) {
- try {
-
- List<SurveyExportRow> rows = Lists.newArrayList();
- exportContext.surveyModel.prepareRows(rows, cruise, country);
- exportContext.surveyExport.write(rows, exportContext.surveyWriter);
- } catch (Exception e) {
- throw new TuttiTechnicalException(_("tutti.service.export.survey.error"), e);
- }
- }
-
- protected void exportGearCaracteristics(ExportContext exportContext,
- Cruise cruise) {
- try {
-
- List<GearCaracteristicExportRow> rows = Lists.newArrayList();
-
- for (Gear gear : cruise.getGear()) {
-
- CaracteristicMap caracteristics =
- persistenceService.getGearCaracteristics(
- cruise.getId(),
- gear.getId(),
- gear.getRankOrder());
-
- Gear gearWithCaracteristics = Gears.newGear(gear);
- gearWithCaracteristics.setCaracteristics(caracteristics);
- exportContext.gearCaracteristicsModel.prepareRows(rows, cruise, gearWithCaracteristics);
- }
-
- exportContext.gearCaracteristicsExport.write(rows, exportContext.gearCaracteristicsWriter);
- } catch (Exception e) {
- throw new TuttiTechnicalException(_("tutti.service.export.survey.error"), e);
- }
- }
-
- protected void exportOperations(ExportContext exportContext,
- Cruise cruise,
- List<FishingOperation> operations) {
-
- try {
-
- List<OperationExportRow> rows = Lists.newArrayList();
-
- for (FishingOperation operation : operations) {
-
- OperationContext operationContext = getOperationContext(operation);
- CatchBatch catchBatch = operationContext.getCatchBatch();
- exportContext.operationModel.prepareRows(rows,
- cruise,
- operation,
- catchBatch);
- }
-
- exportContext.operationExport.write(rows, exportContext.operationWriter);
- } catch (Exception e) {
- throw new TuttiTechnicalException(_("tutti.service.export.operations.error"), e);
- }
- }
-
- protected void exportParameters(ExportContext exportContext,
- Cruise cruise,
- List<FishingOperation> operations) {
-
- try {
-
- for (FishingOperation operation : operations) {
- List<ParameterExportRow> rows = Lists.newArrayList();
- exportContext.parameterModel.prepareRows(rows, cruise, operation);
- exportContext.parameterExport.write(rows, exportContext.parameterWriter);
- }
-
- } catch (Exception e) {
- throw new TuttiTechnicalException(_("tutti.service.export.parameters.error"), e);
- }
- }
-
- protected void exportMarineLitters(ExportContext exportContext,
- Cruise cruise,
- List<FishingOperation> operations) {
-
- try {
-
- for (FishingOperation operation : operations) {
- OperationContext operationContext = getOperationContext(operation);
-
- boolean withCatchBatch = operationContext.isWithCatchBatch();
- if (!withCatchBatch) {
- continue;
- }
- List<MarineLitterExportRow> rows = Lists.newArrayList();
- exportContext.marineLitterModel.prepareRows(persistenceService, rows, cruise, operation);
- exportContext.marineLitterExport.write(rows, exportContext.marineLitterWriter);
- }
-
- } catch (Exception e) {
- throw new TuttiTechnicalException(_("tutti.service.export.parameters.error"), e);
- }
- }
-
- protected void exportIndividualObservations(ExportContext exportContext,
- Cruise cruise,
- List<FishingOperation> operations) {
-
- try {
-
- for (FishingOperation operation : operations) {
- OperationContext operationContext = getOperationContext(operation);
-
- boolean withCatchBatch = operationContext.isWithCatchBatch();
- if (!withCatchBatch) {
- continue;
- }
- List<IndividualObservationExportRow> rows = Lists.newArrayList();
- exportContext.individualObservationModel.prepareRows(persistenceService, rows, cruise, operation);
- exportContext.speciesModel.prepareIndividualRows(
- exportContext,
- rows);
- exportContext.individualObservationExport.write(rows, exportContext.individualObservationWriter);
- }
-
- } catch (Exception e) {
- throw new TuttiTechnicalException(_("tutti.service.export.parameters.error"), e);
- }
- }
-
- protected void exportAccidentalCatch(ExportContext exportContext,
- Cruise cruise,
- List<FishingOperation> operations) {
- try {
-
- for (FishingOperation operation : operations) {
- List<AccidentalCatchExportRow> rows = Lists.newArrayList();
- exportContext.accidentalCatchModel.prepareRows(persistenceService, rows, cruise, operation);
- exportContext.speciesModel.prepareAccidentalRows(
- exportContext,
- rows);
- exportContext.accidentalCatchExport.write(rows, exportContext.accidentalCatchWriter);
- }
-
- } catch (Exception e) {
- throw new TuttiTechnicalException(_("tutti.service.export.parameters.error"), e);
- }
- }
-
- protected void exportCatches(ExportContext exportContext,
- Cruise cruise,
- List<FishingOperation> operations) {
- try {
-
- for (FishingOperation operation : operations) {
-
- OperationContext operationContext = getOperationContext(operation);
-
- boolean withCatchBatch = operationContext.isWithCatchBatch();
- if (!withCatchBatch) {
- continue;
- }
-
- CatchBatch catchBatch = operationContext.getCatchBatch();
-
- BatchContainer<SpeciesBatch> rootSpeciesBatch =
- operationContext.getRootSpeciesBatch();
-
- BatchContainer<BenthosBatch> rootBenthosBatch =
- operationContext.getRootBenthosBatch();
-
- exportContext.speciesModel.prepareBatchRows(
- exportContext,
- rootSpeciesBatch,
- rootBenthosBatch);
-
- Float totalWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getCatchTotalWeight(),
- catchBatch.getCatchTotalComputedWeight());
-
- Float totalUnsortedWeight =
- catchBatch.getCatchTotalUnsortedComputedWeight();
-
-
- Float totalSortedSpeciesWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalSortedWeight(),
- catchBatch.getSpeciesTotalSortedComputedWeight());
-
- Float totalSampleSortedSpeciesWeight =
- catchBatch.getSpeciesTotalSampleSortedComputedWeight();
-
- Float totalSortedBenthosWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalSortedWeight(),
- catchBatch.getBenthosTotalSortedComputedWeight());
-
- Float totalSampleSortedBenthosWeight =
- catchBatch.getBenthosTotalSampleSortedComputedWeight();
-
- Float totalSortedWeight = catchBatch.getCatchTotalSortedComputedWeight();
-
- //FIXME tchemit 2013-07-12 J'utilise en fait la formule (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée)
- // (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée - poids du HV dans la capture totale)
-
- Float catchRaisingFactor = totalWeight == null || totalUnsortedWeight == null || totalSortedWeight == null ? 1 : (totalWeight - totalUnsortedWeight) / totalSortedWeight;
-
- Float speciesCatchRaisingFactor = totalSampleSortedSpeciesWeight == null || totalSortedSpeciesWeight == null || totalSampleSortedSpeciesWeight == null ? 1 : (totalSampleSortedSpeciesWeight == 0 ? 0 : (totalSortedSpeciesWeight / totalSampleSortedSpeciesWeight) * catchRaisingFactor);
- Float benthosCatchRaisingFactor = totalSampleSortedBenthosWeight == null || totalSortedBenthosWeight == null || totalSampleSortedBenthosWeight == null ? 1 : (totalSampleSortedBenthosWeight == 0 ? 0 : (totalSortedBenthosWeight / totalSampleSortedBenthosWeight) * catchRaisingFactor);
-
- if (log.isDebugEnabled()) {
- String message = "\ncatchTotalWeight : " + totalWeight +
- "\ncatchTotalUnsortedWeight : " + totalUnsortedWeight +
- "\ntotalSampleSortedSpeciesWeight : " + totalSampleSortedSpeciesWeight +
- "\ntotalSampleSortedBenthosWeight : " + totalSampleSortedBenthosWeight +
- "\ntotalSortedWeight : " + totalSortedWeight +
- "\ncatchRaisingFactor : " + catchRaisingFactor +
- "\nspeciesCatchRaisingFactor : " + speciesCatchRaisingFactor +
- "\nbenthosCatchRaisingFactor : " + benthosCatchRaisingFactor;
-
- log.debug(message);
- }
-
- List<CatchExportRow> rows = Lists.newArrayList();
- exportContext.catchModel.prepareRows(persistenceService,
- rows,
- cruise,
- operation,
- rootSpeciesBatch,
- rootBenthosBatch,
- speciesCatchRaisingFactor,
- benthosCatchRaisingFactor);
-
- exportContext.catchExport.write(rows, exportContext.catchWriter);
- }
-
- } catch (Exception e) {
- throw new TuttiTechnicalException(
- _("tutti.service.export.catches.error"), e);
- }
- }
-
- protected void exportSpecies(ExportContext exportContext,
- List<SpeciesExportRow> rows) {
-
- try {
-
- exportContext.speciesExport.write(rows, exportContext.speciesWriter);
-
- } catch (Exception e) {
- throw new TuttiTechnicalException(
- _("tutti.service.export.catches.error"), e);
- }
- }
-
- protected static class ExportContext implements Closeable {
-
- File surveyFile;
-
- File gearCaracteristicsFile;
-
- File operationFile;
-
- File parameterFile;
-
- File marineLitterFile;
-
- File individualObservationFile;
-
- File catchFile;
-
- File accidentalCatchFile;
-
- File speciesFile;
-
- BufferedWriter surveyWriter;
-
- BufferedWriter gearCaracteristicsWriter;
-
- BufferedWriter operationWriter;
-
- BufferedWriter parameterWriter;
-
- BufferedWriter marineLitterWriter;
-
- BufferedWriter catchWriter;
-
- BufferedWriter accidentalCatchWriter;
-
- BufferedWriter individualObservationWriter;
-
- BufferedWriter speciesWriter;
-
- SurveyExportModel surveyModel;
-
- GearCaracteristicExportModel gearCaracteristicsModel;
-
- OperationExportModel operationModel;
-
- MarineLitterExportModel marineLitterModel;
-
- ParameterExportModel parameterModel;
-
- CatchExportModel catchModel;
-
- AccidentalCatchExportModel accidentalCatchModel;
-
- IndividualObservationExportModel individualObservationModel;
-
- SpeciesExportModel speciesModel;
-
- final Map<String, SpeciesExportRow> speciesToExport = Maps.newTreeMap();
-
- TuttiCsvUtil.TuttiRepeatableExport<SurveyExportRow> surveyExport;
-
- TuttiCsvUtil.TuttiRepeatableExport<GearCaracteristicExportRow> gearCaracteristicsExport;
-
- TuttiCsvUtil.TuttiRepeatableExport<OperationExportRow> operationExport;
-
- TuttiCsvUtil.TuttiRepeatableExport<MarineLitterExportRow> marineLitterExport;
-
- TuttiCsvUtil.TuttiRepeatableExport<ParameterExportRow> parameterExport;
-
- TuttiCsvUtil.TuttiRepeatableExport<CatchExportRow> catchExport;
-
- TuttiCsvUtil.TuttiRepeatableExport<AccidentalCatchExportRow> accidentalCatchExport;
-
- TuttiCsvUtil.TuttiRepeatableExport<IndividualObservationExportRow> individualObservationExport;
-
- TuttiCsvUtil.TuttiRepeatableExport<SpeciesExportRow> speciesExport;
-
- Map<String, Species> speciesById;
-
- String checkError;
-
- ExportContext(File basedir,
- char csvSeparator,
- DecoratorService decoratorService,
- Caracteristic verticalOpeningCaracteristic,
- Caracteristic horizontalOpeningWingCaracteristic,
- Caracteristic horizontalOpeningDoorCaracteristic,
- Caracteristic weightMeasuredCaracteristic,
- Caracteristic deadOrAliveCaracteristic,
- Caracteristic genderCaracteristic,
- Caracteristic pmfmIdCaracteristic,
- SampleCategoryModel sampleCategoryModel,
- Map<String, Species> speciesById) {
-
- this.speciesById = speciesById;
- try {
-
- surveyFile = new File(basedir, "survey.csv");
- surveyWriter = Files.newWriter(surveyFile, Charsets.UTF_8);
-
- gearCaracteristicsFile = new File(basedir, "gearCaracteristics.csv");
- gearCaracteristicsWriter = Files.newWriter(gearCaracteristicsFile, Charsets.UTF_8);
-
- operationFile = new File(basedir, "operation.csv");
- operationWriter = Files.newWriter(operationFile, Charsets.UTF_8);
-
- marineLitterFile = new File(basedir, "marineLitter.csv");
- marineLitterWriter = Files.newWriter(marineLitterFile, Charsets.UTF_8);
-
- parameterFile = new File(basedir, "parameter.csv");
- parameterWriter = Files.newWriter(parameterFile, Charsets.UTF_8);
-
- catchFile = new File(basedir, "catch.csv");
- catchWriter = Files.newWriter(catchFile, Charsets.UTF_8);
-
- accidentalCatchFile = new File(basedir, "accidentalCatch.csv");
- accidentalCatchWriter = Files.newWriter(accidentalCatchFile, Charsets.UTF_8);
-
- individualObservationFile = new File(basedir, "individualObservation.csv");
- individualObservationWriter = Files.newWriter(individualObservationFile, Charsets.UTF_8);
-
- speciesFile = new File(basedir, "species.csv");
- speciesWriter = Files.newWriter(speciesFile, Charsets.UTF_8);
-
- } catch (FileNotFoundException e) {
-
- // should never happen
- throw new TuttiTechnicalException(_("tutti.service.export.context.error"), e);
- }
-
- surveyModel = new SurveyExportModel(csvSeparator);
-
- gearCaracteristicsModel = new GearCaracteristicExportModel(
- csvSeparator, decoratorService);
-
- operationModel =
- new OperationExportModel(
- csvSeparator,
- verticalOpeningCaracteristic,
- horizontalOpeningWingCaracteristic,
- horizontalOpeningDoorCaracteristic,
- decoratorService.getDecoratorByType(Vessel.class));
-
- parameterModel = new ParameterExportModel(
- csvSeparator, decoratorService);
-
- marineLitterModel = new MarineLitterExportModel(csvSeparator);
- catchModel = new CatchExportModel(csvSeparator,
- sampleCategoryModel,
- decoratorService);
- accidentalCatchModel = new AccidentalCatchExportModel(
- csvSeparator,
- deadOrAliveCaracteristic,
- genderCaracteristic,
- weightMeasuredCaracteristic,
- pmfmIdCaracteristic);
- individualObservationModel = new IndividualObservationExportModel(
- csvSeparator,
- weightMeasuredCaracteristic,
- pmfmIdCaracteristic);
-
- speciesModel = new SpeciesExportModel(
- csvSeparator);
-
- surveyExport = TuttiCsvUtil.newRepeatableExport(surveyModel);
-
- gearCaracteristicsExport = TuttiCsvUtil.newRepeatableExport(
- gearCaracteristicsModel);
-
- operationExport = TuttiCsvUtil.newRepeatableExport(
- operationModel);
-
- parameterExport = TuttiCsvUtil.newRepeatableExport(
- parameterModel);
-
- marineLitterExport = TuttiCsvUtil.newRepeatableExport(
- marineLitterModel);
-
- catchExport = TuttiCsvUtil.newRepeatableExport(catchModel);
- accidentalCatchExport = TuttiCsvUtil.newRepeatableExport(accidentalCatchModel);
- individualObservationExport = TuttiCsvUtil.newRepeatableExport(individualObservationModel);
- speciesExport = TuttiCsvUtil.newRepeatableExport(speciesModel);
- }
-
- @Override
- public void close() throws IOException {
- IOUtils.closeQuietly(surveyWriter);
- IOUtils.closeQuietly(gearCaracteristicsWriter);
- IOUtils.closeQuietly(operationWriter);
- IOUtils.closeQuietly(parameterWriter);
- IOUtils.closeQuietly(catchWriter);
- IOUtils.closeQuietly(accidentalCatchWriter);
- IOUtils.closeQuietly(marineLitterWriter);
- IOUtils.closeQuietly(individualObservationWriter);
- IOUtils.closeQuietly(speciesWriter);
- }
-
- public String getCheckError() {
- return checkError;
- }
-
- public void setCheckError(String checkError) {
- this.checkError = checkError;
- }
-
- public void addSpecies(Species species) {
- String speciesId = species.getId();
- if (!speciesToExport.containsKey(speciesId)) {
-
- // not treated species, add a new row
- Species fullSpecies = speciesById.get(speciesId);
- SpeciesExportRow row = new SpeciesExportRow();
- row.setSpecies(fullSpecies);
- speciesToExport.put(speciesId, row);
- }
- }
-
- public List<SpeciesExportRow> getSpeciesToExport() {
- List<SpeciesExportRow> result =
- Lists.newArrayList(speciesToExport.values());
-
- Collections.sort(result, new Comparator<SpeciesExportRow>() {
- @Override
- public int compare(SpeciesExportRow o1, SpeciesExportRow o2) {
- return o1.getSpecies().getReferenceTaxonId().compareTo(o2.getSpecies().getReferenceTaxonId());
- }
- });
- return result;
- }
- }
-
- protected static class OperationContext {
-
- protected final FishingOperation operation;
-
- private final CatchBatch catchBatch;
-
- private BatchContainer<MarineLitterBatch> rootMarineLitterBatch;
-
- private BatchContainer<SpeciesBatch> rootSpeciesBatch;
-
- private BatchContainer<BenthosBatch> rootBenthosBatch;
-
-
- protected boolean withCatchBatch;
-
- public OperationContext(FishingOperation operation,
- PersistenceService persistenceService,
- WeightComputingService weightComputingService) {
- this.operation = operation;
-
- String operationId = operation.getId();
-
- withCatchBatch =
- persistenceService.isFishingOperationWithCatchBatch(
- operationId);
-
- if (withCatchBatch) {
-
-
- // load batches
-
- catchBatch =
- persistenceService.getCatchBatchFromFishingOperation(
- operationId);
-
- boolean withError = false;
-
- try {
- rootSpeciesBatch = weightComputingService.getComputedSpeciesBatches(operationId);
- } catch (Exception e) {
- withError = true;
- rootSpeciesBatch =
- persistenceService.getRootSpeciesBatch(operationId, null);
- }
-
- try {
- rootBenthosBatch =
- weightComputingService.getComputedBenthosBatches(operationId);
- } catch (Exception e) {
- withError = true;
- rootBenthosBatch =
- persistenceService.getRootBenthosBatch(operationId, null);
- }
-
- try {
- rootMarineLitterBatch =
- weightComputingService.getComputedMarineLitterBatches(operationId, catchBatch.getMarineLitterTotalWeight());
- } catch (Exception e) {
- withError = true;
- rootMarineLitterBatch =
- persistenceService.getRootMarineLitterBatch(operationId);
- }
-
- // apply compute weights
-
- if (!withError) {
- weightComputingService.computeCatchBatchWeights(
- catchBatch,
- rootSpeciesBatch,
- rootBenthosBatch,
- rootMarineLitterBatch);
- }
- } else {
- if (log.isWarnEnabled()) {
- log.warn("Skip fishing operation " + operationId +
- " since no catchBatch associated.");
- }
- catchBatch = null;
- rootSpeciesBatch = null;
- rootBenthosBatch = null;
- rootMarineLitterBatch = null;
- }
-
- }
-
- public CatchBatch getCatchBatch() {
- return catchBatch;
- }
-
- public BatchContainer<MarineLitterBatch> getRootMarineLitterBatch() {
- return rootMarineLitterBatch;
- }
-
- public BatchContainer<SpeciesBatch> getRootSpeciesBatch() {
- return rootSpeciesBatch;
- }
-
- public BatchContainer<BenthosBatch> getRootBenthosBatch() {
- return rootBenthosBatch;
- }
-
- public boolean isWithCatchBatch() {
- return withCatchBatch;
- }
- }
-
- protected Map<String, OperationContext> operationContexts = Maps.newTreeMap();
-
- protected OperationContext getOperationContext(FishingOperation operation) {
- String operationId = operation.getId();
-
- OperationContext result = operationContexts.get(operationId);
- if (result == null) {
-
- // create it
- result = new OperationContext(operation,
- persistenceService,
- weightComputingService);
- operationContexts.put(operationId, result);
- }
- return result;
-
- }
-}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/AccidentalCatchExportModel.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/AccidentalCatchExportModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/AccidentalCatchExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,170 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.2
+ */
+public class AccidentalCatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<AccidentalCatchExportRow> {
+
+ protected final Caracteristic caracteristicDeadOrAliveSize;
+
+ protected final Caracteristic caracteristicGender;
+
+ protected final Caracteristic caracteristicWeight;
+
+ protected final Caracteristic caracteristicPmfmId;
+
+ public AccidentalCatchExportModel(
+ char separator,
+ Caracteristic caracteristicDeadOrAliveSize,
+ Caracteristic caracteristicGender,
+ Caracteristic caracteristicWeight,
+ Caracteristic caracteristicPmfmId) {
+ super(separator);
+
+ this.caracteristicDeadOrAliveSize = caracteristicDeadOrAliveSize;
+ this.caracteristicGender = caracteristicGender;
+ this.caracteristicWeight = caracteristicWeight;
+ this.caracteristicPmfmId = caracteristicPmfmId;
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
+ newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
+
+ newColumnForExport("BatchId", AccidentalCatchExportRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("ReferenceTaxonId", AccidentalBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("ReferenceTaxonName", AccidentalBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
+ newColumnForExport("Commentaire", AccidentalBatch.PROPERTY_COMMENT);
+ newColumnForExport("CaracteristicId", AccidentalCatchExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
+ newColumnForExport("CaracteristicValue", AccidentalCatchExportRow.PROPERTY_CARACTERISTIC_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ }
+
+ public void prepareRows(PersistenceService persistenceService,
+ List<AccidentalCatchExportRow> rows,
+ Cruise cruise,
+ FishingOperation operation) {
+
+ List<AccidentalBatch> observations =
+ persistenceService.getAllAccidentalBatch(operation.getId());
+
+ if (CollectionUtils.isNotEmpty(observations)) {
+ for (AccidentalBatch child : observations) {
+
+ addCaracteristicRow(rows,
+ cruise,
+ operation,
+ child,
+ caracteristicDeadOrAliveSize,
+ child.getDeadOrAlive());
+
+ addCaracteristicRow(rows,
+ cruise,
+ operation,
+ child,
+ caracteristicGender,
+ child.getGender());
+
+ addCaracteristicRow(rows,
+ cruise,
+ operation,
+ child,
+ caracteristicWeight,
+ child.getWeight());
+
+ if (child.getLengthStepCaracteristic() != null) {
+ addCaracteristicRow(rows,
+ cruise,
+ operation,
+ child,
+ caracteristicPmfmId,
+ child.getLengthStepCaracteristic().getIdAsInt());
+
+ addCaracteristicRow(rows,
+ cruise,
+ operation,
+ child,
+ child.getLengthStepCaracteristic(),
+ child.getSize());
+ }
+
+ CaracteristicMap caracteristics = child.getCaracteristics();
+ if (MapUtils.isNotEmpty(caracteristics)) {
+ for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
+ addCaracteristicRow(rows,
+ cruise,
+ operation,
+ child,
+ entry.getKey(),
+ entry.getValue());
+ }
+ }
+ }
+ }
+ }
+
+ private void addCaracteristicRow(List<AccidentalCatchExportRow> rows,
+ Cruise cruise,
+ FishingOperation operation,
+ AccidentalBatch child,
+ Caracteristic caracteristic,
+ Serializable caracteristicValue) {
+ if (caracteristicValue != null) {
+
+ AccidentalCatchExportRow row = new AccidentalCatchExportRow();
+ row.setCruise(cruise);
+ row.setFishingOperation(operation);
+ row.setBatch(child);
+ row.setCaracteristic(caracteristic);
+ row.setCaracteristicValue(caracteristicValue);
+ rows.add(row);
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/AccidentalCatchExportRow.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportRow.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/AccidentalCatchExportRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/AccidentalCatchExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,139 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.AccidentalBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * A row in a accidental catch export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.2
+ */
+public class AccidentalCatchExportRow implements Serializable {
+
+ public static final String PROPERTY_BATCH = "batch";
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_BATCH_ID = "batchId";
+
+ public static final String PROPERTY_CARACTERISTIC = "caracteristic";
+
+ public static final String PROPERTY_CARACTERISTIC_VALUE = "caracteristicValue";
+
+ protected Cruise cruise;
+
+ protected FishingOperation fishingOperation;
+
+ protected AccidentalBatch batch;
+
+ protected Caracteristic caracteristic;
+
+ protected Serializable caracteristicValue;
+
+ public void setCruise(Cruise cruise) {
+ this.cruise = cruise;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public void setBatch(AccidentalBatch batch) {
+ this.batch = batch;
+ }
+
+ public void setCaracteristic(Caracteristic caracteristic) {
+ this.caracteristic = caracteristic;
+ }
+
+ public void setCaracteristicValue(Serializable caracteristicValue) {
+ this.caracteristicValue = caracteristicValue;
+ }
+
+ public Integer getBatchId() {
+ return batch.getIdAsInt();
+ }
+
+ public Caracteristic getCaracteristic() {
+ return caracteristic;
+ }
+
+ public Serializable getCaracteristicValue() {
+ return caracteristicValue;
+ }
+
+ public String getComment() {
+ return batch.getComment();
+ }
+
+ public Species getSpecies() {
+ return batch.getSpecies();
+ }
+
+ public Date getBeginDate() {
+ return cruise.getBeginDate();
+ }
+
+ public Program getProgram() {
+ return cruise.getProgram();
+ }
+
+ public String getSurveyPart() {
+ return cruise.getSurveyPart();
+ }
+
+ public String getStationNumber() {
+ return fishingOperation.getStationNumber();
+ }
+
+ public Integer getFishingOperationNumber() {
+ return fishingOperation.getFishingOperationNumber();
+ }
+
+ public Gear getGear() {
+ return fishingOperation.getGear();
+ }
+
+ public Vessel getVessel() {
+ return fishingOperation.getVessel();
+ }
+
+ public String getMultirigAggregation() {
+ return fishingOperation.getMultirigAggregation();
+ }
+
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportModel.java (from rev 1366, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,457 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import org.apache.commons.collections.CollectionUtils;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Model of a catch export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<CatchExportRow> {
+
+ public static final String WEIGHT_OR_VOL_TYPE = "Poids";
+
+ protected SampleCategoryModel sampleCategoryModel;
+
+ public CatchExportModel(char separator,
+ SampleCategoryModel sampleCategoryModel,
+ DecoratorService decoratorService) {
+ super(separator);
+ this.sampleCategoryModel = sampleCategoryModel;
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
+ newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
+ newColumnForExport("Taxon", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Nom_scientifique", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
+ newColumnForExport("Commentaire", SpeciesBatch.PROPERTY_COMMENT);
+
+ for (SampleCategoryModelEntry entry : sampleCategoryModel.getCategory()) {
+ addSampleCategory(entry.getCanonicalLabel(), entry.getOrder());
+ }
+
+ // mensuration
+
+ newNullableColumnForExport("Code_Longueur", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_ID);
+ newNullableColumnForExportByDecorator("Libelle_Longueur", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
+ newNullableColumnForExport("Taille", CatchExportRow.FREQUENCY_LENGTH_STEP, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("NumOrdre_Taille_H2", CatchExportRow.FREQUENCY_RANK_ORDER, TuttiCsvUtil.INTEGER);
+ newNullableColumnForExport("Poids_Classe_Taille", CatchExportRow.FREQUENCY_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Unite_Taille", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_UNIT);
+ newNullableColumnForExport("Precision_Mesure", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_PRECISION, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Nbr", CatchExportRow.BATCH_NUMBER, TuttiCsvUtil.INTEGER);
+
+ newColumnForExport("Poids_Reference", CatchExportRow.REFERENCE_WEIGHT, TuttiCsvUtil.PRIMITIVE_FLOAT);
+ newColumnForExport("Coef_Elev_Espece_Capture", CatchExportRow.RAISING_FACTOR, TuttiCsvUtil.PRIMITIVE_FLOAT);
+ }
+
+ public void prepareRows(PersistenceService persistenceService,
+ List<CatchExportRow> rows,
+ Cruise cruise,
+ FishingOperation operation,
+ BatchContainer<SpeciesBatch> rootSpeciesBatch,
+ BatchContainer<BenthosBatch> rootBenthosBatch,
+ Float speciesCatchRaisingFactor,
+ Float benthosCatchRaisingFactor) {
+
+ Caracteristic weightMeasuredCaracteristic = persistenceService.getWeightMeasuredCaracteristic();
+ String batchWeightUnit = weightMeasuredCaracteristic.getUnit();
+
+ for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) {
+ CatchExportRow row = new CatchExportRow();
+ row.setCruise(cruise);
+ row.setFishingOperation(operation);
+ row.setSpecies(speciesBatch.getSpecies());
+ row.setBatchWeightUnit(batchWeightUnit);
+
+ if (persistenceService.isVracBatch(speciesBatch)) {
+
+ // compute species total weight in catch
+
+ Float sortedBatchWeight = TuttiEntities.getValueOrComputedValue(
+ speciesBatch.getSampleCategoryWeight(),
+ speciesBatch.getSampleCategoryComputedWeight());
+
+ float totalBatchWeight = sortedBatchWeight == null ? 0 : speciesCatchRaisingFactor *
+ sortedBatchWeight;
+
+ prepareSortedRows(persistenceService,
+ row,
+ rows,
+ speciesBatch,
+ totalBatchWeight);
+ } else {
+ prepareUnsortedRows(row, rows, speciesBatch);
+ }
+
+ }
+ for (BenthosBatch benthosBatch : rootBenthosBatch.getChildren()) {
+ CatchExportRow row = new CatchExportRow();
+ row.setCruise(cruise);
+ row.setFishingOperation(operation);
+ row.setSpecies(benthosBatch.getSpecies());
+ row.setBatchWeightUnit(batchWeightUnit);
+
+ if (persistenceService.isVracBatch(benthosBatch)) {
+
+ // compute species total weight in catch
+
+ Float sortedBatchWeight = TuttiEntities.getValueOrComputedValue(
+ benthosBatch.getSampleCategoryWeight(),
+ benthosBatch.getSampleCategoryComputedWeight());
+
+ float totalBatchWeight = sortedBatchWeight == null ? 0 : benthosCatchRaisingFactor *
+ sortedBatchWeight;
+
+ prepareSortedRows(persistenceService,
+ row,
+ rows,
+ benthosBatch,
+ totalBatchWeight);
+ } else {
+ prepareUnsortedRows(row, rows, benthosBatch);
+ }
+ }
+ }
+
+ protected void prepareSortedRows(PersistenceService persistenceService,
+ CatchExportRow currentRow,
+ List<CatchExportRow> rows,
+ SpeciesBatch speciesBatch,
+ final float totalBatchWeight) {
+
+ currentRow.addComment(speciesBatch.getComment());
+
+ prepareBatch(currentRow,
+ speciesBatch.getSampleCategoryId(),
+ speciesBatch.getSampleCategoryValue(),
+ speciesBatch.getSampleCategoryWeight(),
+ speciesBatch.getSampleCategoryComputedWeight(),
+ speciesBatch.getWeight(),
+ speciesBatch.getNumber(),
+ speciesBatch.getRankOrder());
+
+ if (speciesBatch.isChildBatchsEmpty()) {
+
+ // on a leaf, get frequencies
+
+ List<SpeciesBatchFrequency> speciesBatchFrequency =
+ persistenceService.getAllSpeciesBatchFrequency(speciesBatch.getId());
+
+ if (CollectionUtils.isEmpty(speciesBatchFrequency)) {
+
+ // no frequency
+
+ CatchExportRow row = currentRow.copy();
+
+ // Get reference weight
+
+ Float referenceWeight = TuttiEntities.getValueOrComputedValue(
+ speciesBatch.getWeight(),
+ speciesBatch.getComputedWeight());
+
+ if (referenceWeight == null) {
+
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
+ speciesBatch.getSampleCategoryWeight(),
+ speciesBatch.getSampleCategoryComputedWeight());
+ }
+ setRaisingFactor(row, totalBatchWeight, referenceWeight);
+ rows.add(row);
+ } else {
+
+ // there is some frequencies
+
+ boolean withNoWeightOnFrequencies =
+ speciesBatchFrequency.get(0).getWeight() == null;
+
+ Float referenceWeight = null;
+
+ if (withNoWeightOnFrequencies) {
+
+ // no weight on frequencies use upper reference weight
+
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
+ speciesBatch.getWeight(),
+ speciesBatch.getComputedWeight());
+
+ if (referenceWeight == null) {
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
+ speciesBatch.getSampleCategoryWeight(),
+ speciesBatch.getSampleCategoryComputedWeight());
+ }
+ }
+
+ for (SpeciesBatchFrequency batchFrequency : speciesBatchFrequency) {
+ CatchExportRow row = currentRow.copy();
+ row.setSpeciesFrequency(batchFrequency);
+ rows.add(row);
+
+ if (!withNoWeightOnFrequencies) {
+
+ // use concrete frequency weight
+ referenceWeight = batchFrequency.getWeight();
+ }
+
+ setRaisingFactor(row, totalBatchWeight, referenceWeight);
+ }
+ }
+
+ } else {
+
+ for (SpeciesBatch childBatch : speciesBatch.getChildBatchs()) {
+ prepareSortedRows(persistenceService,
+ currentRow,
+ rows,
+ childBatch,
+ totalBatchWeight
+ );
+ }
+ }
+
+ // remove last comment (otherwise next brother will have this one too...)
+ currentRow.popLastComment();
+ }
+
+ protected void prepareUnsortedRows(CatchExportRow currentRow,
+ List<CatchExportRow> rows,
+ SpeciesBatch speciesBatch) {
+
+
+ prepareBatch(currentRow,
+ speciesBatch.getSampleCategoryId(),
+ speciesBatch.getSampleCategoryValue(),
+ speciesBatch.getSampleCategoryWeight(),
+ speciesBatch.getSampleCategoryComputedWeight(),
+ speciesBatch.getWeight(),
+ speciesBatch.getNumber(),
+ speciesBatch.getRankOrder());
+
+ CatchExportRow row = currentRow.copy();
+ row.addComment(speciesBatch.getComment());
+ float referenceWeight = TuttiEntities.getValueOrComputedValue(
+ speciesBatch.getSampleCategoryWeight(),
+ speciesBatch.getSampleCategoryComputedWeight());
+
+ setRaisingFactor(row, referenceWeight, referenceWeight);
+ rows.add(row);
+ }
+
+ protected void prepareSortedRows(PersistenceService persistenceService,
+ CatchExportRow currentRow,
+ List<CatchExportRow> rows,
+ BenthosBatch benthosBatch,
+ final float totalBatchWeight) {
+
+ currentRow.addComment(benthosBatch.getComment());
+
+ prepareBatch(currentRow,
+ benthosBatch.getSampleCategoryId(),
+ benthosBatch.getSampleCategoryValue(),
+ benthosBatch.getSampleCategoryWeight(),
+ benthosBatch.getSampleCategoryComputedWeight(),
+ benthosBatch.getWeight(),
+ benthosBatch.getNumber(),
+ benthosBatch.getRankOrder());
+
+ if (benthosBatch.isChildBatchsEmpty()) {
+
+ // on a leaf, get frequencies
+
+ List<BenthosBatchFrequency> benthosBatchFrequency =
+ persistenceService.getAllBenthosBatchFrequency(benthosBatch.getId());
+
+ if (CollectionUtils.isEmpty(benthosBatchFrequency)) {
+
+ // no frequency
+
+ CatchExportRow row = currentRow.copy();
+
+ // Get reference weight
+
+ Float referenceWeight = TuttiEntities.getValueOrComputedValue(
+ benthosBatch.getWeight(),
+ benthosBatch.getComputedWeight());
+
+ if (referenceWeight == null) {
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
+ benthosBatch.getSampleCategoryWeight(),
+ benthosBatch.getSampleCategoryComputedWeight());
+ }
+
+ setRaisingFactor(row, totalBatchWeight, referenceWeight);
+ rows.add(row);
+ } else {
+
+ // there is some frequencies
+
+ Float referenceWeight = null;
+
+ boolean withNoWeightOnFrequencies =
+ benthosBatchFrequency.get(0).getWeight() == null;
+
+ if (withNoWeightOnFrequencies) {
+
+ // no weight on frequencies use upper reference weight
+
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
+ benthosBatch.getWeight(),
+ benthosBatch.getComputedWeight());
+
+ if (referenceWeight == null) {
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
+ benthosBatch.getSampleCategoryWeight(),
+ benthosBatch.getSampleCategoryComputedWeight());
+ }
+ }
+
+ for (BenthosBatchFrequency batchFrequency : benthosBatchFrequency) {
+ CatchExportRow row = currentRow.copy();
+ row.setBenthosFrequency(batchFrequency);
+ rows.add(row);
+
+ if (!withNoWeightOnFrequencies) {
+
+ // use concrete frequency weight
+ referenceWeight = batchFrequency.getWeight();
+ }
+
+ setRaisingFactor(row, totalBatchWeight, referenceWeight);
+ }
+ }
+
+ } else {
+
+ for (BenthosBatch childBatch : benthosBatch.getChildBatchs()) {
+ prepareSortedRows(persistenceService,
+ currentRow,
+ rows,
+ childBatch,
+ totalBatchWeight);
+ }
+ }
+
+ // remove last comment (otherwise next brother will have this one too...)
+ currentRow.popLastComment();
+ }
+
+ protected void prepareUnsortedRows(CatchExportRow currentRow,
+ List<CatchExportRow> rows,
+ BenthosBatch benthosBatch) {
+
+ prepareBatch(currentRow,
+ benthosBatch.getSampleCategoryId(),
+ benthosBatch.getSampleCategoryValue(),
+ benthosBatch.getSampleCategoryWeight(),
+ benthosBatch.getSampleCategoryComputedWeight(),
+ benthosBatch.getWeight(),
+ benthosBatch.getNumber(),
+ benthosBatch.getRankOrder());
+
+ CatchExportRow row = currentRow.copy();
+ row.addComment(benthosBatch.getComment());
+
+ Float referenceWeight = TuttiEntities.getValueOrComputedValue(
+ benthosBatch.getSampleCategoryWeight(),
+ benthosBatch.getSampleCategoryComputedWeight());
+
+ setRaisingFactor(row, referenceWeight, referenceWeight);
+
+ rows.add(row);
+ }
+
+ protected void setRaisingFactor(CatchExportRow row,
+ float totalBatchWeight,
+ Float referenceWeight) {
+ row.setReferenceWeight(referenceWeight);
+ row.setRaisingFactor(referenceWeight == null ? 1.0f : (totalBatchWeight / referenceWeight));
+ }
+
+ protected void prepareBatch(CatchExportRow currentRow,
+ Integer sampleCategoryId,
+ Serializable sampleCategoryValue,
+ Float sampleCategoryWeight,
+ Float sampleCategoryComputedWeight,
+ Float batchWeight,
+ Integer batchNumber,
+ Integer batchRankOrder) {
+ currentRow.setBatchNumber(batchNumber);
+
+ ExportSampleCategory<Serializable> sampleCategory =
+ new ExportSampleCategory<Serializable>();
+ SampleCategoryModelEntry categoryById =
+ sampleCategoryModel.getCategoryById(sampleCategoryId);
+ sampleCategory.setCategoryDef(categoryById);
+ sampleCategory.setCategoryValue(sampleCategoryValue);
+ sampleCategory.setCategoryWeight(sampleCategoryWeight);
+ sampleCategory.setSampleWeight(batchWeight);
+
+ sampleCategory.setComputedWeight(sampleCategoryComputedWeight);
+ sampleCategory.setWeightOrVolType(WEIGHT_OR_VOL_TYPE);
+ sampleCategory.setRankOrder(batchRankOrder);
+
+ currentRow.addSampleCategory(sampleCategory);
+ }
+
+ protected void addSampleCategory(String headerPrefix, int categoryOrder) {
+
+ String categoryName = CatchExportRow.SAMPLE_CATEGORY;
+ newIndexNullableColumnForExport(headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ newIndexNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName, categoryOrder, ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER);
+ newIndexNullableColumnForExport("Tot_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT);
+ newIndexNullableColumnForExport("Ech_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT);
+ newIndexNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE);
+ newNullableColumnForExport("Unite_Volume_Poids_" + headerPrefix, CatchExportRow.BATCH_WEIGHT_UNIT);
+ }
+
+}
\ No newline at end of file
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportRow.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,254 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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 com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * A row in a catch export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class CatchExportRow implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(CatchExportRow.class);
+
+ public static final String FREQUENCY_LENGTH_STEP = "frequency.lengthStep";
+
+ public static final String FREQUENCY_NUMBER = "frequency.number";
+
+ public static final String FREQUENCY_WEIGHT = "frequency.weight";
+
+ public static final String FREQUENCY_LENGTH_STEP_CARACTERISTIC = "frequency.lengthStepCaracteristic";
+
+ public static final String FREQUENCY_RANK_ORDER = "frequency.rankOrder";
+
+ public static final String SAMPLE_CATEGORY = "sampleCategory";
+
+ public static final String REFERENCE_WEIGHT = "referenceWeight";
+
+ public static final String RAISING_FACTOR = "raisingFactor";
+
+ public static final String BATCH_NUMBER = "batchNumber";
+
+ public static final String BATCH_WEIGHT_UNIT = "batchWeightUnit";
+
+ protected Cruise cruise;
+
+ protected FishingOperation fishingOperation;
+
+ protected final List<ExportSampleCategory> sampleCategory = Lists.newLinkedList();
+
+ protected SpeciesBatchFrequency speciesFrequency;
+
+ protected BenthosBatchFrequency benthosFrequency;
+
+ protected Species species;
+
+ protected Float referenceWeight;
+
+ protected float raisingFactor;
+
+ protected Integer batchNumber;
+
+ protected String batchWeightUnit;
+
+ protected final List<String> comment = Lists.newArrayList();
+
+ public void setCruise(Cruise cruise) {
+ this.cruise = cruise;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public void setReferenceWeight(Float referenceWeight) {
+ this.referenceWeight = referenceWeight;
+ }
+
+ public void setRaisingFactor(float raisingFactor) {
+ this.raisingFactor = raisingFactor;
+ }
+
+ public void setBatchNumber(Integer batchNumber) {
+ this.batchNumber = batchNumber;
+ }
+
+ public void addSampleCategory(ExportSampleCategory sampleCategory) {
+ int order = sampleCategory.getCategoryDef().getOrder();
+ while (this.sampleCategory.size() <= order) {
+ this.sampleCategory.add(null);
+ }
+ this.sampleCategory.set(order, sampleCategory);
+ }
+
+ public void setSpeciesFrequency(SpeciesBatchFrequency speciesFrequency) {
+ Preconditions.checkNotNull(speciesFrequency);
+ this.speciesFrequency = speciesFrequency;
+ this.batchNumber = speciesFrequency.getNumber();
+ }
+
+ public void setBenthosFrequency(BenthosBatchFrequency benthosFrequency) {
+ Preconditions.checkNotNull(benthosFrequency);
+ this.benthosFrequency = benthosFrequency;
+ this.batchNumber = benthosFrequency.getNumber();
+ }
+
+ public Date getBeginDate() {
+ return cruise.getBeginDate();
+ }
+
+ public Program getProgram() {
+ return cruise.getProgram();
+ }
+
+ public String getSurveyPart() {
+ return cruise.getSurveyPart();
+ }
+
+ public Vessel getVessel() {
+ return cruise.getVessel();
+ }
+
+ public String getStationNumber() {
+ return fishingOperation.getStationNumber();
+ }
+
+ public Integer getFishingOperationNumber() {
+ return fishingOperation.getFishingOperationNumber();
+ }
+
+ public Gear getGear() {
+ return fishingOperation.getGear();
+ }
+
+ public String getMultirigAggregation() {
+ return fishingOperation.getMultirigAggregation();
+ }
+
+ public Object getFrequency() {
+ return speciesFrequency == null ? benthosFrequency : speciesFrequency;
+ }
+
+ public List<ExportSampleCategory> getSampleCategory() {
+ return sampleCategory;
+ }
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(Species species) {
+ this.species = species;
+ }
+
+ public Float getReferenceWeight() {
+ return referenceWeight;
+ }
+
+ public float getRaisingFactor() {
+ return raisingFactor;
+ }
+
+ public Integer getBatchNumber() {
+ return batchNumber;
+ }
+
+ public String getBatchWeightUnit() {
+ return batchWeightUnit;
+ }
+
+ public void setBatchWeightUnit(String batchWeightUnit) {
+ this.batchWeightUnit = batchWeightUnit;
+ }
+
+ public CatchExportRow copy() {
+ CatchExportRow result = new CatchExportRow();
+ result.setCruise(cruise);
+ result.setFishingOperation(fishingOperation);
+// result.setSpeciesCategory(speciesCategory);
+ result.sampleCategory.addAll(sampleCategory);
+ if (benthosFrequency != null) {
+ result.setBenthosFrequency(benthosFrequency);
+ }
+ if (speciesFrequency != null) {
+ result.setSpeciesFrequency(speciesFrequency);
+ }
+ result.setSpecies(species);
+ result.setRaisingFactor(raisingFactor);
+ result.setReferenceWeight(referenceWeight);
+ result.setBatchNumber(batchNumber);
+ result.setBatchWeightUnit(batchWeightUnit);
+ result.comment.addAll(comment);
+
+ return result;
+ }
+
+ public void addComment(String comment) {
+ String safeComment = StringUtils.isEmpty(comment) ? "" : comment;
+ if (log.isDebugEnabled()) {
+ log.debug("Add comment: " + safeComment);
+ }
+ this.comment.add(safeComment);
+ }
+
+ public void popLastComment() {
+ if (!comment.isEmpty()) {
+ this.comment.remove(this.comment.size() - 1);
+ }
+ }
+
+ public String getComment() {
+ String result;
+ if (comment.isEmpty()) {
+ result = "";
+ } else {
+ result = Joiner.on('|').join(comment);
+ }
+ return result;
+ }
+}
\ No newline at end of file
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ExportSampleCategory.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportSampleCategory.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ExportSampleCategory.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ExportSampleCategory.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,95 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.SampleCategory;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+
+import java.io.Serializable;
+
+/**
+ * Export sample category (extends {@link SampleCategory} to some computed
+ * stuff.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class ExportSampleCategory<S extends Serializable> extends SampleCategory<S> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CATEGORY_CARACTERISTIC = "categoryCaracteristic";
+
+ public static final String PROPERTY_CATEGORY_VALUE = "categoryValue";
+
+ public static final String PROPERTY_CATEGORY_WEIGHT = "categoryWeight";
+
+ public static final String PROPERTY_NUMBER = "number";
+
+ public static final String PROPERTY_COMPUTED_WEIGHT = "computedWeight";
+
+ public static final String PROPERTY_COMPUTED_NUMBER = "computedNumber";
+
+ public static final String PROPERTY_WEIGHT_OR_VOL_TYPE = "weightOrVolType";
+
+ public static final String PROPERTY_RANK_ORDER = "rankOrder";
+
+ public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
+
+ private Integer rankOrder;
+
+ private String weightOrVolType;
+
+ private Float sampleWeight;
+
+ public String getWeightOrVolType() {
+ return weightOrVolType;
+ }
+
+ public void setWeightOrVolType(String weightOrVolType) {
+ this.weightOrVolType = weightOrVolType;
+ }
+
+ public Integer getRankOrder() {
+ return rankOrder;
+ }
+
+ public void setRankOrder(Integer rankOrder) {
+ this.rankOrder = rankOrder;
+ }
+
+ public Float getSampleWeight() {
+ return sampleWeight;
+ }
+
+ public void setSampleWeight(Float sampleWeight) {
+ this.sampleWeight = sampleWeight;
+ }
+
+ public Caracteristic getCategoryCaracteristic() {
+ return categoryDef.getCaracteristic();
+ }
+
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GearCaracteristicExportModel.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/GearCaracteristicExportModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GearCaracteristicExportModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GearCaracteristicExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,76 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * To export gear caracteristics.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.3.2
+ */
+public class GearCaracteristicExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<GearCaracteristicExportRow> {
+
+ public GearCaracteristicExportModel(char separator, DecoratorService decoratorService) {
+ super(separator);
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newColumnForExport("Engin", GearCaracteristicExportRow.PROPERTY_GEAR, Gear.PROPERTY_NAME);
+ newColumnForExport("Code_PMFM", GearCaracteristicExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
+ newColumnForExportByDecorator("Libelle_PMFM", GearCaracteristicExportRow.PROPERTY_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
+ newColumnForExport("Valeur", GearCaracteristicExportRow.PROPERTY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ }
+
+ public void prepareRows(List<GearCaracteristicExportRow> rows, Cruise cruise,
+ Gear gear) {
+ CaracteristicMap caracteristics = gear.getCaracteristics();
+ if (caracteristics != null) {
+ for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
+ Caracteristic caracteristic = entry.getKey();
+ Serializable value = entry.getValue();
+ GearCaracteristicExportRow row = new GearCaracteristicExportRow();
+ row.setCruise(cruise);
+ row.setGear(gear);
+ row.setCaracteristic(caracteristic);
+ row.setValue(value);
+ rows.add(row);
+ }
+ }
+ }
+
+}
\ No newline at end of file
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GearCaracteristicExportRow.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/GearCaracteristicExportRow.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GearCaracteristicExportRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GearCaracteristicExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,98 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * A row in a gear caracteristics export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.3.2
+ */
+public class GearCaracteristicExportRow implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_GEAR = "gear";
+
+ public static final String PROPERTY_CARACTERISTIC = "caracteristic";
+
+ public static final String PROPERTY_VALUE = "value";
+
+ protected Cruise cruise;
+
+ protected Gear gear;
+
+ protected Caracteristic caracteristic;
+
+ private Serializable value;
+
+ public void setCruise(Cruise cruise) {
+ this.cruise = cruise;
+ }
+
+ public void setGear(Gear gear) {
+ this.gear = gear;
+ }
+
+ public void setCaracteristic(Caracteristic caracteristic) {
+ this.caracteristic = caracteristic;
+ }
+
+ public void setValue(Serializable value) {
+ this.value = value;
+ }
+
+ public Date getBeginDate() {
+ return cruise.getBeginDate();
+ }
+
+ public Program getProgram() {
+ return cruise.getProgram();
+ }
+
+ public String getSurveyPart() {
+ return cruise.getSurveyPart();
+ }
+
+ public Gear getGear() {
+ return gear;
+ }
+
+ public Caracteristic getCaracteristic() {
+ return caracteristic;
+ }
+
+ public Serializable getValue() {
+ return value;
+ }
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/IndividualObservationExportModel.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/IndividualObservationExportModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/IndividualObservationExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,170 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Model of a individual observation export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0.1
+ */
+public class IndividualObservationExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<IndividualObservationExportRow> {
+
+// protected final Caracteristic caracteristicSample;
+//
+// protected final Caracteristic caracteristicOtolithe;
+
+ protected final Caracteristic caracteristicWeight;
+
+ protected final Caracteristic caracteristicPmfmId;
+
+ public IndividualObservationExportModel(
+ char separator,
+// Caracteristic caracteristicSample,
+// Caracteristic caracteristicOtolithe,
+ Caracteristic caracteristicWeight,
+ Caracteristic caracteristicPmfmId) {
+ super(separator);
+
+// this.caracteristicSample = caracteristicSample;
+// this.caracteristicOtolithe = caracteristicOtolithe;
+ this.caracteristicWeight = caracteristicWeight;
+ this.caracteristicPmfmId = caracteristicPmfmId;
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
+ newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
+
+ newColumnForExport("BatchId", IndividualObservationExportRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("ReferenceTaxonId", IndividualObservationBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("ReferenceTaxonName", IndividualObservationBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
+ newColumnForExport("Commentaire", IndividualObservationBatch.PROPERTY_COMMENT);
+ newColumnForExport("CaracteristicId", IndividualObservationExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
+ newColumnForExport("CaracteristicValue", IndividualObservationExportRow.PROPERTY_CARACTERISTIC_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ }
+
+ public void prepareRows(PersistenceService persistenceService,
+ List<IndividualObservationExportRow> rows,
+ Cruise cruise,
+ FishingOperation operation) {
+
+ List<IndividualObservationBatch> observations =
+ persistenceService.getAllIndividualObservationBatch(operation.getId());
+
+ if (CollectionUtils.isNotEmpty(observations)) {
+ for (IndividualObservationBatch child : observations) {
+
+// addCaracteristicRow(rows,
+// cruise,
+// operation,
+// child,
+// caracteristicSample,
+// child.getSamplingCode());
+//
+// addCaracteristicRow(rows,
+// cruise,
+// operation,
+// child,
+// caracteristicOtolithe,
+// child.getCalcifiedPieceSamplingCode());
+
+ addCaracteristicRow(rows,
+ cruise,
+ operation,
+ child,
+ caracteristicWeight,
+ child.getWeight());
+
+ if (child.getLengthStepCaracteristic() != null) {
+ addCaracteristicRow(rows,
+ cruise,
+ operation,
+ child,
+ caracteristicPmfmId,
+ child.getLengthStepCaracteristic().getIdAsInt());
+
+ addCaracteristicRow(rows,
+ cruise,
+ operation,
+ child,
+ child.getLengthStepCaracteristic(),
+ child.getSize());
+ }
+
+ CaracteristicMap caracteristics = child.getCaracteristics();
+ if (MapUtils.isNotEmpty(caracteristics)) {
+ for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
+ addCaracteristicRow(rows,
+ cruise,
+ operation,
+ child,
+ entry.getKey(),
+ entry.getValue());
+ }
+ }
+ }
+ }
+ }
+
+ private void addCaracteristicRow(List<IndividualObservationExportRow> rows,
+ Cruise cruise,
+ FishingOperation operation,
+ IndividualObservationBatch child,
+ Caracteristic caracteristic,
+ Serializable caracteristicValue) {
+ if (caracteristicValue != null) {
+
+ IndividualObservationExportRow row = new IndividualObservationExportRow();
+ row.setCruise(cruise);
+ row.setFishingOperation(operation);
+ row.setBatch(child);
+ row.setCaracteristic(caracteristic);
+ row.setCaracteristicValue(caracteristicValue);
+ rows.add(row);
+ }
+ }
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/IndividualObservationExportRow.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportRow.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/IndividualObservationExportRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/IndividualObservationExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,138 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * A row in a individual observation export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0.1
+ */
+public class IndividualObservationExportRow implements Serializable {
+
+ public static final String PROPERTY_BATCH = "batch";
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_BATCH_ID = "batchId";
+
+ public static final String PROPERTY_CARACTERISTIC = "caracteristic";
+
+ public static final String PROPERTY_CARACTERISTIC_VALUE = "caracteristicValue";
+
+ protected Cruise cruise;
+
+ protected FishingOperation fishingOperation;
+
+ protected IndividualObservationBatch batch;
+
+ protected Caracteristic caracteristic;
+
+ protected Serializable caracteristicValue;
+
+ public void setCruise(Cruise cruise) {
+ this.cruise = cruise;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public void setBatch(IndividualObservationBatch batch) {
+ this.batch = batch;
+ }
+
+ public void setCaracteristic(Caracteristic caracteristic) {
+ this.caracteristic = caracteristic;
+ }
+
+ public void setCaracteristicValue(Serializable caracteristicValue) {
+ this.caracteristicValue = caracteristicValue;
+ }
+
+ public Integer getBatchId() {
+ return batch.getIdAsInt();
+ }
+
+ public Caracteristic getCaracteristic() {
+ return caracteristic;
+ }
+
+ public Serializable getCaracteristicValue() {
+ return caracteristicValue;
+ }
+
+ public String getComment() {
+ return batch.getComment();
+ }
+
+ public Date getBeginDate() {
+ return cruise.getBeginDate();
+ }
+
+ public Program getProgram() {
+ return cruise.getProgram();
+ }
+
+ public String getSurveyPart() {
+ return cruise.getSurveyPart();
+ }
+
+ public String getStationNumber() {
+ return fishingOperation.getStationNumber();
+ }
+
+ public Integer getFishingOperationNumber() {
+ return fishingOperation.getFishingOperationNumber();
+ }
+
+ public Gear getGear() {
+ return fishingOperation.getGear();
+ }
+
+ public Vessel getVessel() {
+ return fishingOperation.getVessel();
+ }
+
+ public String getMultirigAggregation() {
+ return fishingOperation.getMultirigAggregation();
+ }
+
+ public Species getSpecies() {
+ return batch.getSpecies();
+ }
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/MarineLitterExportModel.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/MarineLitterExportModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/MarineLitterExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,85 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import org.apache.commons.collections.CollectionUtils;
+
+import java.util.List;
+
+/**
+ * Model of a marine litter export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0.1
+ */
+public class MarineLitterExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<MarineLitterExportRow> {
+
+ public MarineLitterExportModel(char separator) {
+ super(separator);
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
+ newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
+
+ newColumnForExport("MarineLitterCategory", MarineLitterBatch.PROPERTY_MARINE_LITTER_CATEGORY, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ newColumnForExport("MarineLitterSizeCategory", MarineLitterBatch.PROPERTY_MARINE_LITTER_SIZE_CATEGORY, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ newColumnForExport("Number", MarineLitterBatch.PROPERTY_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Weight", MarineLitterBatch.PROPERTY_WEIGHT, TuttiCsvUtil.FLOAT);
+ newColumnForExport("Commentaire", MarineLitterBatch.PROPERTY_COMMENT);
+ }
+
+ public void prepareRows(PersistenceService persistenceService,
+ List<MarineLitterExportRow> rows,
+ Cruise cruise,
+ FishingOperation operation) {
+
+ BatchContainer<MarineLitterBatch> rootMarineLitterBatch =
+ persistenceService.getRootMarineLitterBatch(operation.getId());
+
+ List<MarineLitterBatch> children = rootMarineLitterBatch.getChildren();
+ if (CollectionUtils.isNotEmpty(children)) {
+ for (MarineLitterBatch child : children) {
+ MarineLitterExportRow row = new MarineLitterExportRow();
+ row.setCruise(cruise);
+ row.setFishingOperation(operation);
+ row.setBatch(child);
+ rows.add(row);
+ }
+ }
+ }
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/MarineLitterExportRow.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportRow.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/MarineLitterExportRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/MarineLitterExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,121 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * A row in a marine litter export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0.1
+ */
+public class MarineLitterExportRow implements Serializable {
+
+ public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
+
+ public static final String PROPERTY_BATCH = "batch";
+
+ private static final long serialVersionUID = 1L;
+
+ protected Cruise cruise;
+
+ protected FishingOperation fishingOperation;
+
+ protected MarineLitterBatch batch;
+
+ public void setCruise(Cruise cruise) {
+ this.cruise = cruise;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public void setBatch(MarineLitterBatch batch) {
+ this.batch = batch;
+ }
+
+ public CaracteristicQualitativeValue getMarineLitterCategory() {
+ return batch.getMarineLitterCategory();
+ }
+
+ public CaracteristicQualitativeValue getMarineLitterSizeCategory() {
+ return batch.getMarineLitterSizeCategory();
+ }
+
+ public Integer getNumber() {
+ return batch.getNumber();
+ }
+
+ public Float getWeight() {
+ return batch.getWeight();
+ }
+
+ public String getComment() {
+ return batch.getComment();
+ }
+
+ public Date getBeginDate() {
+ return cruise.getBeginDate();
+ }
+
+ public Program getProgram() {
+ return cruise.getProgram();
+ }
+
+ public String getSurveyPart() {
+ return cruise.getSurveyPart();
+ }
+
+ public String getStationNumber() {
+ return fishingOperation.getStationNumber();
+ }
+
+ public Integer getFishingOperationNumber() {
+ return fishingOperation.getFishingOperationNumber();
+ }
+
+ public Gear getGear() {
+ return fishingOperation.getGear();
+ }
+
+ public Vessel getVessel() {
+ return fishingOperation.getVessel();
+ }
+
+ public String getMultirigAggregation() {
+ return fishingOperation.getMultirigAggregation();
+ }
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportModel.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,166 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import org.nuiton.decorator.Decorator;
+
+import java.util.List;
+
+/**
+ * Model of a operation export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class OperationExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<OperationExportRow> {
+
+
+ protected final Caracteristic verticalOpeningCaracteristic;
+
+ protected final Caracteristic horizontalOpeningWingCaracteristic;
+
+ protected final Caracteristic horizontalOpeningDoorCaracteristic;
+
+ public OperationExportModel(char separator,
+ Caracteristic verticalOpeningCaracteristic,
+ Caracteristic horizontalOpeningWingCaracteristic,
+ Caracteristic horizontalOpeningDoorCaracteristic,
+ Decorator<Vessel> vesselDecorator) {
+ super(separator);
+ this.verticalOpeningCaracteristic = verticalOpeningCaracteristic;
+ this.horizontalOpeningWingCaracteristic = horizontalOpeningWingCaracteristic;
+ this.horizontalOpeningDoorCaracteristic = horizontalOpeningDoorCaracteristic;
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newColumnForExport("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
+ newColumnForExport("Navire", FishingOperation.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
+ newColumnForExport("DateDeb_Op", FishingOperation.PROPERTY_GEAR_SHOOTING_START_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newColumnForExport("LatDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LATITUDE, TuttiCsvUtil.FLOAT);
+ newColumnForExport("LongDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LONGITUDE, TuttiCsvUtil.FLOAT);
+ newColumnForExport("DateFin_Op", FishingOperation.PROPERTY_GEAR_SHOOTING_END_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newColumnForExport("LatFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_LATITUDE, TuttiCsvUtil.FLOAT);
+ newColumnForExport("LongFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_LONGITUDE, TuttiCsvUtil.FLOAT);
+ newColumnForExport("Duree", OperationExportRow.PROPERTY_DURATION);
+ newColumnForExport("Strate", FishingOperation.PROPERTY_STRATA, TuttiLocation.PROPERTY_NAME, "NA");
+ newColumnForExport("Sous-Strate", FishingOperation.PROPERTY_SUB_STRATA, TuttiLocation.PROPERTY_NAME, "NA");
+ newColumnForExport("Localite", FishingOperation.PROPERTY_LOCATION, TuttiLocation.PROPERTY_NAME, "NA");
+ newColumnForExport("Validite_OP", FishingOperation.PROPERTY_FISHING_OPERATION_VALID, TuttiCsvUtil.BOOLEAN);
+ newColumnForExport("Rectiligne", FishingOperation.PROPERTY_FISHING_OPERATION_RECTILIGNE, TuttiCsvUtil.BOOLEAN);
+ newColumnForExport("Distance", FishingOperation.PROPERTY_TRAWL_DISTANCE, TuttiCsvUtil.FLOAT);
+ newColumnForExport("Ouv_Verticale", OperationExportRow.PROPERTY_VERTICAL_OPENING_GEAR_USE_FEATURE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ newColumnForExport("Ouv_Horizontale_Ailes", OperationExportRow.PROPERTY_HORIZONTAL_OPENING_WING_GEAR_USE_FEATURE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ newColumnForExport("Ouv_Horizontale_Panneaux", OperationExportRow.PROPERTY_HORIZONTAL_OPENING_DOOR_GEAR_USE_FEATURE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ newColumnForExport("Saisisseur", FishingOperation.PROPERTY_RECORDER_PERSON, TuttiCsvUtil.LIST_PERSON_FORMATTER);
+ newColumnForExport("NavireAssocie", FishingOperation.PROPERTY_SECONDARY_VESSEL, TuttiCsvUtil.newListVesselFormatter(vesselDecorator));
+ newColumnForExport("Commentaire", FishingOperation.PROPERTY_COMMENT);
+
+ newNullableColumnForExport("Poids_Total", OperationExportRow.PROPERTY_CATCH_TOTAL_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Vrac", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Vrac_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_HorsVrac", OperationExportRow.PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_HorsVrac_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Non_Trie", OperationExportRow.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Non_Trie_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Tremis", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Tremis_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Carroussel", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Carroussel_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece", OperationExportRow.PROPERTY_SPECIES_TOTAL_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Espece_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece_Vrac", OperationExportRow.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Espece_Vrac_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece_Vrac_Trie", OperationExportRow.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Espece_Vrac_Trie_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece_HorsVrac", OperationExportRow.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Espece_HorsVrac_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece_Inerte_Trie", OperationExportRow.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Espece_Inerte_Trie_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece_Vivant_non_detaille_trie", OperationExportRow.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Espece_Vivant_non_detaille_trie_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos", OperationExportRow.PROPERTY_BENTHOS_TOTAL_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Benthos_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos_Vrac", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Benthos_Vrac_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos_Vrac_Trie", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Benthos_Vrac_Trie_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos_HorsVrac", OperationExportRow.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Benthos_HorsVrac_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos_Inerte_Trie", OperationExportRow.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Benthos_Inerte_Trie_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos_Vivant_non_detaille_trie", OperationExportRow.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Macro_Dechet", OperationExportRow.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Poids_Total_Macro_Dechet_Calcule", OperationExportRow.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+ }
+
+ public void prepareRows(List<OperationExportRow> rows,
+ Cruise cruise,
+ FishingOperation operation,
+ CatchBatch catchBatch) {
+
+ OperationExportRow row = new OperationExportRow(
+ verticalOpeningCaracteristic,
+ horizontalOpeningWingCaracteristic,
+ horizontalOpeningDoorCaracteristic);
+ row.setCruise(cruise);
+ row.setFishingOperation(operation);
+ row.setCatchBatch(catchBatch);
+ rows.add(row);
+
+ }
+}
\ No newline at end of file
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportRow.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,499 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Person;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * A row in a operation export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class OperationExportRow implements Serializable {
+
+ public static final String PROPERTY_DURATION = "duration";
+
+ public static final String PROPERTY_VERTICAL_OPENING_GEAR_USE_FEATURE = "verticalOpeningGearUseFeature";
+
+ public static final String PROPERTY_HORIZONTAL_OPENING_WING_GEAR_USE_FEATURE = "horizontalOpeningWingGearUseFeature";
+
+ public static final String PROPERTY_HORIZONTAL_OPENING_DOOR_GEAR_USE_FEATURE = "horizontalOpeningDoorGearUseFeature";
+
+ public static final String PROPERTY_CATCH_TOTAL_WEIGHT = "catchTotalWeight";
+
+ public static final String PROPERTY_CATCH_TOTAL_WEIGHT_COMPUTED = "catchTotalWeightComputed";
+
+ public static final String PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT = "catchTotalSortedTremisWeight";
+
+ public static final String PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT_COMPUTED = "catchTotalSortedTremisWeightComputed";
+
+ public static final String PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT = "catchTotalSortedCarousselWeight";
+
+ public static final String PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT_COMPUTED = "catchTotalSortedCarousselWeightComputed";
+
+ public static final String PROPERTY_CATCH_TOTAL_SORTED_WEIGHT = "catchTotalSortedWeight";
+
+ public static final String PROPERTY_CATCH_TOTAL_SORTED_WEIGHT_COMPUTED = "catchTotalSortedWeightComputed";
+
+ public static final String PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT = "catchTotalUnsortedWeight";
+
+ public static final String PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT_COMPUTED = "catchTotalUnsortedWeightComputed";
+
+ public static final String PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT = "catchTotalRejectedWeight";
+
+ public static final String PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT_COMPUTED = "catchTotalRejectedWeightComputed";
+
+
+ public static final String PROPERTY_SPECIES_TOTAL_WEIGHT = "speciesTotalWeight";
+
+ public static final String PROPERTY_SPECIES_TOTAL_WEIGHT_COMPUTED = "speciesTotalWeightComputed";
+
+ public static final String PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT = "speciesTotalSortedWeight";
+
+ public static final String PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT_COMPUTED = "speciesTotalSortedWeightComputed";
+
+ public static final String PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT = "speciesTotalUnsortedWeight";
+
+ public static final String PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT_COMPUTED = "speciesTotalUnsortedWeightComputed";
+
+ public static final String PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT = "speciesTotalSampleSortedWeight";
+
+ public static final String PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED = "speciesTotalSampleSortedWeightComputed";
+
+ public static final String PROPERTY_SPECIES_TOTAL_INERT_WEIGHT = "speciesTotalInertWeight";
+
+ public static final String PROPERTY_SPECIES_TOTAL_INERT_WEIGHT_COMPUTED = "speciesTotalInertWeightComputed";
+
+ public static final String PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT = "speciesTotalLivingNotItemizedWeight";
+
+ public static final String PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED = "speciesTotalLivingNotItemizedWeightComputed";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_WEIGHT = "benthosTotalWeight";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_WEIGHT_COMPUTED = "benthosTotalWeightComputed";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT = "benthosTotalSortedWeight";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT_COMPUTED = "benthosTotalSortedWeightComputed";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT = "benthosTotalUnsortedWeight";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT_COMPUTED = "benthosTotalUnsortedWeightComputed";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT = "benthosTotalSampleSortedWeight";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED = "benthosTotalSampleSortedWeightComputed";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT = "benthosTotalInertWeight";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT_COMPUTED = "benthosTotalInertWeightComputed";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT = "benthosTotalLivingNotItemizedWeight";
+
+ public static final String PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED = "benthosTotalLivingNotItemizedWeightComputed";
+
+ public static final String PROPERTY_MARINE_LITTER_TOTAL_WEIGHT = "marineLitterTotalWeight";
+
+ public static final String PROPERTY_MARINE_LITTER_TOTAL_WEIGHT_COMPUTED = "marineLitterTotalWeightComputed";
+
+ private static final long serialVersionUID = 1L;
+
+ protected Cruise cruise;
+
+ protected FishingOperation fishingOperation;
+
+ protected CatchBatch catchBatch;
+
+ private Caracteristic verticalOpeningCaracteristic;
+
+ private Caracteristic horizontalOpeningWingCaracteristic;
+
+ private Caracteristic horizontalOpeningDoorCaracteristic;
+
+ public OperationExportRow(Caracteristic verticalOpeningCaracteristic,
+ Caracteristic horizontalOpeningWingCaracteristic,
+ Caracteristic horizontalOpeningDoorCaracteristic) {
+
+ this.verticalOpeningCaracteristic = verticalOpeningCaracteristic;
+ this.horizontalOpeningWingCaracteristic = horizontalOpeningWingCaracteristic;
+ this.horizontalOpeningDoorCaracteristic = horizontalOpeningDoorCaracteristic;
+ }
+
+ public void setCruise(Cruise cruise) {
+ this.cruise = cruise;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public void setCatchBatch(CatchBatch catchBatch) {
+ this.catchBatch = catchBatch;
+ }
+
+ public Date getBeginDate() {
+ return cruise.getBeginDate();
+ }
+
+ public Program getProgram() {
+ return cruise.getProgram();
+ }
+
+ public String getSurveyPart() {
+ return cruise.getSurveyPart();
+ }
+
+ public String getStationNumber() {
+ return fishingOperation.getStationNumber();
+ }
+
+ public Integer getFishingOperationNumber() {
+ return fishingOperation.getFishingOperationNumber();
+ }
+
+ public String getMultirigAggregation() {
+ return fishingOperation.getMultirigAggregation();
+ }
+
+ public Gear getGear() {
+ return fishingOperation.getGear();
+ }
+
+ public Vessel getVessel() {
+ return fishingOperation.getVessel();
+ }
+
+ public Date getGearShootingStartDate() {
+ return fishingOperation.getGearShootingStartDate();
+ }
+
+ public Float getGearShootingStartLatitude() {
+ return fishingOperation.getGearShootingStartLatitude();
+ }
+
+ public Float getGearShootingStartLongitude() {
+ return fishingOperation.getGearShootingStartLongitude();
+ }
+
+ public Date getGearShootingEndDate() {
+ return fishingOperation.getGearShootingEndDate();
+ }
+
+ public Float getGearShootingEndLatitude() {
+ return fishingOperation.getGearShootingEndLatitude();
+ }
+
+ public Float getGearShootingEndLongitude() {
+ return fishingOperation.getGearShootingEndLongitude();
+ }
+
+ public TuttiLocation getStrata() {
+ return fishingOperation.getStrata();
+ }
+
+ public TuttiLocation getSubStrata() {
+ return fishingOperation.getSubStrata();
+ }
+
+ public TuttiLocation getLocation() {
+ return fishingOperation.getLocation();
+ }
+
+ public Boolean getFishingOperationValid() {
+ return fishingOperation.getFishingOperationValid();
+ }
+
+ public boolean isFishingOperationRectiligne() {
+ return fishingOperation.isFishingOperationRectiligne();
+ }
+
+ public Float getTrawlDistance() {
+ return fishingOperation.getTrawlDistance();
+ }
+
+ public String getComment() {
+ return fishingOperation.getComment();
+ }
+
+ public List<Person> getRecorderPerson() {
+ return fishingOperation.getRecorderPerson();
+ }
+
+ public List<Vessel> getSecondaryVessel() {
+ return fishingOperation.getSecondaryVessel();
+ }
+
+ public String getDuration() {
+ return TuttiEntities.getDuration(
+ getGearShootingStartDate(),
+ getGearShootingEndDate(),
+ "mm");
+ }
+
+ public Serializable getVerticalOpeningGearUseFeature() {
+ Serializable result = getGearUseFeature(verticalOpeningCaracteristic);
+ return result;
+ }
+
+ public Serializable getHorizontalOpeningWingGearUseFeature() {
+ Serializable result = getGearUseFeature(horizontalOpeningWingCaracteristic);
+ return result;
+ }
+
+ public Serializable getHorizontalOpeningDoorGearUseFeature() {
+ Serializable result = getGearUseFeature(horizontalOpeningDoorCaracteristic);
+ return result;
+ }
+
+ public Float getCatchTotalWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getCatchTotalWeight(),
+ catchBatch.getCatchTotalComputedWeight());
+ }
+
+ public Boolean getCatchTotalWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getCatchTotalWeight(),
+ catchBatch.getCatchTotalComputedWeight());
+ }
+
+ public Float getCatchTotalSortedTremisWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getCatchTotalSortedTremisWeight(), null);
+ }
+
+ public Boolean getCatchTotalSortedTremisWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getCatchTotalSortedTremisWeight(), null);
+ }
+
+ public Float getCatchTotalSortedCarousselWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getCatchTotalSortedCarousselWeight(), null);
+ }
+
+ public Boolean getCatchTotalSortedCarousselWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getCatchTotalSortedCarousselWeight(), null);
+ }
+
+ public Float getCatchTotalSortedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ null, catchBatch.getCatchTotalSortedComputedWeight());
+ }
+
+ public Boolean getCatchTotalSortedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ null, catchBatch.getCatchTotalSortedComputedWeight());
+ }
+
+ public Float getCatchTotalUnsortedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ null, catchBatch.getCatchTotalUnsortedComputedWeight());
+ }
+
+ public Boolean getCatchTotalUnsortedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ null, catchBatch.getCatchTotalUnsortedComputedWeight());
+ }
+
+ public Float getCatchTotalRejectedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getCatchTotalRejectedWeight(),
+ catchBatch.getCatchTotalRejectedComputedWeight());
+ }
+
+ public Boolean getCatchTotalRejectedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getCatchTotalRejectedWeight(),
+ catchBatch.getCatchTotalRejectedComputedWeight());
+ }
+
+ public Float getSpeciesTotalWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ null, catchBatch.getSpeciesTotalComputedWeight());
+ }
+
+ public Boolean getSpeciesTotalWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ null, catchBatch.getSpeciesTotalComputedWeight());
+ }
+
+ public Float getSpeciesTotalSortedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalSortedWeight(),
+ catchBatch.getSpeciesTotalSortedComputedWeight());
+ }
+
+ public Boolean getSpeciesTotalSortedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getSpeciesTotalSortedWeight(),
+ catchBatch.getSpeciesTotalSortedComputedWeight());
+ }
+
+ public Float getSpeciesTotalUnsortedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ null, catchBatch.getSpeciesTotalUnsortedComputedWeight());
+ }
+
+ public Boolean getSpeciesTotalUnsortedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ null, catchBatch.getSpeciesTotalUnsortedComputedWeight());
+ }
+
+ public Float getSpeciesTotalSampleSortedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalSampleSortedComputedWeight(),
+ catchBatch.getSpeciesTotalSampleSortedComputedWeight());
+ }
+
+ public Boolean getSpeciesTotalSampleSortedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ null, catchBatch.getSpeciesTotalSampleSortedComputedWeight());
+ }
+
+ public Float getSpeciesTotalInertWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalInertWeight(),
+ catchBatch.getSpeciesTotalInertComputedWeight());
+ }
+
+ public Boolean getSpeciesTotalInertWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getSpeciesTotalInertWeight(),
+ catchBatch.getSpeciesTotalInertComputedWeight());
+ }
+
+ public Float getSpeciesTotalLivingNotItemizedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
+ catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
+ }
+
+ public Boolean getSpeciesTotalLivingNotItemizedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
+ catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
+ }
+
+ public Float getBenthosTotalWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ null, catchBatch.getBenthosTotalComputedWeight());
+ }
+
+ public Boolean getBenthosTotalWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ null, catchBatch.getBenthosTotalComputedWeight());
+ }
+
+ public Float getBenthosTotalSortedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalSortedWeight(),
+ catchBatch.getBenthosTotalSortedComputedWeight());
+ }
+
+ public Boolean getBenthosTotalSortedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getBenthosTotalSortedWeight(),
+ catchBatch.getBenthosTotalSortedComputedWeight());
+ }
+
+ public Float getBenthosTotalUnsortedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ null, catchBatch.getBenthosTotalUnsortedComputedWeight());
+ }
+
+ public Boolean getBenthosTotalUnsortedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ null, catchBatch.getBenthosTotalUnsortedComputedWeight());
+ }
+
+ public Float getBenthosTotalSampleSortedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ null, catchBatch.getBenthosTotalSampleSortedComputedWeight());
+ }
+
+ public Boolean getBenthosTotalSampleSortedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ null, catchBatch.getBenthosTotalSampleSortedComputedWeight());
+ }
+
+ public Float getBenthosTotalInertWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalInertWeight(),
+ catchBatch.getBenthosTotalInertComputedWeight());
+ }
+
+ public Boolean getBenthosTotalInertWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getBenthosTotalInertWeight(),
+ catchBatch.getBenthosTotalInertComputedWeight());
+ }
+
+ public Float getBenthosTotalLivingNotItemizedWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalLivingNotItemizedWeight(),
+ catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
+ }
+
+ public Boolean getBenthosTotalLivingNotItemizedWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getBenthosTotalLivingNotItemizedWeight(),
+ catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
+ }
+
+ public Float getMarineLitterTotalWeight() {
+ return TuttiEntities.getValueOrComputedValue(
+ catchBatch.getMarineLitterTotalWeight(),
+ catchBatch.getMarineLitterTotalComputedWeight());
+ }
+
+ public Boolean getMarineLitterTotalWeightComputed() {
+ return TuttiEntities.getValueOrComputedValueComputed(
+ catchBatch.getMarineLitterTotalWeight(),
+ catchBatch.getMarineLitterTotalComputedWeight());
+ }
+
+ protected Serializable getGearUseFeature(Caracteristic caracteristic) {
+ CaracteristicMap gearUseFeatures = fishingOperation.getGearUseFeatures();
+ Serializable serializable = gearUseFeatures == null ? null : gearUseFeatures.get(caracteristic);
+ return serializable;
+ }
+}
\ No newline at end of file
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ParameterExportModel.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ParameterExportModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ParameterExportModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ParameterExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,94 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Model of a parameter export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class ParameterExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<ParameterExportRow> {
+
+ public ParameterExportModel(char separator, DecoratorService decoratorService) {
+ super(separator);
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+
+ newColumnForExport("Code_PMFM", ParameterExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
+ newColumnForExportByDecorator("Libelle_PMFm", ParameterExportRow.PROPERTY_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
+ newColumnForExport("Valeur", ParameterExportRow.PROPERTY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ }
+
+ public void prepareRows(List<ParameterExportRow> rows,
+ Cruise cruise,
+ FishingOperation operation) {
+
+ CaracteristicMap gearUseFeatures = operation.getGearUseFeatures();
+ if (gearUseFeatures != null) {
+ for (Map.Entry<Caracteristic, Serializable> entry : gearUseFeatures.entrySet()) {
+ Caracteristic caracteristic = entry.getKey();
+
+ ParameterExportRow row = new ParameterExportRow();
+ row.setCruise(cruise);
+ row.setFishingOperation(operation);
+ row.setCaracteristic(caracteristic);
+ row.setValue(entry.getValue());
+ rows.add(row);
+ }
+ }
+ CaracteristicMap vesselUseFeatures = operation.getVesselUseFeatures();
+ if (vesselUseFeatures != null) {
+ for (Map.Entry<Caracteristic, Serializable> entry : vesselUseFeatures.entrySet()) {
+ Caracteristic caracteristic = entry.getKey();
+
+ ParameterExportRow row = new ParameterExportRow();
+ row.setCruise(cruise);
+ row.setFishingOperation(operation);
+ row.setCaracteristic(caracteristic);
+ row.setValue(entry.getValue());
+ rows.add(row);
+ }
+ }
+ }
+
+}
\ No newline at end of file
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ParameterExportRow.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ParameterExportRow.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ParameterExportRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/ParameterExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,105 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * A row in a parameter export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class ParameterExportRow implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CARACTERISTIC = "caracteristic";
+
+ public static final String PROPERTY_VALUE = "value";
+
+
+ protected Cruise cruise;
+
+ protected FishingOperation fishingOperation;
+
+ protected Caracteristic caracteristic;
+
+ private Serializable value;
+
+ public void setCruise(Cruise cruise) {
+ this.cruise = cruise;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public void setCaracteristic(Caracteristic caracteristic) {
+ this.caracteristic = caracteristic;
+ }
+
+ public void setValue(Serializable value) {
+ this.value = value;
+ }
+
+ public Date getBeginDate() {
+ return cruise.getBeginDate();
+ }
+
+ public Program getProgram() {
+ return cruise.getProgram();
+ }
+
+ public String getSurveyPart() {
+ return cruise.getSurveyPart();
+ }
+
+ public String getStationNumber() {
+ return fishingOperation.getStationNumber();
+ }
+
+ public Integer getFishingOperationNumber() {
+ return fishingOperation.getFishingOperationNumber();
+ }
+
+ public String getMultirigAggregation() {
+ return fishingOperation.getMultirigAggregation();
+ }
+
+ public Caracteristic getCaracteristic() {
+ return caracteristic;
+ }
+
+ public Serializable getValue() {
+ return value;
+ }
+}
\ No newline at end of file
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SpeciesExportModel.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SpeciesExportModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SpeciesExportModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SpeciesExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,77 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+
+import java.util.List;
+
+/**
+ * To export a species used in data to export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.3
+ */
+public class SpeciesExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<SpeciesExportRow> {
+
+ public SpeciesExportModel(char separator) {
+ super(separator);
+ newColumnForExport("Id", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("Code_Rubin", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_REF_TAX_CODE);
+ newColumnForExport("Nom Scientifique", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_NAME);
+ newColumnForExport("Code campagne", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_SURVEY_CODE);
+ }
+
+ public void prepareBatchRows(TuttiExportService.ExportContext exportContext,
+ BatchContainer<SpeciesBatch> rootSpeciesBatch,
+ BatchContainer<BenthosBatch> rootBenthosBatch) {
+
+ for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) {
+
+ exportContext.addSpecies(speciesBatch.getSpecies());
+ }
+ for (BenthosBatch benthosBatch : rootBenthosBatch.getChildren()) {
+ exportContext.addSpecies(benthosBatch.getSpecies());
+ }
+ }
+
+ public void prepareIndividualRows(TuttiExportService.ExportContext exportContext,
+ List<IndividualObservationExportRow> rows) {
+ for (IndividualObservationExportRow row : rows) {
+ exportContext.addSpecies(row.getSpecies());
+ }
+ }
+
+ public void prepareAccidentalRows(TuttiExportService.ExportContext exportContext,
+ List<AccidentalCatchExportRow> rows) {
+ for (AccidentalCatchExportRow row : rows) {
+ exportContext.addSpecies(row.getSpecies());
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SpeciesExportRow.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SpeciesExportRow.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SpeciesExportRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SpeciesExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,52 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.referential.Species;
+
+import java.io.Serializable;
+
+/**
+ * A species in a export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.3
+ */
+public class SpeciesExportRow implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String SPECIES = "species";
+
+ protected Species species;
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(Species species) {
+ this.species = species;
+ }
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SurveyExportModel.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SurveyExportModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SurveyExportModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SurveyExportModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,72 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+
+import java.util.List;
+
+/**
+ * Model of a survey export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class SurveyExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<SurveyExportRow> {
+
+ public SurveyExportModel(char separator) {
+ super(separator);
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
+ newColumnForExport("Pays", SurveyExportRow.PROPERTY_COUNTRY);
+ newColumnForExport("Zone_Etude", Program.PROPERTY_ZONE, TuttiLocation.PROPERTY_NAME);
+ newColumnForExport("Campagne", Cruise.PROPERTY_NAME);
+ newColumnForExport("Id_Sismer", SurveyExportRow.PROPERTY_ID_SISMER);
+// newColumnForExport("Nombre_de_poche", Cruise.PROPERTY_MULTIRIG_NUMBER, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("Date_Deb_Campagne", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newColumnForExport("Port_Deb_Campagne", Cruise.PROPERTY_DEPARTURE_LOCATION, TuttiLocation.PROPERTY_NAME);
+ newColumnForExport("Date_Fin_Campagne", Cruise.PROPERTY_END_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newColumnForExport("Port_Fin_Campagne", Cruise.PROPERTY_RETURN_LOCATION, TuttiLocation.PROPERTY_NAME);
+// newColumnForExport("Engin", Cruise.PROPERTY_GEAR, TuttiCsvUtil.LIST_GEAR_FORMATTER);
+ newColumnForExport("Chef_Mission", Cruise.PROPERTY_HEAD_OF_MISSION, TuttiCsvUtil.LIST_PERSON_FORMATTER);
+ newColumnForExport("Resp_Salle_Tri", Cruise.PROPERTY_HEAD_OF_SORT_ROOM, TuttiCsvUtil.LIST_PERSON_FORMATTER);
+ newColumnForExport("Commentaire", Cruise.PROPERTY_COMMENT);
+ }
+
+ public void prepareRows(List<SurveyExportRow> rows,
+ Cruise cruise,
+ TuttiLocation country) {
+ SurveyExportRow row = new SurveyExportRow();
+ row.setCruise(cruise);
+ row.setCountry(country);
+ rows.add(row);
+ }
+}
\ No newline at end of file
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SurveyExportRow.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/SurveyExportRow.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SurveyExportRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/SurveyExportRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,128 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrder;
+import fr.ifremer.tutti.persistence.entities.referential.Person;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * A row in a survey export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class SurveyExportRow implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_COUNTRY = "country";
+
+ public static final String PROPERTY_ID_SISMER = "idSismer";
+
+ protected Cruise cruise;
+
+ protected TuttiLocation country;
+
+ public void setCruise(Cruise cruise) {
+ this.cruise = cruise;
+ }
+
+ public void setCountry(TuttiLocation country) {
+ this.country = country;
+ }
+
+ public Date getBeginDate() {
+ return cruise.getBeginDate();
+ }
+
+ public Program getProgram() {
+ return cruise.getProgram();
+ }
+
+ public String getSurveyPart() {
+ return cruise.getSurveyPart();
+ }
+
+ public TuttiLocation getZone() {
+ return cruise.getProgram().getZone();
+ }
+
+ public Vessel getVessel() {
+ return cruise.getVessel();
+ }
+
+ public String getCountry() {
+ return country.getLabel();
+ }
+
+ public String getName() {
+ return cruise.getName();
+ }
+
+ public List<GearWithOriginalRankOrder> getGear() {
+ return cruise.getGear();
+ }
+
+ public TuttiLocation getDepartureLocation() {
+ return cruise.getDepartureLocation();
+ }
+
+ public Date getEndDate() {
+ return cruise.getEndDate();
+ }
+
+ public TuttiLocation getReturnLocation() {
+ return cruise.getReturnLocation();
+ }
+
+ public String getComment() {
+ return cruise.getComment();
+ }
+
+ public List<Person> getHeadOfMission() {
+ return cruise.getHeadOfMission();
+ }
+
+ public List<Person> getHeadOfSortRoom() {
+ return cruise.getHeadOfSortRoom();
+ }
+
+ public Integer getMultirigNumber() {
+ return cruise.getMultirigNumber();
+ }
+
+ // see http://forge.codelutin.com/issues/2877
+ public String getIdSismer() {
+ return "";
+ }
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,953 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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 com.google.common.base.Charsets;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.io.Files;
+import fr.ifremer.tutti.TuttiBusinessException;
+import fr.ifremer.tutti.TuttiIOUtil;
+import fr.ifremer.tutti.TuttiTechnicalException;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Gears;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import fr.ifremer.tutti.service.AbstractTuttiService;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import fr.ifremer.tutti.service.catches.WeightComputingService;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.decorator.Decorator;
+
+import java.io.BufferedWriter;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export data in the generic format.
+ * <p/>
+ * See http://forge.codelutin.com/issues/1875.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class TuttiExportService extends AbstractTuttiService {
+
+ private static final Log log =
+ LogFactory.getLog(TuttiExportService.class);
+
+ protected PersistenceService persistenceService;
+
+ protected DecoratorService decoratorService;
+
+ protected WeightComputingService weightComputingService;
+
+ protected char csvSeparator;
+
+ protected Caracteristic verticalOpeningCaracteristic;
+
+ protected Caracteristic horizontalOpeningWingCaracteristic;
+
+ protected Caracteristic horizontalOpeningDoorCaracteristic;
+
+ protected TuttiLocation country;
+
+ protected SampleCategoryModel sampleCategoryModel;
+
+ protected Caracteristic deadOrAliveCaracteristic;
+
+ protected Caracteristic genderCaracteristic;
+
+ protected Caracteristic weightMeasuredCaracteristic;
+
+ protected Caracteristic pmfmIdCaracteristic;
+
+ @Override
+ public void setServiceContext(TuttiServiceContext context) {
+ super.setServiceContext(context);
+ persistenceService = getService(PersistenceService.class);
+ decoratorService = getService(DecoratorService.class);
+ weightComputingService = getService(WeightComputingService.class);
+
+ sampleCategoryModel = context.getSampleCategoryModel();
+
+ csvSeparator = context.getConfig().getCsvSeparator();
+ verticalOpeningCaracteristic = persistenceService.getVerticalOpeningCaracteristic();
+ horizontalOpeningWingCaracteristic = persistenceService.getHorizontalOpeningWingCaracteristic();
+ horizontalOpeningDoorCaracteristic = persistenceService.getHorizontalOpeningDoorCaracteristic();
+ weightMeasuredCaracteristic = persistenceService.getWeightMeasuredCaracteristic();
+ pmfmIdCaracteristic = persistenceService.getPmfmIdCaracteristic();
+ deadOrAliveCaracteristic = persistenceService.getDeadOrAliveCaracteristic();
+ genderCaracteristic = persistenceService.getSexCaracteristic();
+
+ List<TuttiLocation> allCountry = persistenceService.getAllCountry();
+ String countryId = context.getConfig().getExportCountryId();
+ country = TuttiEntities.splitById(allCountry).get(countryId);
+ }
+
+ public void exportProgram(String programId,
+ File exportFile,
+ ProgressionModel progressionModel) {
+ Preconditions.checkNotNull(programId);
+ Preconditions.checkNotNull(exportFile);
+
+ Program program = persistenceService.getProgram(programId);
+ Preconditions.checkNotNull(program);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will export program: " + programId);
+ }
+ List<Cruise> allCruise = persistenceService.getAllCruise(programId);
+
+ File basedir = new File(context.getConfig().newTempFile(
+ "exportProgram"), "exportProgram-" + programId);
+
+ TuttiIOUtil.forceMkdir(basedir, _("tutti.service.mkDir.error", basedir));
+
+ ExportContext exportContext = createExportContext(basedir);
+
+ try {
+ for (Cruise cruise : allCruise) {
+ // load full cruise
+ cruise = persistenceService.getCruise(cruise.getId());
+ exportCruise(cruise, exportContext, progressionModel);
+ }
+ TuttiIOUtil.close(exportContext, _("tutti.service.export.closeContext.error"));
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.buildZip", exportFile));
+
+ TuttiIOUtil.zip(basedir, exportFile, _("tutti.service.export.zip.error", exportFile));
+ progressionModel.increments(1);
+ } finally {
+ IOUtils.closeQuietly(exportContext);
+ }
+ }
+
+ public void exportCruise(String cruiseId,
+ File exportFile,
+ ProgressionModel progressionModel) {
+
+ Preconditions.checkNotNull(cruiseId);
+ Preconditions.checkNotNull(exportFile);
+
+ Cruise cruise = persistenceService.getCruise(cruiseId);
+ Preconditions.checkNotNull(cruise);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will export cruise: " + cruiseId);
+ }
+
+ // check cruise fishing operations
+ TuttiBusinessException checkError = null;
+ try {
+ checkCruise(progressionModel, cruise);
+ } catch (TuttiBusinessException e) {
+ // error while checking cruise
+ if (log.isDebugEnabled()) {
+ log.debug("Got a check cruise error", e);
+ }
+ checkError = e;
+ }
+
+ File basedir = new File(context.getConfig().newTempFile(
+ "exportCruise"), "exportCruise-" + cruiseId);
+
+ TuttiIOUtil.forceMkdir(basedir, _("tutti.service.mkDir.error", basedir));
+
+ ExportContext exportContext = createExportContext(basedir);
+
+ try {
+ exportCruise(cruise, exportContext, progressionModel);
+ TuttiIOUtil.close(exportContext, _("tutti.service.export.closeContext.error"));
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.buildZip", exportFile));
+
+ TuttiIOUtil.zip(basedir, exportFile, _("tutti.service.export.zip.error", exportFile));
+ progressionModel.increments(1);
+ } finally {
+ IOUtils.closeQuietly(exportContext);
+ }
+
+ if (checkError != null) {
+ // rethrow error
+ throw checkError;
+ }
+ }
+
+ protected ExportContext createExportContext(File basedir) {
+
+
+ List<Species> allReferentSpecies = persistenceService.getAllReferentSpecies();
+ Map<String, Species> speciesById = TuttiEntities.splitById(allReferentSpecies);
+
+ return new ExportContext(
+ basedir,
+ csvSeparator,
+ decoratorService,
+ verticalOpeningCaracteristic,
+ horizontalOpeningWingCaracteristic,
+ horizontalOpeningDoorCaracteristic,
+ weightMeasuredCaracteristic,
+ deadOrAliveCaracteristic,
+ genderCaracteristic,
+ pmfmIdCaracteristic,
+ sampleCategoryModel,
+ speciesById);
+ }
+
+ protected void checkCruise(ProgressionModel progressionModel, Cruise cruise) {
+ Preconditions.checkNotNull(cruise);
+
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.checkCruise", cruise.getName()));
+
+ // check cruise fishing operations
+ Map<String, String> errors =
+ weightComputingService.checkCruise(cruise.getId());
+
+ progressionModel.increments(1);
+
+ if (MapUtils.isNotEmpty(errors)) {
+
+ // there is some fishing operations with some errors
+
+ Decorator<Cruise> cruiseDecorator =
+ decoratorService.getDecoratorByType(Cruise.class);
+
+ Decorator<FishingOperation> fishingOperationDecorator =
+ decoratorService.getDecoratorByType(FishingOperation.class);
+ StringBuilder sb = new StringBuilder();
+ for (Map.Entry<String, String> entry : errors.entrySet()) {
+ String fishingOperationId = entry.getKey();
+ FishingOperation fishingOperation = persistenceService.getFishingOperation(fishingOperationId);
+ String fishingOperationStr = fishingOperationDecorator.toString(fishingOperation);
+ sb.append(_("tutti.service.export.invalid.fishingOperation", fishingOperationStr, entry.getValue()));
+ }
+ String cruiseStr = cruiseDecorator.toString(cruise);
+ throw new TuttiBusinessException(
+ _("tutti.service.export.invalid.cruise", cruiseStr, sb.toString()));
+ }
+ }
+
+ protected void exportCruise(Cruise cruise,
+ ExportContext exportContext,
+ ProgressionModel progressionModel) {
+
+ List<FishingOperation> operations =
+ persistenceService.getAllFishingOperation(cruise.getId());
+
+ // load fully operations
+ List<FishingOperation> loadedOperations =
+ Lists.newArrayListWithCapacity(operations.size());
+ for (FishingOperation operation : operations) {
+ FishingOperation loadedOeration =
+ persistenceService.getFishingOperation(operation.getId());
+ loadedOperations.add(loadedOeration);
+ }
+
+ String cruiseName = cruise.getName();
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.exportSurvey", cruiseName));
+ exportSurvey(exportContext, cruise);
+ progressionModel.increments(1);
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.exportGearCaracteristics", cruiseName));
+ exportGearCaracteristics(exportContext, cruise);
+ progressionModel.increments(1);
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.exportOperations", cruiseName));
+ exportOperations(exportContext, cruise, loadedOperations);
+ progressionModel.increments(1);
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.exportParameters", cruiseName));
+ exportParameters(exportContext, cruise, loadedOperations);
+ progressionModel.increments(1);
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.exportMarineLitters", cruiseName));
+ exportMarineLitters(exportContext, cruise, loadedOperations);
+ progressionModel.increments(1);
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.exportIndividualObservations", cruiseName));
+ exportIndividualObservations(exportContext, cruise, loadedOperations);
+ progressionModel.increments(1);
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.exportAccidentalCatches", cruiseName));
+ exportAccidentalCatch(exportContext, cruise, loadedOperations);
+ progressionModel.increments(1);
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.exportCatches", cruiseName));
+ exportCatches(exportContext, cruise, loadedOperations);
+ progressionModel.increments(1);
+
+ progressionModel.setMessage(
+ _("tutti.service.exportCruise.exportSpecies", cruiseName));
+
+ exportSpecies(exportContext, exportContext.getSpeciesToExport());
+ progressionModel.increments(1);
+ }
+
+ protected void exportSurvey(ExportContext exportContext,
+ Cruise cruise) {
+ try {
+
+ List<SurveyExportRow> rows = Lists.newArrayList();
+ exportContext.surveyModel.prepareRows(rows, cruise, country);
+ exportContext.surveyExport.write(rows, exportContext.surveyWriter);
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(_("tutti.service.export.survey.error"), e);
+ }
+ }
+
+ protected void exportGearCaracteristics(ExportContext exportContext,
+ Cruise cruise) {
+ try {
+
+ List<GearCaracteristicExportRow> rows = Lists.newArrayList();
+
+ for (Gear gear : cruise.getGear()) {
+
+ CaracteristicMap caracteristics =
+ persistenceService.getGearCaracteristics(
+ cruise.getId(),
+ gear.getId(),
+ gear.getRankOrder());
+
+ Gear gearWithCaracteristics = Gears.newGear(gear);
+ gearWithCaracteristics.setCaracteristics(caracteristics);
+ exportContext.gearCaracteristicsModel.prepareRows(rows, cruise, gearWithCaracteristics);
+ }
+
+ exportContext.gearCaracteristicsExport.write(rows, exportContext.gearCaracteristicsWriter);
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(_("tutti.service.export.survey.error"), e);
+ }
+ }
+
+ protected void exportOperations(ExportContext exportContext,
+ Cruise cruise,
+ List<FishingOperation> operations) {
+
+ try {
+
+ List<OperationExportRow> rows = Lists.newArrayList();
+
+ for (FishingOperation operation : operations) {
+
+ OperationContext operationContext = getOperationContext(operation);
+ CatchBatch catchBatch = operationContext.getCatchBatch();
+ exportContext.operationModel.prepareRows(rows,
+ cruise,
+ operation,
+ catchBatch);
+ }
+
+ exportContext.operationExport.write(rows, exportContext.operationWriter);
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(_("tutti.service.export.operations.error"), e);
+ }
+ }
+
+ protected void exportParameters(ExportContext exportContext,
+ Cruise cruise,
+ List<FishingOperation> operations) {
+
+ try {
+
+ for (FishingOperation operation : operations) {
+ List<ParameterExportRow> rows = Lists.newArrayList();
+ exportContext.parameterModel.prepareRows(rows, cruise, operation);
+ exportContext.parameterExport.write(rows, exportContext.parameterWriter);
+ }
+
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(_("tutti.service.export.parameters.error"), e);
+ }
+ }
+
+ protected void exportMarineLitters(ExportContext exportContext,
+ Cruise cruise,
+ List<FishingOperation> operations) {
+
+ try {
+
+ for (FishingOperation operation : operations) {
+ OperationContext operationContext = getOperationContext(operation);
+
+ boolean withCatchBatch = operationContext.isWithCatchBatch();
+ if (!withCatchBatch) {
+ continue;
+ }
+ List<MarineLitterExportRow> rows = Lists.newArrayList();
+ exportContext.marineLitterModel.prepareRows(persistenceService, rows, cruise, operation);
+ exportContext.marineLitterExport.write(rows, exportContext.marineLitterWriter);
+ }
+
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(_("tutti.service.export.parameters.error"), e);
+ }
+ }
+
+ protected void exportIndividualObservations(ExportContext exportContext,
+ Cruise cruise,
+ List<FishingOperation> operations) {
+
+ try {
+
+ for (FishingOperation operation : operations) {
+ OperationContext operationContext = getOperationContext(operation);
+
+ boolean withCatchBatch = operationContext.isWithCatchBatch();
+ if (!withCatchBatch) {
+ continue;
+ }
+ List<IndividualObservationExportRow> rows = Lists.newArrayList();
+ exportContext.individualObservationModel.prepareRows(persistenceService, rows, cruise, operation);
+ exportContext.speciesModel.prepareIndividualRows(
+ exportContext,
+ rows);
+ exportContext.individualObservationExport.write(rows, exportContext.individualObservationWriter);
+ }
+
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(_("tutti.service.export.parameters.error"), e);
+ }
+ }
+
+ protected void exportAccidentalCatch(ExportContext exportContext,
+ Cruise cruise,
+ List<FishingOperation> operations) {
+ try {
+
+ for (FishingOperation operation : operations) {
+ List<AccidentalCatchExportRow> rows = Lists.newArrayList();
+ exportContext.accidentalCatchModel.prepareRows(persistenceService, rows, cruise, operation);
+ exportContext.speciesModel.prepareAccidentalRows(
+ exportContext,
+ rows);
+ exportContext.accidentalCatchExport.write(rows, exportContext.accidentalCatchWriter);
+ }
+
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(_("tutti.service.export.parameters.error"), e);
+ }
+ }
+
+ protected void exportCatches(ExportContext exportContext,
+ Cruise cruise,
+ List<FishingOperation> operations) {
+ try {
+
+ for (FishingOperation operation : operations) {
+
+ OperationContext operationContext = getOperationContext(operation);
+
+ boolean withCatchBatch = operationContext.isWithCatchBatch();
+ if (!withCatchBatch) {
+ continue;
+ }
+
+ CatchBatch catchBatch = operationContext.getCatchBatch();
+
+ BatchContainer<SpeciesBatch> rootSpeciesBatch =
+ operationContext.getRootSpeciesBatch();
+
+ BatchContainer<BenthosBatch> rootBenthosBatch =
+ operationContext.getRootBenthosBatch();
+
+ exportContext.speciesModel.prepareBatchRows(
+ exportContext,
+ rootSpeciesBatch,
+ rootBenthosBatch);
+
+ Float totalWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getCatchTotalWeight(),
+ catchBatch.getCatchTotalComputedWeight());
+
+ Float totalUnsortedWeight =
+ catchBatch.getCatchTotalUnsortedComputedWeight();
+
+
+ Float totalSortedSpeciesWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalSortedWeight(),
+ catchBatch.getSpeciesTotalSortedComputedWeight());
+
+ Float totalSampleSortedSpeciesWeight =
+ catchBatch.getSpeciesTotalSampleSortedComputedWeight();
+
+ Float totalSortedBenthosWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalSortedWeight(),
+ catchBatch.getBenthosTotalSortedComputedWeight());
+
+ Float totalSampleSortedBenthosWeight =
+ catchBatch.getBenthosTotalSampleSortedComputedWeight();
+
+ Float totalSortedWeight = catchBatch.getCatchTotalSortedComputedWeight();
+
+ //FIXME tchemit 2013-07-12 J'utilise en fait la formule (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée)
+ // (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée - poids du HV dans la capture totale)
+
+ Float catchRaisingFactor = totalWeight == null || totalUnsortedWeight == null || totalSortedWeight == null ? 1 : (totalWeight - totalUnsortedWeight) / totalSortedWeight;
+
+ Float speciesCatchRaisingFactor = totalSampleSortedSpeciesWeight == null || totalSortedSpeciesWeight == null || totalSampleSortedSpeciesWeight == null ? 1 : (totalSampleSortedSpeciesWeight == 0 ? 0 : (totalSortedSpeciesWeight / totalSampleSortedSpeciesWeight) * catchRaisingFactor);
+ Float benthosCatchRaisingFactor = totalSampleSortedBenthosWeight == null || totalSortedBenthosWeight == null || totalSampleSortedBenthosWeight == null ? 1 : (totalSampleSortedBenthosWeight == 0 ? 0 : (totalSortedBenthosWeight / totalSampleSortedBenthosWeight) * catchRaisingFactor);
+
+ if (log.isDebugEnabled()) {
+ String message = "\ncatchTotalWeight : " + totalWeight +
+ "\ncatchTotalUnsortedWeight : " + totalUnsortedWeight +
+ "\ntotalSampleSortedSpeciesWeight : " + totalSampleSortedSpeciesWeight +
+ "\ntotalSampleSortedBenthosWeight : " + totalSampleSortedBenthosWeight +
+ "\ntotalSortedWeight : " + totalSortedWeight +
+ "\ncatchRaisingFactor : " + catchRaisingFactor +
+ "\nspeciesCatchRaisingFactor : " + speciesCatchRaisingFactor +
+ "\nbenthosCatchRaisingFactor : " + benthosCatchRaisingFactor;
+
+ log.debug(message);
+ }
+
+ List<CatchExportRow> rows = Lists.newArrayList();
+ exportContext.catchModel.prepareRows(persistenceService,
+ rows,
+ cruise,
+ operation,
+ rootSpeciesBatch,
+ rootBenthosBatch,
+ speciesCatchRaisingFactor,
+ benthosCatchRaisingFactor);
+
+ exportContext.catchExport.write(rows, exportContext.catchWriter);
+ }
+
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(
+ _("tutti.service.export.catches.error"), e);
+ }
+ }
+
+ protected void exportSpecies(ExportContext exportContext,
+ List<SpeciesExportRow> rows) {
+
+ try {
+
+ exportContext.speciesExport.write(rows, exportContext.speciesWriter);
+
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(
+ _("tutti.service.export.catches.error"), e);
+ }
+ }
+
+ protected static class ExportContext implements Closeable {
+
+ File surveyFile;
+
+ File gearCaracteristicsFile;
+
+ File operationFile;
+
+ File parameterFile;
+
+ File marineLitterFile;
+
+ File individualObservationFile;
+
+ File catchFile;
+
+ File accidentalCatchFile;
+
+ File speciesFile;
+
+ BufferedWriter surveyWriter;
+
+ BufferedWriter gearCaracteristicsWriter;
+
+ BufferedWriter operationWriter;
+
+ BufferedWriter parameterWriter;
+
+ BufferedWriter marineLitterWriter;
+
+ BufferedWriter catchWriter;
+
+ BufferedWriter accidentalCatchWriter;
+
+ BufferedWriter individualObservationWriter;
+
+ BufferedWriter speciesWriter;
+
+ SurveyExportModel surveyModel;
+
+ GearCaracteristicExportModel gearCaracteristicsModel;
+
+ OperationExportModel operationModel;
+
+ MarineLitterExportModel marineLitterModel;
+
+ ParameterExportModel parameterModel;
+
+ CatchExportModel catchModel;
+
+ AccidentalCatchExportModel accidentalCatchModel;
+
+ IndividualObservationExportModel individualObservationModel;
+
+ SpeciesExportModel speciesModel;
+
+ final Map<String, SpeciesExportRow> speciesToExport = Maps.newTreeMap();
+
+ TuttiCsvUtil.TuttiRepeatableExport<SurveyExportRow> surveyExport;
+
+ TuttiCsvUtil.TuttiRepeatableExport<GearCaracteristicExportRow> gearCaracteristicsExport;
+
+ TuttiCsvUtil.TuttiRepeatableExport<OperationExportRow> operationExport;
+
+ TuttiCsvUtil.TuttiRepeatableExport<MarineLitterExportRow> marineLitterExport;
+
+ TuttiCsvUtil.TuttiRepeatableExport<ParameterExportRow> parameterExport;
+
+ TuttiCsvUtil.TuttiRepeatableExport<CatchExportRow> catchExport;
+
+ TuttiCsvUtil.TuttiRepeatableExport<AccidentalCatchExportRow> accidentalCatchExport;
+
+ TuttiCsvUtil.TuttiRepeatableExport<IndividualObservationExportRow> individualObservationExport;
+
+ TuttiCsvUtil.TuttiRepeatableExport<SpeciesExportRow> speciesExport;
+
+ Map<String, Species> speciesById;
+
+ String checkError;
+
+ ExportContext(File basedir,
+ char csvSeparator,
+ DecoratorService decoratorService,
+ Caracteristic verticalOpeningCaracteristic,
+ Caracteristic horizontalOpeningWingCaracteristic,
+ Caracteristic horizontalOpeningDoorCaracteristic,
+ Caracteristic weightMeasuredCaracteristic,
+ Caracteristic deadOrAliveCaracteristic,
+ Caracteristic genderCaracteristic,
+ Caracteristic pmfmIdCaracteristic,
+ SampleCategoryModel sampleCategoryModel,
+ Map<String, Species> speciesById) {
+
+ this.speciesById = speciesById;
+ try {
+
+ surveyFile = new File(basedir, "survey.csv");
+ surveyWriter = Files.newWriter(surveyFile, Charsets.UTF_8);
+
+ gearCaracteristicsFile = new File(basedir, "gearCaracteristics.csv");
+ gearCaracteristicsWriter = Files.newWriter(gearCaracteristicsFile, Charsets.UTF_8);
+
+ operationFile = new File(basedir, "operation.csv");
+ operationWriter = Files.newWriter(operationFile, Charsets.UTF_8);
+
+ marineLitterFile = new File(basedir, "marineLitter.csv");
+ marineLitterWriter = Files.newWriter(marineLitterFile, Charsets.UTF_8);
+
+ parameterFile = new File(basedir, "parameter.csv");
+ parameterWriter = Files.newWriter(parameterFile, Charsets.UTF_8);
+
+ catchFile = new File(basedir, "catch.csv");
+ catchWriter = Files.newWriter(catchFile, Charsets.UTF_8);
+
+ accidentalCatchFile = new File(basedir, "accidentalCatch.csv");
+ accidentalCatchWriter = Files.newWriter(accidentalCatchFile, Charsets.UTF_8);
+
+ individualObservationFile = new File(basedir, "individualObservation.csv");
+ individualObservationWriter = Files.newWriter(individualObservationFile, Charsets.UTF_8);
+
+ speciesFile = new File(basedir, "species.csv");
+ speciesWriter = Files.newWriter(speciesFile, Charsets.UTF_8);
+
+ } catch (FileNotFoundException e) {
+
+ // should never happen
+ throw new TuttiTechnicalException(_("tutti.service.export.context.error"), e);
+ }
+
+ surveyModel = new SurveyExportModel(csvSeparator);
+
+ gearCaracteristicsModel = new GearCaracteristicExportModel(
+ csvSeparator, decoratorService);
+
+ operationModel =
+ new OperationExportModel(
+ csvSeparator,
+ verticalOpeningCaracteristic,
+ horizontalOpeningWingCaracteristic,
+ horizontalOpeningDoorCaracteristic,
+ decoratorService.getDecoratorByType(Vessel.class));
+
+ parameterModel = new ParameterExportModel(
+ csvSeparator, decoratorService);
+
+ marineLitterModel = new MarineLitterExportModel(csvSeparator);
+ catchModel = new CatchExportModel(csvSeparator,
+ sampleCategoryModel,
+ decoratorService);
+ accidentalCatchModel = new AccidentalCatchExportModel(
+ csvSeparator,
+ deadOrAliveCaracteristic,
+ genderCaracteristic,
+ weightMeasuredCaracteristic,
+ pmfmIdCaracteristic);
+ individualObservationModel = new IndividualObservationExportModel(
+ csvSeparator,
+ weightMeasuredCaracteristic,
+ pmfmIdCaracteristic);
+
+ speciesModel = new SpeciesExportModel(
+ csvSeparator);
+
+ surveyExport = TuttiCsvUtil.newRepeatableExport(surveyModel);
+
+ gearCaracteristicsExport = TuttiCsvUtil.newRepeatableExport(
+ gearCaracteristicsModel);
+
+ operationExport = TuttiCsvUtil.newRepeatableExport(
+ operationModel);
+
+ parameterExport = TuttiCsvUtil.newRepeatableExport(
+ parameterModel);
+
+ marineLitterExport = TuttiCsvUtil.newRepeatableExport(
+ marineLitterModel);
+
+ catchExport = TuttiCsvUtil.newRepeatableExport(catchModel);
+ accidentalCatchExport = TuttiCsvUtil.newRepeatableExport(accidentalCatchModel);
+ individualObservationExport = TuttiCsvUtil.newRepeatableExport(individualObservationModel);
+ speciesExport = TuttiCsvUtil.newRepeatableExport(speciesModel);
+ }
+
+ @Override
+ public void close() throws IOException {
+ IOUtils.closeQuietly(surveyWriter);
+ IOUtils.closeQuietly(gearCaracteristicsWriter);
+ IOUtils.closeQuietly(operationWriter);
+ IOUtils.closeQuietly(parameterWriter);
+ IOUtils.closeQuietly(catchWriter);
+ IOUtils.closeQuietly(accidentalCatchWriter);
+ IOUtils.closeQuietly(marineLitterWriter);
+ IOUtils.closeQuietly(individualObservationWriter);
+ IOUtils.closeQuietly(speciesWriter);
+ }
+
+ public String getCheckError() {
+ return checkError;
+ }
+
+ public void setCheckError(String checkError) {
+ this.checkError = checkError;
+ }
+
+ public void addSpecies(Species species) {
+ String speciesId = species.getId();
+ if (!speciesToExport.containsKey(speciesId)) {
+
+ // not treated species, add a new row
+ Species fullSpecies = speciesById.get(speciesId);
+ SpeciesExportRow row = new SpeciesExportRow();
+ row.setSpecies(fullSpecies);
+ speciesToExport.put(speciesId, row);
+ }
+ }
+
+ public List<SpeciesExportRow> getSpeciesToExport() {
+ List<SpeciesExportRow> result =
+ Lists.newArrayList(speciesToExport.values());
+
+ Collections.sort(result, new Comparator<SpeciesExportRow>() {
+ @Override
+ public int compare(SpeciesExportRow o1, SpeciesExportRow o2) {
+ return o1.getSpecies().getReferenceTaxonId().compareTo(o2.getSpecies().getReferenceTaxonId());
+ }
+ });
+ return result;
+ }
+ }
+
+ protected static class OperationContext {
+
+ protected final FishingOperation operation;
+
+ private final CatchBatch catchBatch;
+
+ private BatchContainer<MarineLitterBatch> rootMarineLitterBatch;
+
+ private BatchContainer<SpeciesBatch> rootSpeciesBatch;
+
+ private BatchContainer<BenthosBatch> rootBenthosBatch;
+
+
+ protected boolean withCatchBatch;
+
+ public OperationContext(FishingOperation operation,
+ PersistenceService persistenceService,
+ WeightComputingService weightComputingService) {
+ this.operation = operation;
+
+ String operationId = operation.getId();
+
+ withCatchBatch =
+ persistenceService.isFishingOperationWithCatchBatch(
+ operationId);
+
+ if (withCatchBatch) {
+
+
+ // load batches
+
+ catchBatch =
+ persistenceService.getCatchBatchFromFishingOperation(
+ operationId);
+
+ boolean withError = false;
+
+ try {
+ rootSpeciesBatch = weightComputingService.getComputedSpeciesBatches(operationId);
+ } catch (Exception e) {
+ withError = true;
+ rootSpeciesBatch =
+ persistenceService.getRootSpeciesBatch(operationId, null);
+ }
+
+ try {
+ rootBenthosBatch =
+ weightComputingService.getComputedBenthosBatches(operationId);
+ } catch (Exception e) {
+ withError = true;
+ rootBenthosBatch =
+ persistenceService.getRootBenthosBatch(operationId, null);
+ }
+
+ try {
+ rootMarineLitterBatch =
+ weightComputingService.getComputedMarineLitterBatches(operationId, catchBatch.getMarineLitterTotalWeight());
+ } catch (Exception e) {
+ withError = true;
+ rootMarineLitterBatch =
+ persistenceService.getRootMarineLitterBatch(operationId);
+ }
+
+ // apply compute weights
+
+ if (!withError) {
+ weightComputingService.computeCatchBatchWeights(
+ catchBatch,
+ rootSpeciesBatch,
+ rootBenthosBatch,
+ rootMarineLitterBatch);
+ }
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("Skip fishing operation " + operationId +
+ " since no catchBatch associated.");
+ }
+ catchBatch = null;
+ rootSpeciesBatch = null;
+ rootBenthosBatch = null;
+ rootMarineLitterBatch = null;
+ }
+
+ }
+
+ public CatchBatch getCatchBatch() {
+ return catchBatch;
+ }
+
+ public BatchContainer<MarineLitterBatch> getRootMarineLitterBatch() {
+ return rootMarineLitterBatch;
+ }
+
+ public BatchContainer<SpeciesBatch> getRootSpeciesBatch() {
+ return rootSpeciesBatch;
+ }
+
+ public BatchContainer<BenthosBatch> getRootBenthosBatch() {
+ return rootBenthosBatch;
+ }
+
+ public boolean isWithCatchBatch() {
+ return withCatchBatch;
+ }
+ }
+
+ protected Map<String, OperationContext> operationContexts = Maps.newTreeMap();
+
+ protected OperationContext getOperationContext(FishingOperation operation) {
+ String operationId = operation.getId();
+
+ OperationContext result = operationContexts.get(operationId);
+ if (result == null) {
+
+ // create it
+ result = new OperationContext(operation,
+ persistenceService,
+ weightComputingService);
+ operationContexts.put(operationId, result);
+ }
+ return result;
+
+ }
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java (from rev 1366, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,296 @@
+package fr.ifremer.tutti.service.export.pdf;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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 com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.TuttiBusinessException;
+import fr.ifremer.tutti.TuttiTechnicalException;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.AbstractTuttiService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import fr.ifremer.tutti.service.catches.WeightComputingService;
+import fr.ifremer.tutti.service.export.ExportBatchEntry;
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.ext.beans.BeansWrapper;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xhtmlrenderer.pdf.ITextRenderer;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.0
+ */
+public class CatchesPdfExportService extends AbstractTuttiService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CatchesPdfExportService.class);
+
+ protected Configuration freemarkerConfiguration;
+
+ protected PersistenceService persistenceService;
+
+ protected WeightComputingService weightComputingService;
+
+ public CatchesPdfExportService() {
+ super();
+
+ freemarkerConfiguration = new Configuration();
+
+ // needed to overwrite "Defaults to default system encoding."
+ // fix encoding issue on some systems
+ freemarkerConfiguration.setEncoding(Locale.getDefault(), "UTF-8");
+
+ // specific template loader to get template from jars (classpath)
+ ClassTemplateLoader templateLoader = new ClassTemplateLoader(CatchesPdfExportService.class, "/ftl");
+ freemarkerConfiguration.setTemplateLoader(templateLoader);
+
+ // pour les maps dans les template (entre autre)
+ freemarkerConfiguration.setObjectWrapper(new BeansWrapper());
+ }
+
+ @Override
+ public void setServiceContext(TuttiServiceContext context) {
+ super.setServiceContext(context);
+ persistenceService = getService(PersistenceService.class);
+ weightComputingService = getService(WeightComputingService.class);
+ }
+
+ /**
+ * Generate the PDF report for the fiven cruise.
+ *
+ * @param targetFile pdf file to generate
+ * @param locale generated pdf locale
+ * @throws TuttiBusinessException
+ */
+ public void generateCruisePDFFile(File targetFile,
+ String cruiseId,
+ Locale locale) throws TuttiBusinessException {
+
+
+ List<String> allFishingOperation =
+ persistenceService.getAllFishingOperationIds(cruiseId);
+
+ List<Map<String, Object>> operations = Lists.newArrayList();
+ for (String operationId : allFishingOperation) {
+
+ prepareOperation(operationId, operations);
+
+ }
+
+ generatePdf(targetFile, locale, operations);
+ }
+
+ /**
+ * Generate the PDF report for the given fishing operation.
+ *
+ * @param targetFile pdf file to generate
+ * @param fishingOperationId id of the fishing operation to export
+ * @param locale generated pdf locale
+ * @throws TuttiBusinessException
+ * @since 2.7
+ */
+ public void generateFishingOperationPDFFile(File targetFile,
+ String fishingOperationId,
+ Locale locale) throws TuttiBusinessException {
+
+ List<Map<String, Object>> operations = Lists.newArrayList();
+
+ prepareOperation(fishingOperationId, operations);
+
+ generatePdf(targetFile, locale, operations);
+ }
+
+ protected void prepareOperation(String fishingOperationId,
+ List<Map<String, Object>> operations) {
+
+ // get operation and catch data
+ boolean withCatchBatch =
+ persistenceService.isFishingOperationWithCatchBatch(
+ fishingOperationId);
+
+ if (!withCatchBatch) {
+ if (log.isWarnEnabled()) {
+ log.warn("Skip fishing operation " + fishingOperationId +
+ " since no catchBatch associated.");
+ }
+ return;
+ }
+
+ ExportCatchContext exportContext = ExportCatchContext.newExportContext(
+ persistenceService, weightComputingService, fishingOperationId);
+
+ // create operation data model
+ Map<String, Object> op = createOperation(exportContext.getFishingOperation());
+
+ float totalWeight = exportContext.getCatchTotalWeight();
+
+ op.put("totalWeight", totalWeight);
+ op.put("totalSortedWeight", exportContext.getCatchTotalSortedWeight());
+
+ List<PdfExportBatchEntry> catchList = Lists.newArrayList();
+
+ // Species
+ if (exportContext.withSpeciesBatches()) {
+ List<ExportBatchEntry> speciesBatchEntries =
+ exportContext.getSpeciesBatchEntry(false);
+
+ for (ExportBatchEntry entry : speciesBatchEntries) {
+
+ SpeciesAbleBatch batch = entry.getBatch();
+ Species species = batch.getSpecies();
+
+ Species speciesWithVerncularCode =
+ persistenceService.getSpeciesByReferenceTaxonIdWithVernacularCode(species.getReferenceTaxonId());
+
+ PdfExportBatchEntry pdfEntry = new PdfExportBatchEntry(species.getRefTaxCode(),
+ species.getName(),
+ speciesWithVerncularCode.getVernacularCode(),
+ entry.getSortedWeight(),
+ entry.getTotalWeight(),
+ totalWeight);
+ catchList.add(pdfEntry);
+ }
+ }
+
+ // Benthos
+ if (exportContext.withBenthosBatches()) {
+
+ List<ExportBatchEntry> benthosBatchEntries =
+ exportContext.getBenthosBatchEntry(false);
+
+ float sortedWeight = 0f;
+ float benthosTotalWeight = 0f;
+
+ for (ExportBatchEntry entry : benthosBatchEntries) {
+ sortedWeight += entry.getSortedWeight();
+ benthosTotalWeight += entry.getTotalWeight();
+ }
+
+ PdfExportBatchEntry pdfEntry = new PdfExportBatchEntry(
+ _("tutti.service.operations.exportCatchesReport.specialRows.benthos.code"),
+ "",
+ _("tutti.service.operations.exportCatchesReport.specialRows.benthos.name"),
+ sortedWeight,
+ benthosTotalWeight,
+ totalWeight);
+ catchList.add(pdfEntry);
+ }
+
+ // Inert and living not itemized
+ ExportBatchEntry inertLivingNotItemizedCatch = exportContext.getInertAndLivingNotItemizedCatch();
+
+ if (inertLivingNotItemizedCatch.getSortedWeight() > 0f) {
+
+ PdfExportBatchEntry pdfExportBatchEntry =
+ new PdfExportBatchEntry(
+ _("tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.code"),
+ "",
+ _("tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.name"),
+ inertLivingNotItemizedCatch.getSortedWeight(),
+ inertLivingNotItemizedCatch.getTotalWeight(),
+ totalWeight);
+ catchList.add(pdfExportBatchEntry);
+ }
+
+ if (log.isDebugEnabled()) {
+
+ // recompute total for check
+ float computedTotalWeight = 0f;
+ float computedPercentage = 0f;
+ for (PdfExportBatchEntry entry : catchList) {
+ computedTotalWeight += entry.getTotalWeight();
+ computedPercentage += entry.getPercentage();
+ }
+ log.debug("TotalWeight: " + totalWeight);
+ log.debug("ComputedTotalWeight: " + computedTotalWeight);
+ log.debug("ComputedPercentage: " + computedPercentage);
+ }
+ op.put("catches", catchList);
+ operations.add(op);
+ }
+
+ protected void generatePdf(File targetFile, Locale locale, List<Map<String, Object>> operations) {
+
+ Map<String, Object> data = Maps.newHashMap();
+ data.put("operations", operations);
+ // generate the report
+ OutputStream os = null;
+ try {
+
+ // render freemarker template
+ Template mapTemplate = freemarkerConfiguration.getTemplate("catchesReport.ftl", locale);
+
+ Writer out = new StringWriter();
+ mapTemplate.process(data, out);
+ out.flush();
+
+ // render template output as pdf
+ os = new FileOutputStream(targetFile);
+
+ ITextRenderer renderer = new ITextRenderer();
+ renderer.setDocumentFromString(out.toString());
+ renderer.layout();
+ renderer.createPDF(os);
+
+ os.close();
+
+ } catch (Exception ex) {
+ throw new TuttiTechnicalException(_("tutti.service.operations.exportCatchesReport.error"), ex);
+ } finally {
+ IOUtils.closeQuietly(os);
+ }
+ }
+
+ protected Map<String, Object> createOperation(FishingOperation fishingOperation) {
+ Map<String, Object> op = Maps.newHashMap();
+ op.put("number", fishingOperation.getFishingOperationNumber());
+ op.put("station", fishingOperation.getStationNumber());
+ op.put("rigNumber", fishingOperation.getMultirigAggregation());
+ op.put("startDate", fishingOperation.getGearShootingStartDate());
+ op.put("endDate", fishingOperation.getGearShootingEndDate());
+
+ return op;
+ }
+
+}
Added: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,337 @@
+package fr.ifremer.tutti.service.export.pdf;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.catches.WeightComputingService;
+import fr.ifremer.tutti.service.export.ExportBatchEntry;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created on 11/21/13.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since XXX
+ */
+public class ExportCatchContext {
+
+ final FishingOperation fishingOperation;
+
+ final CatchBatch catchBatch;
+
+ final BatchContainer<SpeciesBatch> rootSpeciesBatch;
+
+ final BatchContainer<BenthosBatch> rootBenthosBatch;
+
+ final BatchContainer<MarineLitterBatch> marineLitterBatches;
+
+ final Predicate<SpeciesAbleBatch> vracPredicate;
+
+ public static ExportCatchContext newExportContext(PersistenceService persistenceService,
+ WeightComputingService weightComputingService,
+ String fishingOperationId) {
+
+ FishingOperation fishingOperation =
+ persistenceService.getFishingOperation(fishingOperationId);
+
+ CatchBatch catchBatch =
+ persistenceService.getCatchBatchFromFishingOperation(fishingOperationId);
+
+ BatchContainer<SpeciesBatch> rootSpeciesBatch =
+ weightComputingService.getComputedSpeciesBatches(fishingOperationId);
+
+ BatchContainer<BenthosBatch> rootBenthosBatch =
+ weightComputingService.getComputedBenthosBatches(fishingOperationId);
+
+ BatchContainer<MarineLitterBatch> marineLitterBatches =
+ weightComputingService.getComputedMarineLitterBatches(
+ fishingOperationId,
+ catchBatch.getMarineLitterTotalWeight());
+ weightComputingService.computeCatchBatchWeights(catchBatch,
+ rootSpeciesBatch,
+ rootBenthosBatch,
+ marineLitterBatches);
+
+ Predicate<SpeciesAbleBatch> vracPredicate = persistenceService.getVracBatchPredicate();
+
+ ExportCatchContext result = new ExportCatchContext(vracPredicate,
+ fishingOperation,
+ catchBatch,
+ rootSpeciesBatch,
+ rootBenthosBatch,
+ marineLitterBatches);
+ return result;
+
+ }
+
+ private ExportCatchContext(Predicate<SpeciesAbleBatch> vracPredicate,
+ FishingOperation fishingOperation,
+ CatchBatch catchBatch,
+ BatchContainer<SpeciesBatch> rootSpeciesBatch,
+ BatchContainer<BenthosBatch> rootBenthosBatch,
+ BatchContainer<MarineLitterBatch> marineLitterBatches) {
+ this.vracPredicate = vracPredicate;
+ this.fishingOperation = fishingOperation;
+ this.catchBatch = catchBatch;
+ this.rootSpeciesBatch = rootSpeciesBatch;
+ this.rootBenthosBatch = rootBenthosBatch;
+ this.marineLitterBatches = marineLitterBatches;
+ }
+
+ public FishingOperation getFishingOperation() {
+ return fishingOperation;
+ }
+
+ public float getCatchTotalWeight() {
+ float result = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getCatchTotalWeight(),
+ catchBatch.getCatchTotalComputedWeight());
+ return result;
+ }
+
+ public float getCatchTotalSortedWeight() {
+ return catchBatch.getSpeciesTotalSampleSortedComputedWeight() +
+ catchBatch.getBenthosTotalSampleSortedComputedWeight();
+ }
+
+ public boolean withSpeciesBatches() {
+ return rootSpeciesBatch != null && !rootSpeciesBatch.isEmptyChildren();
+ }
+
+ public boolean withBenthosBatches() {
+ return rootBenthosBatch != null && !rootBenthosBatch.isEmptyChildren();
+ }
+
+ public List<ExportBatchEntry> getSpeciesBatchEntry(boolean computeNumber) {
+ List<ExportBatchEntry> catchList = Lists.newArrayList();
+
+ if (withSpeciesBatches()) {
+
+ Map<Species, ExportBatchEntry> catches = Maps.newLinkedHashMap();
+
+ // ratio total species weight / total sorted sampled species weight
+ float speciesRatio = getSpeciesElevationRate();
+
+ List<SpeciesBatch> batches = rootSpeciesBatch.getChildren();
+ for (SpeciesBatch batch : batches) {
+
+ createExportBatchCatch(
+ batch,
+ catches,
+ speciesRatio,
+ computeNumber);
+ }
+ catchList.addAll(catches.values());
+ }
+ return catchList;
+ }
+
+ public List<ExportBatchEntry> getBenthosBatchEntry(boolean computeNumber) {
+ List<ExportBatchEntry> catchList = Lists.newArrayList();
+
+ if (withBenthosBatches()) {
+
+ Map<Species, ExportBatchEntry> catches = Maps.newLinkedHashMap();
+
+ // ratio total species weight / total sorted sampled species weight
+ float speciesRatio = getBenthosElevationRate();
+
+ List<BenthosBatch> batches = rootBenthosBatch.getChildren();
+ for (BenthosBatch batch : batches) {
+
+ createExportBatchCatch(
+ batch,
+ catches,
+ speciesRatio,
+ computeNumber);
+ }
+
+ catchList.addAll(catches.values());
+ }
+ return catchList;
+ }
+
+ public ExportBatchEntry getInertAndLivingNotItemizedCatch() {
+
+ ExportBatchEntry result = new ExportBatchEntry(null);
+
+ float speciesRatio = getSpeciesElevationRate();
+ float benthosRatio = getBenthosElevationRate();
+
+ Float speciesInterWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalInertWeight(),
+ catchBatch.getSpeciesTotalInertComputedWeight());
+
+ if (speciesInterWeight != null) {
+ result.addSortedWeight(speciesInterWeight);
+ result.addTotalWeight(speciesInterWeight * speciesRatio);
+ }
+
+ Float speciesLivingNotItemizedWeigth = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
+ catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
+
+ if (speciesLivingNotItemizedWeigth != null) {
+ result.addSortedWeight(speciesLivingNotItemizedWeigth);
+ result.addTotalWeight(speciesLivingNotItemizedWeigth * speciesRatio);
+ }
+
+ Float benthosInterWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalInertWeight(),
+ catchBatch.getBenthosTotalInertComputedWeight());
+
+ if (benthosInterWeight != null) {
+ result.addSortedWeight(benthosInterWeight);
+ result.addTotalWeight(benthosInterWeight * benthosRatio);
+ }
+
+ Float benthosLivingNotItemizedWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalLivingNotItemizedWeight(),
+ catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
+
+ if (benthosLivingNotItemizedWeight != null) {
+ result.addSortedWeight(benthosLivingNotItemizedWeight);
+ result.addTotalWeight(benthosLivingNotItemizedWeight * benthosRatio);
+ }
+
+ return result;
+ }
+
+ public boolean isVracBatch(SpeciesAbleBatch batch) {
+ return vracPredicate.apply(batch);
+ }
+
+ protected float getSpeciesElevationRate() {
+
+ float globalRatio = (getCatchTotalWeight() - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight();
+
+ float speciesTotalSortedWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalSortedWeight(),
+ catchBatch.getSpeciesTotalSortedComputedWeight());
+
+ // ratio total species weight / total sorted sampled species weight
+ float result = globalRatio * speciesTotalSortedWeight;
+ if (catchBatch.getSpeciesTotalSampleSortedComputedWeight() > 0) {
+ result /= catchBatch.getSpeciesTotalSampleSortedComputedWeight();
+ }
+ return result;
+ }
+
+ protected float getBenthosElevationRate() {
+
+ float globalRatio = (getCatchTotalWeight() - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight();
+
+ float benthosTotalSortedWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalSortedWeight(),
+ catchBatch.getBenthosTotalSortedComputedWeight());
+
+ // ratio total benthos weight / total sorted sampled benthos weight
+ float result = globalRatio * benthosTotalSortedWeight;
+ if (catchBatch.getBenthosTotalSampleSortedComputedWeight() > 0) {
+ result /= catchBatch.getBenthosTotalSampleSortedComputedWeight();
+ }
+ return result;
+ }
+
+ protected void createExportBatchCatch(SpeciesAbleBatch batch,
+ Map<Species, ExportBatchEntry> catches,
+ float ratio,
+ boolean computeNumber) {
+
+ Species species = batch.getSpecies();
+
+ ExportBatchEntry ktch = catches.get(species);
+ if (ktch == null) {
+ ktch = new ExportBatchEntry(batch);
+ catches.put(species, ktch);
+ }
+
+ float sortedWeight = TuttiEntities.getValueOrComputedValue(
+ batch.getSampleCategoryWeight(),
+ batch.getSampleCategoryComputedWeight());
+
+ ktch.addSortedWeight(sortedWeight);
+
+ boolean isVracBatch = isVracBatch(batch);
+ float speciesTotalWeight = sortedWeight;
+ if (isVracBatch) {
+ speciesTotalWeight *= ratio;
+ }
+ ktch.addTotalWeight(speciesTotalWeight);
+
+ if (computeNumber) {
+ int number = Math.round(computeNumber(batch, 1.0f));
+ if (isVracBatch) {
+ number *= ratio;
+ }
+ ktch.addNumber(number);
+ }
+ }
+
+ protected float computeNumber(SpeciesAbleBatch batch, float rf) {
+ float result;
+
+ float weight = TuttiEntities.getValueOrComputedValue(
+ batch.getSampleCategoryWeight(),
+ batch.getSampleCategoryComputedWeight());
+
+ if (batch.isChildBatchsEmpty()) {
+
+ // on a leaf, get his weight
+
+ Integer number = TuttiEntities.getValueOrComputedValue(
+ batch.getNumber(),
+ batch.getComputedNumber());
+ if (number == null) {
+
+ // no count
+ number = 0;
+ }
+
+ // get the sample weight
+ Float subweight = TuttiEntities.getValueOrComputedValue(
+ batch.getWeight(),
+ batch.getComputedWeight());
+
+ if (subweight != null) {
+
+ // with sub sample, update the raising factor
+ rf *= weight / subweight;
+ }
+
+ result = number.floatValue() * rf;
+ } else {
+
+ // get total weight of all childs
+ float totalWeight = 0.f;
+ for (SpeciesAbleBatch child : batch.getChildBatchs()) {
+ totalWeight += TuttiEntities.getValueOrComputedValue(
+ child.getSampleCategoryWeight(),
+ child.getSampleCategoryComputedWeight());
+ }
+
+ result = 0f;
+
+ float rf2 = rf * weight / totalWeight;
+ // sum result of each child
+ for (SpeciesAbleBatch child : batch.getChildBatchs()) {
+
+ result += computeNumber(child, rf2);
+ }
+
+ }
+ return result;
+ }
+}
Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,53 @@
+package fr.ifremer.tutti.service.export.pdf;
+
+import fr.ifremer.tutti.service.export.ExportBatchEntry;
+
+/**
+ * To store a species or batch entry within his speices informations,
+ * his sorted weight, total weight and percentage amoong the total catch
+ * weight.
+ *
+ * @since 2.10
+ */
+public class PdfExportBatchEntry extends ExportBatchEntry {
+
+ protected final String code;
+
+ protected final String scientificName;
+
+ protected final String commonName;
+
+ protected float percentage;
+
+ public PdfExportBatchEntry(String code,
+ String scientificName,
+ String commonName,
+ float sortedWeight, float totalWeight,
+ float catchTotalWeight) {
+ super(null);
+
+ this.code = code;
+ this.scientificName = scientificName;
+ this.commonName = commonName;
+
+ addSortedWeight(sortedWeight);
+ addTotalWeight(totalWeight);
+ this.percentage = 100 * totalWeight / catchTotalWeight;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getScientificName() {
+ return scientificName;
+ }
+
+ public String getCommonName() {
+ return commonName;
+ }
+
+ public float getPercentage() {
+ return percentage;
+ }
+}
Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchRow.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRow.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,87 @@
+package fr.ifremer.tutti.service.export.sumatra;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+
+import java.io.Serializable;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.0
+ */
+public class CatchRow implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_FISHING_OPERATION = "fishingOperation";
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_WEIGHT = "weight";
+
+ public static final String PROPERTY_NUMBER = "number";
+
+ protected FishingOperation fishingOperation;
+
+ protected Species species;
+
+ protected Float weight;
+
+ protected Integer number;
+
+ public FishingOperation getFishingOperation() {
+ return fishingOperation;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(Species species) {
+ this.species = species;
+ }
+
+ public Float getWeight() {
+ return weight;
+ }
+
+ public void setWeight(Float weight) {
+ this.weight = weight;
+ }
+
+ public Integer getNumber() {
+ return number;
+ }
+
+ public void setNumber(Integer number) {
+ this.number = number;
+ }
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchRowModel.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRowModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchRowModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchRowModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,70 @@
+package fr.ifremer.tutti.service.export.sumatra;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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 com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import org.nuiton.csv.Common;
+import org.nuiton.csv.ValueFormatter;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.0
+ */
+public class CatchRowModel extends TuttiCsvUtil.AbstractTuttiImportExportModel<CatchRow> {
+
+ public CatchRowModel(char separator) {
+ super(separator);
+
+ // export definition
+
+ newColumnForExport(_("tutti.service.exportSumatra.header.station"), CatchRow.PROPERTY_FISHING_OPERATION, new ValueFormatter<FishingOperation>() {
+ @Override
+ public String format(FishingOperation o) {
+ Preconditions.checkNotNull(o, _("tutti.service.exportSumatra.error.station.null"));
+ return o.getStationNumber();
+ }
+ });
+ newColumnForExport(_("tutti.service.exportSumatra.header.species"), CatchRow.PROPERTY_SPECIES, new ValueFormatter<Species>() {
+ @Override
+ public String format(Species s) {
+ Preconditions.checkNotNull(s, _("tutti.service.exportSumatra.error.species.null"));
+ return s.getName();
+ }
+ });
+ newColumnForExport(_("tutti.service.exportSumatra.header.weight"), CatchRow.PROPERTY_WEIGHT, Common.PRIMITIVE_FLOAT);
+ newColumnForExport(_("tutti.service.exportSumatra.header.number"), CatchRow.PROPERTY_NUMBER, Common.PRIMITIVE_INTEGER);
+ }
+
+ @Override
+ public CatchRow newEmptyInstance() {
+ return new CatchRow();
+ }
+
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java (from rev 1361, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchesSumatraExportService.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,375 @@
+package fr.ifremer.tutti.service.export.sumatra;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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 com.google.common.base.Charsets;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.io.Files;
+import fr.ifremer.tutti.TuttiTechnicalException;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.service.AbstractTuttiService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import fr.ifremer.tutti.service.catches.WeightComputingService;
+import fr.ifremer.tutti.service.export.ExportBatchEntry;
+import fr.ifremer.tutti.service.export.pdf.ExportCatchContext;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.csv.Export;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.0
+ */
+public class CatchesSumatraExportService extends AbstractTuttiService {
+
+ private static final Log log =
+ LogFactory.getLog(CatchesSumatraExportService.class);
+
+ protected PersistenceService persistenceService;
+
+ protected WeightComputingService weightComputingService;
+
+ @Override
+ public void setServiceContext(TuttiServiceContext context) {
+ super.setServiceContext(context);
+ persistenceService = getService(PersistenceService.class);
+ weightComputingService = getService(WeightComputingService.class);
+ }
+
+ /**
+ * Export selected cruise with the csv sumatra format.
+ *
+ * @param file where to generate report
+ * @param cruiseId id of the cruise to export
+ * @since 2.0
+ */
+ public void exportCruiseForSumatra(File file,
+ String cruiseId) {
+
+ Preconditions.checkNotNull(cruiseId, "Cannot export a null cruise");
+ Preconditions.checkNotNull(file, "Cannot export to a null file");
+
+ if (log.isInfoEnabled()) {
+ log.info("Will export cruise " + cruiseId + " to file: " + file);
+ }
+
+ Cruise cruise = persistenceService.getCruise(cruiseId);
+ Preconditions.checkNotNull(cruise, "Cruise [" + cruiseId + "] not found");
+
+ List<String> operations =
+ persistenceService.getAllFishingOperationIds(cruiseId);
+
+ prepareOperationsAndExport(file, operations);
+ }
+
+ /**
+ * Export selected fishing operation with the csv sumatra format.
+ *
+ * @param file where to generate report
+ * @param cruiseId id of the cruise to export
+ * @param fishingOperationId id of the fishing operation to export
+ * @since 2.7
+ */
+ public void exportFishingOperationForSumatra(File file,
+ String cruiseId,
+ String fishingOperationId) {
+
+ Preconditions.checkNotNull(file, "Cannot export to a null file");
+ Preconditions.checkNotNull(cruiseId, "Cannot export a null cruise");
+ Preconditions.checkNotNull(fishingOperationId, "Cannot export a null fishing operation");
+
+ if (log.isInfoEnabled()) {
+ log.info("Will export fishing operation " +
+ fishingOperationId + " to file: " + file);
+ }
+
+ Cruise cruise = persistenceService.getCruise(cruiseId);
+ Preconditions.checkNotNull(cruise, "Cruise [" + cruiseId + "] not found");
+
+ List<String> operations = Lists.newArrayList(fishingOperationId);
+
+ prepareOperationsAndExport(file, operations);
+ }
+
+ protected void prepareOperationsAndExport(File file,
+ List<String> operations) {
+
+ List<CatchRow> rows = Lists.newArrayList();
+
+ if (operations != null) {
+ for (String operationId : operations) {
+
+ prepareFishingOperation(rows, operationId);
+ }
+ }
+
+ CatchRowModel csvModel =
+ new CatchRowModel(context.getConfig().getCsvSeparator());
+
+ BufferedWriter writer = null;
+ try {
+ writer = Files.newWriter(file, Charsets.UTF_8);
+ Export export = Export.newExport(csvModel, rows);
+ export.write(writer);
+ writer.close();
+
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(_("tutti.service.sumatra.export.error", file), e);
+ } finally {
+ IOUtils.closeQuietly(writer);
+ }
+ }
+
+ protected void prepareFishingOperation(List<CatchRow> rows, String operationId) {
+
+ ExportCatchContext exportContext = ExportCatchContext.newExportContext(
+ persistenceService, weightComputingService, operationId);
+
+ FishingOperation operation = exportContext.getFishingOperation();
+
+ // Species
+ if (exportContext.withSpeciesBatches()) {
+
+ List<ExportBatchEntry> entries =
+ exportContext.getSpeciesBatchEntry(true);
+
+ for (ExportBatchEntry entry : entries) {
+
+ CatchRow row = new CatchRow();
+ row.setFishingOperation(operation);
+ row.setSpecies(entry.getBatch().getSpecies());
+ row.setWeight(entry.getTotalWeight());
+ row.setNumber(entry.getTotalNumber());
+ rows.add(row);
+ }
+ }
+
+ // Benthos
+ if (exportContext.withBenthosBatches()) {
+
+ List<ExportBatchEntry> entries =
+ exportContext.getBenthosBatchEntry(true);
+
+ for (ExportBatchEntry entry : entries) {
+
+ CatchRow row = new CatchRow();
+ row.setFishingOperation(operation);
+ row.setSpecies(entry.getBatch().getSpecies());
+ row.setWeight(entry.getTotalWeight());
+ row.setNumber(entry.getTotalNumber());
+ rows.add(row);
+ }
+ }
+
+// FishingOperation operation = persistenceService.getFishingOperation(operationId);
+//
+// CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(
+// operationId);
+//
+// BatchContainer<SpeciesBatch> speciesBatchContainer =
+// weightComputingService.getComputedSpeciesBatches(operationId);
+// BatchContainer<BenthosBatch> benthosBatchContainer =
+// weightComputingService.getComputedBenthosBatches(operationId);
+//
+// BatchContainer<MarineLitterBatch> marineLitterBatch =
+// weightComputingService.getComputedMarineLitterBatches(
+// operationId, catchBatch.getMarineLitterTotalWeight());
+//
+// weightComputingService.computeCatchBatchWeights(catchBatch,
+// speciesBatchContainer,
+// benthosBatchContainer,
+// marineLitterBatch);
+//
+// Float totalWeight = TuttiEntities.getValueOrComputedValue(
+// catchBatch.getCatchTotalWeight(),
+// catchBatch.getCatchTotalComputedWeight());
+//
+// Float totalUnsortedWeight =
+// TuttiEntities.getValueOrComputedValue(
+// catchBatch.getCatchTotalUnsortedComputedWeight(),
+// 0f);
+//
+// Float totalSortedSpeciesWeight = TuttiEntities.getValueOrComputedValue(
+// catchBatch.getSpeciesTotalSortedWeight(),
+// catchBatch.getSpeciesTotalSortedComputedWeight());
+//
+// Float totalSampleSortedSpeciesWeight =
+// catchBatch.getSpeciesTotalSampleSortedComputedWeight();
+//
+// Float totalSortedBenthosWeight = TuttiEntities.getValueOrComputedValue(
+// catchBatch.getBenthosTotalSortedWeight(),
+// catchBatch.getBenthosTotalSortedComputedWeight());
+//
+// Float totalSampleSortedBenthosWeight =
+// catchBatch.getBenthosTotalSampleSortedComputedWeight();
+//
+// Float totalSortedWeight = catchBatch.getCatchTotalSortedComputedWeight();
+//
+// //FIXME tchemit 2013-07-12 J'utilise en fait la formule (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée)
+// // (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée - poids du HV dans la capture totale)
+//
+// Float catchRaisingFactor = totalWeight == null || totalUnsortedWeight == null || totalSortedWeight == null ? 1 : (totalWeight - totalUnsortedWeight) / totalSortedWeight;
+//
+// Float speciesCatchRaisingFactor = totalSampleSortedSpeciesWeight == null || totalSortedSpeciesWeight == null || totalSampleSortedSpeciesWeight == null ? 1 : (totalSampleSortedSpeciesWeight == 0 ? 0 : (totalSortedSpeciesWeight / totalSampleSortedSpeciesWeight) * catchRaisingFactor);
+// Float benthosCatchRaisingFactor = totalSampleSortedBenthosWeight == null || totalSortedBenthosWeight == null || totalSampleSortedBenthosWeight == null ? 1 : (totalSampleSortedBenthosWeight == 0 ? 0 : (totalSortedBenthosWeight / totalSampleSortedBenthosWeight) * catchRaisingFactor);
+//
+// speciesCatchRaisingFactor *= catchRaisingFactor;
+// benthosCatchRaisingFactor *= catchRaisingFactor;
+//
+// // add species rows
+// Map<Species, CatchRow> rowMap = Maps.newLinkedHashMap();
+// if (speciesBatchContainer != null) {
+// List<SpeciesBatch> speciesBatches = speciesBatchContainer.getChildren();
+// for (SpeciesBatch batch : speciesBatches) {
+// Species sp = batch.getSpecies();
+//
+// int number = Math.round(computeNumber(batch, 1.0f));
+//
+// Float weight = TuttiEntities.getValueOrComputedValue(
+// batch.getSampleCategoryWeight(),
+// batch.getSampleCategoryComputedWeight());
+//
+// weight *= speciesCatchRaisingFactor;
+// number = (int) (speciesCatchRaisingFactor * (float) number);
+//
+// CatchRow row = rowMap.get(sp);
+// if (row == null) {
+// row = new CatchRow();
+// row.setFishingOperation(operation);
+// row.setSpecies(sp);
+// row.setWeight(weight);
+// row.setNumber(number);
+//
+// } else {
+// row.setWeight(row.getWeight() + weight);
+// row.setNumber(row.getNumber() + number);
+// }
+// rowMap.put(sp, row);
+// }
+// rows.addAll(rowMap.values());
+// }
+//
+// // add benthos rows
+// rowMap.clear();
+// if (benthosBatchContainer != null) {
+// List<BenthosBatch> benthosBatches = benthosBatchContainer.getChildren();
+// for (BenthosBatch batch : benthosBatches) {
+// Species sp = batch.getSpecies();
+//
+// int number = Math.round(computeNumber(batch, 1.0f));
+//
+// Float weight = TuttiEntities.getValueOrComputedValue(
+// batch.getSampleCategoryWeight(),
+// batch.getSampleCategoryComputedWeight());
+//
+// weight *= benthosCatchRaisingFactor;
+// number = (int) (benthosCatchRaisingFactor * (float) number);
+//
+// CatchRow row = rowMap.get(sp);
+// if (row == null) {
+// row = new CatchRow();
+// row.setFishingOperation(operation);
+// row.setSpecies(sp);
+// row.setWeight(weight);
+// row.setNumber(number);
+//
+// } else {
+// row.setWeight(row.getWeight() + weight);
+// row.setNumber(row.getNumber() + number);
+// }
+// rowMap.put(sp, row);
+// }
+// }
+//
+// rows.addAll(rowMap.values());
+ }
+
+
+// protected float computeNumber(SpeciesAbleBatch batch, float rf) {
+// float result;
+//
+// float weight = TuttiEntities.getValueOrComputedValue(
+// batch.getSampleCategoryWeight(),
+// batch.getSampleCategoryComputedWeight());
+//
+// if (batch.isChildBatchsEmpty()) {
+//
+// // on a leaf, get his weight
+//
+// Integer number = TuttiEntities.getValueOrComputedValue(
+// batch.getNumber(),
+// batch.getComputedNumber());
+// if (number == null) {
+//
+// // no count
+// number = 0;
+// }
+//
+// // get the sample weight
+// Float subweight = TuttiEntities.getValueOrComputedValue(
+// batch.getWeight(),
+// batch.getComputedWeight());
+//
+// if (subweight != null) {
+//
+// // with sub sample, update the raising factor
+// rf *= weight / subweight;
+// }
+//
+// result = number.floatValue() * rf;
+// } else {
+//
+// // get total weight of all childs
+// float totalWeight = 0.f;
+// for (SpeciesAbleBatch child : batch.getChildBatchs()) {
+// totalWeight += TuttiEntities.getValueOrComputedValue(
+// child.getSampleCategoryWeight(),
+// child.getSampleCategoryComputedWeight());
+// }
+//
+// result = 0f;
+//
+// float rf2 = rf * weight / totalWeight;
+// // sum result of each child
+// for (SpeciesAbleBatch child : batch.getChildBatchs()) {
+//
+// result += computeNumber(child, rf2);
+// }
+//
+// }
+// return result;
+// }
+
+}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRow.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRow.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,87 +0,0 @@
-package fr.ifremer.tutti.service.sumatra;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-
-import java.io.Serializable;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.0
- */
-public class CatchRow implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_FISHING_OPERATION = "fishingOperation";
-
- public static final String PROPERTY_SPECIES = "species";
-
- public static final String PROPERTY_WEIGHT = "weight";
-
- public static final String PROPERTY_NUMBER = "number";
-
- protected FishingOperation fishingOperation;
-
- protected Species species;
-
- protected Float weight;
-
- protected Integer number;
-
- public FishingOperation getFishingOperation() {
- return fishingOperation;
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- public Species getSpecies() {
- return species;
- }
-
- public void setSpecies(Species species) {
- this.species = species;
- }
-
- public Float getWeight() {
- return weight;
- }
-
- public void setWeight(Float weight) {
- this.weight = weight;
- }
-
- public Integer getNumber() {
- return number;
- }
-
- public void setNumber(Integer number) {
- this.number = number;
- }
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRowModel.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRowModel.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,70 +0,0 @@
-package fr.ifremer.tutti.service.sumatra;
-
-/*
- * #%L
- * Tutti :: Service
- * $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 com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.csv.Common;
-import org.nuiton.csv.ValueFormatter;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.0
- */
-public class CatchRowModel extends TuttiCsvUtil.AbstractTuttiImportExportModel<CatchRow> {
-
- public CatchRowModel(char separator) {
- super(separator);
-
- // export definition
-
- newColumnForExport(_("tutti.service.exportSumatra.header.station"), CatchRow.PROPERTY_FISHING_OPERATION, new ValueFormatter<FishingOperation>() {
- @Override
- public String format(FishingOperation o) {
- Preconditions.checkNotNull(o, _("tutti.service.exportSumatra.error.station.null"));
- return o.getStationNumber();
- }
- });
- newColumnForExport(_("tutti.service.exportSumatra.header.species"), CatchRow.PROPERTY_SPECIES, new ValueFormatter<Species>() {
- @Override
- public String format(Species s) {
- Preconditions.checkNotNull(s, _("tutti.service.exportSumatra.error.species.null"));
- return s.getName();
- }
- });
- newColumnForExport(_("tutti.service.exportSumatra.header.weight"), CatchRow.PROPERTY_WEIGHT, Common.PRIMITIVE_FLOAT);
- newColumnForExport(_("tutti.service.exportSumatra.header.number"), CatchRow.PROPERTY_NUMBER, Common.PRIMITIVE_INTEGER);
- }
-
- @Override
- public CatchRow newEmptyInstance() {
- return new CatchRow();
- }
-
-}
Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchesSumatraExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchesSumatraExportService.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchesSumatraExportService.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,344 +0,0 @@
-package fr.ifremer.tutti.service.sumatra;
-
-/*
- * #%L
- * Tutti :: Service
- * $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 com.google.common.base.Charsets;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.io.Files;
-import fr.ifremer.tutti.TuttiTechnicalException;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.AbstractTuttiService;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.TuttiServiceContext;
-import fr.ifremer.tutti.service.catches.WeightComputingService;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.csv.Export;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.0
- */
-public class CatchesSumatraExportService extends AbstractTuttiService {
-
- private static final Log log =
- LogFactory.getLog(CatchesSumatraExportService.class);
-
- protected PersistenceService persistenceService;
-
- protected WeightComputingService weightComputingService;
-
- @Override
- public void setServiceContext(TuttiServiceContext context) {
- super.setServiceContext(context);
- persistenceService = getService(PersistenceService.class);
- weightComputingService = getService(WeightComputingService.class);
- }
-
- /**
- * Export selected cruise with the csv sumatra format.
- *
- * @param file where to generate report
- * @param cruiseId id of the cruise to export
- * @since 2.0
- */
- public void exportCruiseForSumatra(File file,
- String cruiseId) {
-
- Preconditions.checkNotNull(cruiseId, "Cannot export a null cruise");
- Preconditions.checkNotNull(file, "Cannot export to a null file");
-
- if (log.isInfoEnabled()) {
- log.info("Will export cruise " + cruiseId + " to file: " + file);
- }
-
- Cruise cruise = persistenceService.getCruise(cruiseId);
- Preconditions.checkNotNull(cruise, "Cruise [" + cruiseId + "] not found");
-
- List<String> operations =
- persistenceService.getAllFishingOperationIds(cruiseId);
-
- prepareOperationsAndExport(file, operations);
- }
-
- /**
- * Export selected fishing operation with the csv sumatra format.
- *
- * @param file where to generate report
- * @param cruiseId id of the cruise to export
- * @param fishingOperationId id of the fishing operation to export
- * @since 2.7
- */
- public void exportFishingOperationForSumatra(File file,
- String cruiseId,
- String fishingOperationId) {
-
- Preconditions.checkNotNull(file, "Cannot export to a null file");
- Preconditions.checkNotNull(cruiseId, "Cannot export a null cruise");
- Preconditions.checkNotNull(fishingOperationId, "Cannot export a null fishing operation");
-
- if (log.isInfoEnabled()) {
- log.info("Will export fishing operation " +
- fishingOperationId + " to file: " + file);
- }
-
- Cruise cruise = persistenceService.getCruise(cruiseId);
- Preconditions.checkNotNull(cruise, "Cruise [" + cruiseId + "] not found");
-
- List<String> operations = Lists.newArrayList(fishingOperationId);
-
- prepareOperationsAndExport(file, operations);
- }
-
- protected void prepareOperationsAndExport(File file,
- List<String> operations) {
-
- List<CatchRow> rows = Lists.newArrayList();
-
- if (operations != null) {
- for (String operationId : operations) {
-
- prepareFishingOperation(rows, operationId);
- }
- }
-
- CatchRowModel csvModel =
- new CatchRowModel(context.getConfig().getCsvSeparator());
-
- BufferedWriter writer = null;
- try {
- writer = Files.newWriter(file, Charsets.UTF_8);
- Export export = Export.newExport(csvModel, rows);
- export.write(writer);
- writer.close();
-
- } catch (Exception e) {
- throw new TuttiTechnicalException(_("tutti.service.sumatra.export.error", file), e);
- } finally {
- IOUtils.closeQuietly(writer);
- }
- }
-
- protected void prepareFishingOperation(List<CatchRow> rows, String operationId) {
-
- FishingOperation operation = persistenceService.getFishingOperation(operationId);
-
- CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(
- operationId);
-
- BatchContainer<SpeciesBatch> speciesBatchContainer =
- weightComputingService.getComputedSpeciesBatches(operationId);
- BatchContainer<BenthosBatch> benthosBatchContainer =
- weightComputingService.getComputedBenthosBatches(operationId);
-
- BatchContainer<MarineLitterBatch> marineLitterBatch =
- weightComputingService.getComputedMarineLitterBatches(
- operationId, catchBatch.getMarineLitterTotalWeight());
-
- weightComputingService.computeCatchBatchWeights(catchBatch,
- speciesBatchContainer,
- benthosBatchContainer,
- marineLitterBatch);
-
- Float totalWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getCatchTotalWeight(),
- catchBatch.getCatchTotalComputedWeight());
-
- Float totalUnsortedWeight =
- TuttiEntities.getValueOrComputedValue(
- catchBatch.getCatchTotalUnsortedComputedWeight(),
- 0f);
-
- Float totalSortedSpeciesWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getSpeciesTotalSortedWeight(),
- catchBatch.getSpeciesTotalSortedComputedWeight());
-
- Float totalSampleSortedSpeciesWeight =
- catchBatch.getSpeciesTotalSampleSortedComputedWeight();
-
- Float totalSortedBenthosWeight = TuttiEntities.getValueOrComputedValue(
- catchBatch.getBenthosTotalSortedWeight(),
- catchBatch.getBenthosTotalSortedComputedWeight());
-
- Float totalSampleSortedBenthosWeight =
- catchBatch.getBenthosTotalSampleSortedComputedWeight();
-
- Float totalSortedWeight = catchBatch.getCatchTotalSortedComputedWeight();
-
- //FIXME tchemit 2013-07-12 J'utilise en fait la formule (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée)
- // (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée - poids du HV dans la capture totale)
-
- Float catchRaisingFactor = totalWeight == null || totalUnsortedWeight == null || totalSortedWeight == null ? 1 : (totalWeight - totalUnsortedWeight) / totalSortedWeight;
-
- Float speciesCatchRaisingFactor = totalSampleSortedSpeciesWeight == null || totalSortedSpeciesWeight == null || totalSampleSortedSpeciesWeight == null ? 1 : (totalSampleSortedSpeciesWeight == 0 ? 0 : (totalSortedSpeciesWeight / totalSampleSortedSpeciesWeight) * catchRaisingFactor);
- Float benthosCatchRaisingFactor = totalSampleSortedBenthosWeight == null || totalSortedBenthosWeight == null || totalSampleSortedBenthosWeight == null ? 1 : (totalSampleSortedBenthosWeight == 0 ? 0 : (totalSortedBenthosWeight / totalSampleSortedBenthosWeight) * catchRaisingFactor);
-
- speciesCatchRaisingFactor *= catchRaisingFactor;
- benthosCatchRaisingFactor *= catchRaisingFactor;
-
- // add species rows
- Map<Species, CatchRow> rowMap = Maps.newLinkedHashMap();
- if (speciesBatchContainer != null) {
- List<SpeciesBatch> speciesBatches = speciesBatchContainer.getChildren();
- for (SpeciesBatch batch : speciesBatches) {
- Species sp = batch.getSpecies();
-
- int number = Math.round(computeNumber(batch, 1.0f));
-
- Float weight = TuttiEntities.getValueOrComputedValue(
- batch.getSampleCategoryWeight(),
- batch.getSampleCategoryComputedWeight());
-
- weight *= speciesCatchRaisingFactor;
- number = (int) (speciesCatchRaisingFactor * (float) number);
-
- CatchRow row = rowMap.get(sp);
- if (row == null) {
- row = new CatchRow();
- row.setFishingOperation(operation);
- row.setSpecies(sp);
- row.setWeight(weight);
- row.setNumber(number);
-
- } else {
- row.setWeight(row.getWeight() + weight);
- row.setNumber(row.getNumber() + number);
- }
- rowMap.put(sp, row);
- }
- rows.addAll(rowMap.values());
- }
-
- // add benthos rows
- rowMap.clear();
- if (benthosBatchContainer != null) {
- List<BenthosBatch> benthosBatches = benthosBatchContainer.getChildren();
- for (BenthosBatch batch : benthosBatches) {
- Species sp = batch.getSpecies();
-
- int number = Math.round(computeNumber(batch, 1.0f));
-
- Float weight = TuttiEntities.getValueOrComputedValue(
- batch.getSampleCategoryWeight(),
- batch.getSampleCategoryComputedWeight());
-
- weight *= benthosCatchRaisingFactor;
- number = (int) (benthosCatchRaisingFactor * (float) number);
-
- CatchRow row = rowMap.get(sp);
- if (row == null) {
- row = new CatchRow();
- row.setFishingOperation(operation);
- row.setSpecies(sp);
- row.setWeight(weight);
- row.setNumber(number);
-
- } else {
- row.setWeight(row.getWeight() + weight);
- row.setNumber(row.getNumber() + number);
- }
- rowMap.put(sp, row);
- }
- }
-
- rows.addAll(rowMap.values());
- }
-
-
- protected float computeNumber(SpeciesAbleBatch batch, float rf) {
- float result;
-
- float weight = TuttiEntities.getValueOrComputedValue(
- batch.getSampleCategoryWeight(),
- batch.getSampleCategoryComputedWeight());
-
- if (batch.isChildBatchsEmpty()) {
-
- // on a leaf, get his weight
-
- Integer number = TuttiEntities.getValueOrComputedValue(
- batch.getNumber(),
- batch.getComputedNumber());
- if (number == null) {
-
- // no count
- number = 0;
- }
-
- // get the sample weight
- Float subweight = TuttiEntities.getValueOrComputedValue(
- batch.getWeight(),
- batch.getComputedWeight());
-
- if (subweight != null) {
-
- // with sub sample, update the raising factor
- rf *= weight / subweight;
- }
-
- result = number.floatValue() * rf;
- } else {
-
- // get total weight of all childs
- float totalWeight = 0.f;
- for (SpeciesAbleBatch child : batch.getChildBatchs()) {
- totalWeight += TuttiEntities.getValueOrComputedValue(
- child.getSampleCategoryWeight(),
- child.getSampleCategoryComputedWeight());
- }
-
- result = 0f;
-
- float rf2 = rf * weight / totalWeight;
- // sum result of each child
- for (SpeciesAbleBatch child : batch.getChildBatchs()) {
-
- result += computeNumber(child, rf2);
- }
-
- }
- return result;
- }
-
-}
Deleted: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/ExportCatchesReportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/ExportCatchesReportServiceTest.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/ExportCatchesReportServiceTest.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,70 +0,0 @@
-package fr.ifremer.tutti.service.catches;
-
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.ServiceDbResource;
-import fr.ifremer.tutti.service.TuttiServiceContext;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.Locale;
-
-/**
- * Created on 11/19/13.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.10
- */
-public class ExportCatchesReportServiceTest {
-
- @ClassRule
- public static final ServiceDbResource dbResource =
- ServiceDbResource.readDb("dbMedits");
-
- public static final String PROGRAM_ID = "CAM-MEDITS";
-
- public static final String CRUISE_ID = "100001";
-
- public static final String OPERATION_1_ID = "100106";
-
- protected ExportCatchesReportService exportService;
-
- protected PersistenceService persistenceService;
-
- protected File dataDirectory;
-
- @Before
- public void setUp() throws Exception {
-
- dataDirectory = dbResource.getServiceConfig().getDataDirectory();
-
- TuttiServiceContext serviceContext = dbResource.getServiceContext();
-
- persistenceService = serviceContext.getService(PersistenceService.class);
-
- serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
- exportService = serviceContext.getService(ExportCatchesReportService.class);
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @Test
- public void generateFishingOperationPDFFile() throws Exception {
-
- File exportFile = new File(dataDirectory, "exportOperation.pdf");
-
- Assert.assertFalse(exportFile.exists());
-
- exportService.generateFishingOperationPDFFile(exportFile,
- OPERATION_1_ID,
- Locale.FRENCH);
-
- Assert.assertTrue(exportFile.exists());
- }
-}
Deleted: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,264 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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 com.google.common.io.Files;
-import fr.ifremer.tutti.TuttiBusinessException;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.ServiceDbResource;
-import fr.ifremer.tutti.service.TuttiServiceContext;
-import fr.ifremer.tutti.service.catches.WeightComputingService;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-import java.io.File;
-import java.net.URL;
-import java.util.List;
-
-/**
- * Test export of catches.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.3.2
- */
-public class TuttiExportService2Test {
-
- @ClassRule
- public static final ServiceDbResource dbResource =
- ServiceDbResource.readDb("dbExport");
-
- public static final String PROGRAM_ID = "CAM-TEST_ELEVATION";
-
- public static final String CRUISE_ID = "100003";
-
- public static final String OPERATION_1_ID = "100112";
-
- public static final String OPERATION_2_ID = "100113";
-
- public static final String OPERATION_3_ID = "100114";
-
- protected TuttiExportService service;
-
- protected ServiceDbResource.DataContext dataContext;
-
- protected File dataDirectory;
-
- @Before
- public void setUp() throws Exception {
-
- dataDirectory = dbResource.getServiceConfig().getDataDirectory();
-
- dbResource.setCountryInConfig("12");
-
- dbResource.openDataContext();
-
- TuttiServiceContext serviceContext = dbResource.getServiceContext();
-
- service = serviceContext.getService(TuttiExportService.class);
-
- }
-
- @Test
- public void exportWithErrors() throws Exception {
-
-
- TuttiServiceContext serviceContext = dbResource.getServiceContext();
-
- PersistenceService persistenceService = serviceContext.getService(PersistenceService.class);
-
- // check there is a error while compute weight for a cruise
- boolean errorDetected = false;
- WeightComputingService computingService = serviceContext.getService(WeightComputingService.class);
- List<String> allFishingOperation = persistenceService.getAllFishingOperationIds(CRUISE_ID);
- for (String fishingOperation : allFishingOperation) {
- try {
- computingService.getComputedSpeciesBatches(fishingOperation);
- } catch (Exception e) {
- errorDetected = true;
- break;
- }
- }
-
- Assert.assertTrue(errorDetected);
-
- File exportFile = new File(dataDirectory, "exportCruise.zip");
-
- Files.createParentDirs(exportFile);
-
- Assert.assertFalse(exportFile.exists());
-
- ProgressionModel progressionModel = new ProgressionModel();
- progressionModel.setTotal(9);
- try {
- service.exportCruise(CRUISE_ID, exportFile, progressionModel);
- // got an error after but export was still performed
- Assert.fail();
- } catch (TuttiBusinessException e) {
- // got an error
- Assert.assertTrue(true);
- }
- // export perform, file exist
- Assert.assertTrue(exportFile.exists());
-
- String urlPrefix = "jar:" + exportFile.toURI().toURL() + "!/exportCruise-" + CRUISE_ID + "/";
- {
- // check species file content
-
- URL url = new URL(urlPrefix + "species.csv");
- ServiceDbResource.assertFileContent("species export:\n",
- url,
- "Id;Code_Rubin;Nom Scientifique;Code campagne\n" +
- "380;ACANECH;Acanthocardia echinata;;\n" +
- "1358;ALOSALO;Alosa alosa;;\n" +
- "1938;AGONCAT;Agonus cataphractus;;\n" +
- "4622;ABIEABI;Abietinaria abietina;;\n" +
- "11183;;Brissopsis atlantica;;");
-
- }
-
- {
- // check accidentalCatch file content
-
- URL url = new URL(urlPrefix + "accidentalCatch.csv");
- ServiceDbResource.assertFileContent("accidentalCatch export:\n",
- url,
- "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue");
-
- }
-
- {
- // check operation file content
-
- URL url = new URL(urlPrefix + "operation.csv");
- ServiceDbResource.assertFileContent("operation export:\n",
- url,
- "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;NavireAssocie;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
- "2013;test elevation;1;B;2;1;OTB 20/28.10;278970;01/07/2013 00:00:00;;;01/07/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;;\"Commentaire sur le trait B-2-1\n" +
- "\n" +
- "avec\n" +
- "saut\n" +
- "de \n" +
- "ligne\";1000.0;Y;280.0;Y;20.0;Y;700.0;N;;?;;?;200.0;Y;180.0;Y;180.0;Y;20.0;Y;0.0;Y;0.0;Y;100.0;Y;100.0;N;50.0;Y;0.0;Y;2.0;N;0.0;Y;100.0;N;\n" +
- "2013;test elevation;1;A;1;1;OTB 20/28.10;278970;01/07/2013 00:00:00;;;01/07/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;;\"commentaire trait A-1-1\n" +
- "Avec \n" +
- "saut\n" +
- "de\n" +
- "ligne\n" +
- "...\";1000.0;Y;180.0;Y;20.0;Y;800.0;N;;?;;?;200.0;Y;180.0;Y;180.0;Y;20.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;\n" +
- "2013;test elevation;1;C;3;1;;278970;25/09/2013 00:00:00;;;25/09/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;;;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;");
-
- }
-
- {
- // check survey file content
-
- URL url = new URL(urlPrefix + "survey.csv");
- ServiceDbResource.assertFileContent("survey export:\n",
- url,
- "Annee;Serie;Serie_Partielle;Navire;Pays;Zone_Etude;Campagne;Id_Sismer;Date_Deb_Campagne;Port_Deb_Campagne;Date_Fin_Campagne;Port_Fin_Campagne;Chef_Mission;Resp_Salle_Tri;Commentaire\n" +
- "2013;test elevation;1;278970;FRA;CGFS - Manche Est / Sud Mer du Nord;test elevation_2013_1;;01/07/2013 00:00:00;La Barbotière (Gujan-Mestras);04/07/2013 00:00:00;La Barbotière (Gujan-Mestras);Adrian LEVREL;Alain BISEAU;;");
-
- }
-
- {
- // check individualObservation file content
-
- URL url = new URL(urlPrefix + "individualObservation.csv");
- ServiceDbResource.assertFileContent("individualObservation export:\n",
- url,
- "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue");
-
- }
-
- {
- // check catch file content
-
- URL url = new URL("jar:" + exportFile.toURI().toURL() + "!/exportCruise-" + CRUISE_ID + "/catch.csv");
- ServiceDbResource.assertFileContent("Catch export:\n",
- url,
- "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V_HV;Num_Ordre_V_HV_H2;Tot_V_HV;Ech_V_HV;Type_Volume_Poids_V_HV;Unite_Volume_Poids_V_HV;Class_Tri_;Num_Ordre_Class_Tri__H2;Tot_Class_Tri_;Ech_Class_Tri_;Type_Volume_Poids_Class_Tri_;Unite_Volume_Poids_Class_Tri_;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-vrac 80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;3.5;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;5.8333335;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Femelle 40.0;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;40.0;8.75;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-horsvrac 20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;4622;Abietinaria abietina;\"Trait B-2-1 Benthos ABIEABI Vrac 30\n" +
- "\n" +
- "avec \n" +
- "\n" +
- "commentaire...\";Vrac;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;7.0;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;380;Acanthocardia echinata;\"Trait B-2-1 Benthos ACANECH Vrac 18\n" +
- "\n" +
- "avec \n" +
- "\n" +
- "commentaire...\";Vrac;2;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;\n" +
- "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-vrac-80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;5.4444447;\n" +
- "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;9.074075;\n" +
- "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;5.0;1;0.6;cm;1.0;4;0.6;907.4074;\n" +
- "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;6.0;2;0.4;cm;1.0;10;0.4;1361.1111;\n" +
- "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-horsvrac-20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" +
- "2013;test elevation;1;;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;UNK - Indéterminé;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;0.0;\n" +
- "2013;test elevation;1;;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;Mâle;2;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;0.0;\n" +
- "2013;test elevation;1;;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;Femelle;3;;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;;1.0;");
-
- }
-
- {
- // check gearCaracteristics file content
-
- URL url = new URL(urlPrefix + "gearCaracteristics.csv");
- ServiceDbResource.assertFileContent("gearCaracteristics export:\n",
- url,
- "Annee;Serie;Serie_Partielle;Engin;Code_PMFM;Libelle_PMFM;Valeur");
-
- }
-
- {
- // check marineLitter file content
-
- URL url = new URL(urlPrefix + "marineLitter.csv");
- ServiceDbResource.assertFileContent("marineLitter export:\n",
- url,
- "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;MarineLitterCategory;MarineLitterSizeCategory;Number;Weight;Commentaire\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;L1 PLASTIQUE;A: <5*5 cm= 25 cm2;10;;\"Trait B-2-1 Macro dechet L1 Plastique (nb 10)\n" +
- "\n" +
- "avec \n" +
- "\n" +
- "commentaire...\";");
-
- }
- {
- // check parameter file content
-
- URL url = new URL(urlPrefix + "parameter.csv");
- ServiceDbResource.assertFileContent("parameter export:\n",
- url,
- "Annee;Serie;Serie_Partielle;Code_station;Numero_Trait;Poche;Code_PMFM;Libelle_PMFm;Valeur");
-
- }
- }
-}
Deleted: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,505 +0,0 @@
-package fr.ifremer.tutti.service.export;
-
-/*
- * #%L
- * Tutti :: Service
- * $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 com.google.common.collect.Lists;
-import com.google.common.io.Files;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.ServiceDbResource;
-import fr.ifremer.tutti.service.TuttiServiceContext;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class TuttiExportServiceTest {
-
- @ClassRule
- public static final ServiceDbResource dbResource =
- ServiceDbResource.readDb("dbCGFS");
-
- public static final String PROGRAM_ID = "CAM-CGFS";
-
- public static final String CRUISE_ID = "100001";
-
- public static final String CRUISE_CGFS_ID = "100000";
-
- public static final String OPERATION_1_ID = "100106";
-
- public static final String OPERATION_2_ID = "100107";
-
- public static final String SURVEY_CONTENT =
- "Annee;Serie;Serie_Partielle;Navire;Pays;Zone_Etude;Campagne;Id_Sismer;Date_Deb_Campagne;Port_Deb_Campagne;Date_Fin_Campagne;Port_Fin_Campagne;Chef_Mission;Resp_Salle_Tri;Commentaire\n" +
- "2013;Campagne CGFS;;278970;FRA;CGFS - Manche Est / Sud Mer du Nord;Campagne CGFS_2013;;01/05/2013 00:00:00;La Barbotière (Gujan-Mestras);31/05/2013 00:00:00;Etang de Palo;Vincent AURECHE;Alain TETARD;;";
-
- public static final String GEAR_CARACTERISTICS_CONTENT =
- "Annee;Serie;Serie_Partielle;Engin;Code_PMFM;Libelle_PMFM;Valeur\n" +
- "2013;Campagne CGFS;;ScientificGear;289;Armature (drague) - engin - totale - Déclaration d'un professionnel;Lame;\n" +
- "2013;Campagne CGFS;;ScientificGear;121;Diamètre du goulot (Casier) - engin - goulotte - Déclaration d'un professionnel;120.0;\n" +
- "2013;Campagne CGFS;;ScientificGear;927;Maillage étiré de l'engin - engin - Maille des ailes - Inconnue;15.0;\n" +
- "2013;Campagne CGFS;;ScientificGear;287;Volet dépresseur (drague) - engin - totale - Déclaration d'un professionnel;Oui;";
-
- public static final String OPERATION_WITH_NO_CATCH_CONTENT =
- "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;NavireAssocie;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
- "2010;Campagne CGFS;;65;65;1;GOV 19.7/25.9;278970;13/10/2010 13:35:00;50.22833;0.31833;13/10/2010 14:05:00;50.22167;0.28333;30;Strate 4J;NA;Localité 4J2;N;Y;2512.0;NA;NA;NA;;;avarie - chalut annulé completement à poil;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;";
-
- public static final String OPERATION_WITH_NO_CATCH_CONTENT_AND_NO_GEAR =
- "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;NavireAssocie;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
- "2010;Campagne CGFS;;65;65;1;;278970;13/10/2010 13:35:00;50.22833;0.31833;13/10/2010 14:05:00;50.22167;0.28333;30;Strate 4J;NA;Localité 4J2;N;Y;2512.0;NA;NA;NA;;;avarie - chalut annulé completement à poil;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;";
-
- public static final String OPERATION_CONTENT =
- "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;NavireAssocie;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
- "2013;Campagne CGFS;;A;1;1;GOV 19.7/25.9;278970;01/05/2013 00:00:00;;;01/05/2013 00:23:00;;;23;Strate 1D;NA;Localité 1D2;?;N;;NA;NA;NA;Vincent AURECHE;;op1;120.0;Y;100.0;Y;20.0;Y;0.0;Y;;?;;?;120.0;Y;100.0;Y;100.0;Y;20.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;6.0;Y;\n" +
- "2013;Campagne CGFS;;A;2;1;GOV 19.7/25.9;278970;11/05/2013 08:00:00;;;11/05/2013 08:23:00;;;23;Strate 1D;NA;Localité 1D2;?;N;;NA;NA;NA;Robert BELLAIL|Herve BARONE;;OP2;0.0;Y;0.0;Y;0.0;Y;0.0;Y;;?;;?;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;";
-
- public static final String PARAMETER_CONTENT =
- "Annee;Serie;Serie_Partielle;Code_station;Numero_Trait;Poche;Code_PMFM;Libelle_PMFm;Valeur\n" +
- "2013;Campagne CGFS;;A;1;1;1164;Catégorie UE - produit/lot - totale - Diffusion par une Halle à marée;Cat UE10;\n" +
- "2013;Campagne CGFS;;A;1;1;1302;(Gross Tonnage) : augmentation de tonnage accordée pour des raisons de sécurité - navire - totale - Déclaration d'un professionnel;10.0;\n" +
- "2013;Campagne CGFS;;A;1;1;194;\"Etat de la mer - masse d'eau, eau brute - totale - Observation par un observateur\";\"2 - belle, vagues de 0.1 à 0.5 mètres\";\n" +
- "2013;Campagne CGFS;;A;1;1;821;Direction vent - air - totale - Instrument de bord;0.1;\n" +
- "2013;Campagne CGFS;;A;1;1;149;Coût de la glace - navire - totale - Déclaration d'un professionnel;10.0;\n" +
- "2013;Campagne CGFS;;A;2;1;1062;Catégorie de fraicheur - produit/lot - totale - Diffusion par une Halle à marée;A - Catégorie A;\n" +
- "2013;Campagne CGFS;;A;2;1;308;Nombre d'engin - engin - totale - Déclaration d'un professionnel;2.0;";
-
- public static final String CATCH_CONTENT =
- "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V_HV;Num_Ordre_V_HV_H2;Tot_V_HV;Ech_V_HV;Type_Volume_Poids_V_HV;Unite_Volume_Poids_V_HV;Class_Tri_;Num_Ordre_Class_Tri__H2;Tot_Class_Tri_;Ech_Class_Tri_;Type_Volume_Poids_Class_Tri_;Unite_Volume_Poids_Class_Tri_;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.0;1;;cm;0.5;5;5.0;20.0;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;2;;cm;0.5;2;5.0;20.0;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;11.0;3;;cm;0.5;1;5.0;20.0;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;3 - Stade 3;3;10.0;;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;11.0;1;;cm;0.5;5;10.0;10.0;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Femelle;2;50.0;30.0;Poids;kg;3 - Stade 3;3;10.0;;Poids;kg;NA;;;;;kg;1425;Longueur totale (LT) - individu - queue - Mesure au cm par un observateur;10.0;1;;cm;;5;30.0;3.3333333;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Femelle;2;50.0;30.0;Poids;kg;3 - Stade 3;3;10.0;;Poids;kg;NA;;;;;kg;1425;Longueur totale (LT) - individu - queue - Mesure au cm par un observateur;11.0;2;;cm;;6;30.0;3.3333333;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Femelle;2;50.0;30.0;Poids;kg;3 - Stade 3;3;10.0;;Poids;kg;NA;;;;;kg;1425;Longueur totale (LT) - individu - queue - Mesure au cm par un observateur;12.0;3;;cm;;7;30.0;3.3333333;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|;Vrac;1;100.0;;Poids;kg;M - Moyen;2;20.0;;Poids;kg;Femelle;2;50.0;30.0;Poids;kg;3 - Stade 3;3;10.0;;Poids;kg;NA;;;;;kg;;;;;;;;;20.0;5.0;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;2;20.0;1.0;";
-
- public static final String CATCH_CONTENT_2 =
- "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V_HV;Num_Ordre_V_HV_H2;Tot_V_HV;Ech_V_HV;Type_Volume_Poids_V_HV;Unite_Volume_Poids_V_HV;Class_Tri_;Num_Ordre_Class_Tri__H2;Tot_Class_Tri_;Ech_Class_Tri_;Type_Volume_Poids_Class_Tri_;Unite_Volume_Poids_Class_Tri_;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;365;Aequipecten opercularis;taxon;Vrac;1;0.005;0.005;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.005;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;491;Alloteuthis;taxon;Vrac;2;0.004;0.004;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.004;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;300;Buccinum undatum;taxon;Vrac;3;0.015;0.015;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.015;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1811;Callionymus lyra;taxon;Vrac;4;0.07;0.07;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.07;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1644;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;36.0;1;;cm;1.0;1;1.06;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1644;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;38.0;2;;cm;1.0;1;1.06;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;2;0.038;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;12.5;2;;cm;0.5;1;0.038;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;13.0;3;;cm;0.5;1;0.038;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;25.0;1;;cm;1.0;1;0.66;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;28.0;2;;cm;1.0;1;0.66;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;3;;cm;1.0;1;0.66;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;9.0;1;;cm;1.0;1;0.28;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;10.0;2;;cm;1.0;3;0.28;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;11.0;3;;cm;1.0;2;0.28;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1988;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;15.0;1;;cm;1.0;1;0.152;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1988;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;18.0;2;;cm;1.0;1;0.152;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1690;Mullus surmuletus;taxon;Vrac;10;0.036;0.036;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;1;;cm;1.0;1;0.036;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1978;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;26.0;1;;cm;1.0;1;0.852;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1978;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;2;;cm;1.0;1;0.852;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1351;Sardina pilchardus;taxon;Vrac;12;0.022;0.022;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;1;0.022;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1772;Scomber scombrus;taxon;Vrac;13;0.18;0.18;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;27.0;1;;cm;1.0;1;0.18;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1242;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;51.0;1;;cm;1.0;1;1.0;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1242;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;55.0;2;;cm;1.0;1;1.0;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;8.0;1;;cm;1.0;1;0.96;136.71875;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;9.0;2;;cm;1.0;20;0.96;136.71875;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;10.0;3;;cm;1.0;89;0.96;136.71875;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;4;;cm;1.0;5;0.96;136.71875;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;G - Gros;2;0.13;0.13;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;23.0;1;;cm;1.0;1;0.13;1009.6154;";
-
- public static final String MARINE_LITTER_CONTENT =
- "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;MarineLitterCategory;MarineLitterSizeCategory;Number;Weight;Commentaire\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;L1 PLASTIQUE;A: <5*5 cm= 25 cm2;2;5.0;S1;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;L1a Sacs;B: <10*10 cm= 100 cm2;3;1.0;S2;";
-
- public static final String INDIVIDUAL_OBSERVATION_CONTENT =
- "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;220;0.1;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;1433;307;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;307;10.0;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;1436;10;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;1435;A20;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;101;10.0;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;46;0L - 0 VMS - 1 LB;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;1388;5.0;";
-
- public static final String ACCIDENTAL_CATCH_CONTENT =
- "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100001;3835;Abalistes;;1393;Rejet mort;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100001;3835;Abalistes;;196;Femelle;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100001;3835;Abalistes;;220;10.0;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100001;3835;Abalistes;;1433;1425;\n" +
- "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100001;3835;Abalistes;;1425;4.0;";
-
- public static final String SPECIES_CONTENT =
- "Id;Code_Rubin;Nom Scientifique;Code campagne\n" +
- "3835;ABAL;Abalistes;;\n" +
- "11242;AAPT;Aaptos;;\n" +
- "11243;AAPTAAP;Aaptos aaptos;;";
-
- public static final String SPECIES_CONTENT_2 =
- "Id;Code_Rubin;Nom Scientifique;Code campagne\n" +
- "300;BUCCUND;Buccinum undatum;;\n" +
- "365;AEQUOPE;Aequipecten opercularis;;\n" +
- "489;LOLIVUL;Loligo vulgaris;LOLIVUL;\n" +
- "491;ALLO;Alloteuthis;ALLOSPP;\n" +
- "1242;SCYOCAN;Scyliorhinus canicula;SCYOCAN;\n" +
- "1351;SARDPIL;Sardina pilchardus;SARDPIL;\n" +
- "1362;ENGRENC;Engraulis encrasicolus;ENGRENC;\n" +
- "1644;DICELAB;Dicentrarchus labrax;DICELAB;\n" +
- "1662;TRACTRA;Trachurus trachurus;TRACTRA;\n" +
- "1690;MULLSUR;Mullus surmuletus;MULLSUR;\n" +
- "1772;SCOMSCO;Scomber scombrus;SCOMSCO;\n" +
- "1811;CALMLYR;Callionymus lyra;CALMLYR;\n" +
- "1978;PLEUPLA;Pleuronectes platessa;;\n" +
- "1986;LIMDLIM;Limanda limanda;;\n" +
- "1988;MICTKIT;Microstomus kitt;;";
-
- public static final int NB_EXPECTED_CGFS_OPERATIONS = 106;
-
- protected TuttiExportService service;
-
- protected PersistenceService persistenceService;
-
- protected ServiceDbResource.DataContext dataContext;
-
- protected ProgressionModel progressionModel;
-
- protected File dataDirectory;
-
- @Before
- public void setUp() throws Exception {
-
- dataDirectory = dbResource.getServiceConfig().getDataDirectory();
-
- TuttiServiceContext serviceContext = dbResource.getServiceContext();
-
- persistenceService = serviceContext.getService(PersistenceService.class);
-
- dbResource.setCountryInConfig("12");
- dbResource.openDataContext();
-
- service = serviceContext.getService(TuttiExportService.class);
-
- dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 2, OPERATION_1_ID, OPERATION_2_ID);
-
- progressionModel = new ProgressionModel();
- progressionModel.setTotal(9);
- }
-
- @Ignore
- @Test
- public void exportProgram() throws Exception {
-
- File exportFile = new File(dataDirectory, "exportProgram.zip");
-
- Files.createParentDirs(exportFile);
-
- Assert.assertFalse(exportFile.exists());
-
- service.exportProgram(dataContext.program.getId(), exportFile, progressionModel);
- Assert.assertTrue(exportFile.exists());
- }
-
- @Test
- public void exportCruise() throws Exception {
-
- File exportFile = new File(dataDirectory, "exportCruise.zip");
-
- Files.createParentDirs(exportFile);
-
- Assert.assertFalse(exportFile.exists());
-
- service.exportCruise(dataContext.cruise.getId(), exportFile, progressionModel);
- Assert.assertTrue(exportFile.exists());
- }
-
- @Test
- public void exportSurvey() throws Exception {
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportSurvey(exportContext, dataContext.cruise);
- } finally {
- exportContext.close();
- }
- ServiceDbResource.assertFileContent("Survey export:\n",
- exportContext.surveyFile,
- SURVEY_CONTENT);
- }
-
- @Test
- public void exportGearCaracteristics() throws Exception {
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportGearCaracteristics(exportContext, dataContext.cruise);
- } finally {
- exportContext.close();
- }
- ServiceDbResource.assertFileContent("Gear caracteristics export:\n",
- exportContext.gearCaracteristicsFile,
- GEAR_CARACTERISTICS_CONTENT);
- }
-
- @Test
- public void exportOperations() throws Exception {
-
-// loadData(PROGRAM_ID, CRUISE_CGFS_ID);
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportOperations(exportContext, dataContext.cruise, dataContext.operations);
- } finally {
- exportContext.close();
- }
- ServiceDbResource.assertFileContent("Operation export:\n",
- exportContext.operationFile,
- OPERATION_CONTENT);
- }
-
- @Test
- public void exportOperationsWithNoCatches() throws Exception {
-
- dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
-
- FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100105");
- dataContext.operations = Lists.newArrayList(operation);
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportOperations(exportContext, dataContext.cruise, dataContext.operations);
- } finally {
- exportContext.close();
- }
-
- ServiceDbResource.assertFileContent("Operation export:\n",
- exportContext.operationFile,
- OPERATION_WITH_NO_CATCH_CONTENT);
- }
-
- @Test
- public void exportOperationsWithNoGear() throws Exception {
-
- dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
-
- FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100105");
- operation.setGear(null);
- dataContext.operations = Lists.newArrayList(operation);
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportOperations(exportContext, dataContext.cruise, dataContext.operations);
- } finally {
- exportContext.close();
- }
-
- ServiceDbResource.assertFileContent("Operation export:\n",
- exportContext.operationFile,
- OPERATION_WITH_NO_CATCH_CONTENT_AND_NO_GEAR);
- }
-
- @Test
- public void exportParameters() throws Exception {
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportParameters(exportContext, dataContext.cruise, dataContext.operations);
- } finally {
- exportContext.close();
- }
- ServiceDbResource.assertFileContent("Parameter export:\n",
- exportContext.parameterFile,
- PARAMETER_CONTENT);
- }
-
- @Test
- public void exportCatches() throws Exception {
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
- } finally {
- exportContext.close();
- }
- ServiceDbResource.assertFileContent("Catch export:\n",
- exportContext.catchFile,
- CATCH_CONTENT);
- }
-
- // To fix http://forge.codelutin.com/issues/2692
- @Test
- public void exportCatchesAndSpecies() throws Exception {
-
- File protocolFile = new File("src/test/resources/tuttiProtocol.tuttiProtocol");
-
- TuttiProtocol protocol = dbResource.loadProtocol(protocolFile);
-
- persistenceService.setProtocol(protocol);
-
- dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
-
- FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100000");
- dataContext.operations = Lists.newArrayList(operation);
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
- service.exportSpecies(exportContext, exportContext.getSpeciesToExport());
- } finally {
- exportContext.close();
- }
-
- ServiceDbResource.assertFileContent("species export:\n",
- exportContext.speciesFile,
- SPECIES_CONTENT_2);
-
- ServiceDbResource.assertFileContent("Catch export:\n",
- exportContext.catchFile,
- CATCH_CONTENT_2);
-
-
- }
-
- // To fix http://forge.codelutin.com/issues/2523
- @Test
- public void exportBadCatches() throws Exception {
-
- dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
- } finally {
- exportContext.close();
- }
- }
-
- @Test
- public void exportMarineLitters() throws Exception {
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportMarineLitters(exportContext, dataContext.cruise, dataContext.operations);
- } finally {
- exportContext.close();
- }
- ServiceDbResource.assertFileContent("MarineLitter export:\n",
- exportContext.marineLitterFile,
- MARINE_LITTER_CONTENT);
- }
-
- @Test
- public void exportIndividualObservations() throws Exception {
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportIndividualObservations(exportContext, dataContext.cruise, dataContext.operations);
- } finally {
- exportContext.close();
- }
- ServiceDbResource.assertFileContent("individualObservation export:\n",
- exportContext.individualObservationFile,
- INDIVIDUAL_OBSERVATION_CONTENT);
- }
-
- @Test
- public void exportAccidentalCatch() throws Exception {
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- service.exportAccidentalCatch(exportContext, dataContext.cruise, dataContext.operations);
- } finally {
- exportContext.close();
- }
- ServiceDbResource.assertFileContent("accidentalCatch export:\n",
- exportContext.accidentalCatchFile,
- ACCIDENTAL_CATCH_CONTENT);
- }
-
- @Test
- public void exportSpecies() throws Exception {
-
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory);
-
- try {
- List<Species> allReferentSpecies =
- persistenceService.getAllReferentSpecies();
-
- Map<String, Species> allReferentSpeciesById =
- TuttiEntities.splitById(allReferentSpecies);
- exportContext.addSpecies(allReferentSpeciesById.get("35883"));
- exportContext.addSpecies(allReferentSpeciesById.get("35884"));
- exportContext.addSpecies(allReferentSpeciesById.get("19279"));
-
- service.exportSpecies(exportContext,
- exportContext.getSpeciesToExport());
- } finally {
- exportContext.close();
- }
- ServiceDbResource.assertFileContent("species export:\n",
- exportContext.speciesFile,
- SPECIES_CONTENT);
- }
-
-}
Copied: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java (from rev 1361, trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java)
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java (rev 0)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,265 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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 com.google.common.io.Files;
+import fr.ifremer.tutti.TuttiBusinessException;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.ServiceDbResource;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import fr.ifremer.tutti.service.catches.WeightComputingService;
+import fr.ifremer.tutti.service.export.generic.TuttiExportService;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * Test export of catches.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.3.2
+ */
+public class TuttiExportService2Test {
+
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.readDb("dbExport");
+
+ public static final String PROGRAM_ID = "CAM-TEST_ELEVATION";
+
+ public static final String CRUISE_ID = "100003";
+
+ public static final String OPERATION_1_ID = "100112";
+
+ public static final String OPERATION_2_ID = "100113";
+
+ public static final String OPERATION_3_ID = "100114";
+
+ protected TuttiExportService service;
+
+ protected ServiceDbResource.DataContext dataContext;
+
+ protected File dataDirectory;
+
+ @Before
+ public void setUp() throws Exception {
+
+ dataDirectory = dbResource.getServiceConfig().getDataDirectory();
+
+ dbResource.setCountryInConfig("12");
+
+ dbResource.openDataContext();
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ service = serviceContext.getService(TuttiExportService.class);
+
+ }
+
+ @Test
+ public void exportWithErrors() throws Exception {
+
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ PersistenceService persistenceService = serviceContext.getService(PersistenceService.class);
+
+ // check there is a error while compute weight for a cruise
+ boolean errorDetected = false;
+ WeightComputingService computingService = serviceContext.getService(WeightComputingService.class);
+ List<String> allFishingOperation = persistenceService.getAllFishingOperationIds(CRUISE_ID);
+ for (String fishingOperation : allFishingOperation) {
+ try {
+ computingService.getComputedSpeciesBatches(fishingOperation);
+ } catch (Exception e) {
+ errorDetected = true;
+ break;
+ }
+ }
+
+ Assert.assertTrue(errorDetected);
+
+ File exportFile = new File(dataDirectory, "exportCruise.zip");
+
+ Files.createParentDirs(exportFile);
+
+ Assert.assertFalse(exportFile.exists());
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ progressionModel.setTotal(9);
+ try {
+ service.exportCruise(CRUISE_ID, exportFile, progressionModel);
+ // got an error after but export was still performed
+ Assert.fail();
+ } catch (TuttiBusinessException e) {
+ // got an error
+ Assert.assertTrue(true);
+ }
+ // export perform, file exist
+ Assert.assertTrue(exportFile.exists());
+
+ String urlPrefix = "jar:" + exportFile.toURI().toURL() + "!/exportCruise-" + CRUISE_ID + "/";
+ {
+ // check species file content
+
+ URL url = new URL(urlPrefix + "species.csv");
+ ServiceDbResource.assertFileContent("species export:\n",
+ url,
+ "Id;Code_Rubin;Nom Scientifique;Code campagne\n" +
+ "380;ACANECH;Acanthocardia echinata;;\n" +
+ "1358;ALOSALO;Alosa alosa;;\n" +
+ "1938;AGONCAT;Agonus cataphractus;;\n" +
+ "4622;ABIEABI;Abietinaria abietina;;\n" +
+ "11183;;Brissopsis atlantica;;");
+
+ }
+
+ {
+ // check accidentalCatch file content
+
+ URL url = new URL(urlPrefix + "accidentalCatch.csv");
+ ServiceDbResource.assertFileContent("accidentalCatch export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue");
+
+ }
+
+ {
+ // check operation file content
+
+ URL url = new URL(urlPrefix + "operation.csv");
+ ServiceDbResource.assertFileContent("operation export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;NavireAssocie;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
+ "2013;test elevation;1;B;2;1;OTB 20/28.10;278970;01/07/2013 00:00:00;;;01/07/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;;\"Commentaire sur le trait B-2-1\n" +
+ "\n" +
+ "avec\n" +
+ "saut\n" +
+ "de \n" +
+ "ligne\";1000.0;Y;280.0;Y;20.0;Y;700.0;N;;?;;?;200.0;Y;180.0;Y;180.0;Y;20.0;Y;0.0;Y;0.0;Y;100.0;Y;100.0;N;50.0;Y;0.0;Y;2.0;N;0.0;Y;100.0;N;\n" +
+ "2013;test elevation;1;A;1;1;OTB 20/28.10;278970;01/07/2013 00:00:00;;;01/07/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;;\"commentaire trait A-1-1\n" +
+ "Avec \n" +
+ "saut\n" +
+ "de\n" +
+ "ligne\n" +
+ "...\";1000.0;Y;180.0;Y;20.0;Y;800.0;N;;?;;?;200.0;Y;180.0;Y;180.0;Y;20.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;\n" +
+ "2013;test elevation;1;C;3;1;;278970;25/09/2013 00:00:00;;;25/09/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;;;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;");
+
+ }
+
+ {
+ // check survey file content
+
+ URL url = new URL(urlPrefix + "survey.csv");
+ ServiceDbResource.assertFileContent("survey export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Navire;Pays;Zone_Etude;Campagne;Id_Sismer;Date_Deb_Campagne;Port_Deb_Campagne;Date_Fin_Campagne;Port_Fin_Campagne;Chef_Mission;Resp_Salle_Tri;Commentaire\n" +
+ "2013;test elevation;1;278970;FRA;CGFS - Manche Est / Sud Mer du Nord;test elevation_2013_1;;01/07/2013 00:00:00;La Barbotière (Gujan-Mestras);04/07/2013 00:00:00;La Barbotière (Gujan-Mestras);Adrian LEVREL;Alain BISEAU;;");
+
+ }
+
+ {
+ // check individualObservation file content
+
+ URL url = new URL(urlPrefix + "individualObservation.csv");
+ ServiceDbResource.assertFileContent("individualObservation export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue");
+
+ }
+
+ {
+ // check catch file content
+
+ URL url = new URL("jar:" + exportFile.toURI().toURL() + "!/exportCruise-" + CRUISE_ID + "/catch.csv");
+ ServiceDbResource.assertFileContent("Catch export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V_HV;Num_Ordre_V_HV_H2;Tot_V_HV;Ech_V_HV;Type_Volume_Poids_V_HV;Unite_Volume_Poids_V_HV;Class_Tri_;Num_Ordre_Class_Tri__H2;Tot_Class_Tri_;Ech_Class_Tri_;Type_Volume_Poids_Class_Tri_;Unite_Volume_Poids_Class_Tri_;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-vrac 80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;3.5;\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;5.8333335;\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Femelle 40.0;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;40.0;8.75;\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-horsvrac 20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;4622;Abietinaria abietina;\"Trait B-2-1 Benthos ABIEABI Vrac 30\n" +
+ "\n" +
+ "avec \n" +
+ "\n" +
+ "commentaire...\";Vrac;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;7.0;\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;380;Acanthocardia echinata;\"Trait B-2-1 Benthos ACANECH Vrac 18\n" +
+ "\n" +
+ "avec \n" +
+ "\n" +
+ "commentaire...\";Vrac;2;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;\n" +
+ "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-vrac-80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;5.4444447;\n" +
+ "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;9.074075;\n" +
+ "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;5.0;1;0.6;cm;1.0;4;0.6;907.4074;\n" +
+ "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;6.0;2;0.4;cm;1.0;10;0.4;1361.1111;\n" +
+ "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-horsvrac-20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" +
+ "2013;test elevation;1;;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;UNK - Indéterminé;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;0.0;\n" +
+ "2013;test elevation;1;;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;Mâle;2;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;0.0;\n" +
+ "2013;test elevation;1;;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;Femelle;3;;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;;1.0;");
+
+ }
+
+ {
+ // check gearCaracteristics file content
+
+ URL url = new URL(urlPrefix + "gearCaracteristics.csv");
+ ServiceDbResource.assertFileContent("gearCaracteristics export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Engin;Code_PMFM;Libelle_PMFM;Valeur");
+
+ }
+
+ {
+ // check marineLitter file content
+
+ URL url = new URL(urlPrefix + "marineLitter.csv");
+ ServiceDbResource.assertFileContent("marineLitter export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;MarineLitterCategory;MarineLitterSizeCategory;Number;Weight;Commentaire\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;L1 PLASTIQUE;A: <5*5 cm= 25 cm2;10;;\"Trait B-2-1 Macro dechet L1 Plastique (nb 10)\n" +
+ "\n" +
+ "avec \n" +
+ "\n" +
+ "commentaire...\";");
+
+ }
+ {
+ // check parameter file content
+
+ URL url = new URL(urlPrefix + "parameter.csv");
+ ServiceDbResource.assertFileContent("parameter export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Code_station;Numero_Trait;Poche;Code_PMFM;Libelle_PMFm;Valeur");
+
+ }
+ }
+}
Copied: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java (from rev 1361, trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java)
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java (rev 0)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,506 @@
+package fr.ifremer.tutti.service.export.generic;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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 com.google.common.collect.Lists;
+import com.google.common.io.Files;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.ServiceDbResource;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import fr.ifremer.tutti.service.export.generic.TuttiExportService;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class TuttiExportServiceTest {
+
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.readDb("dbCGFS");
+
+ public static final String PROGRAM_ID = "CAM-CGFS";
+
+ public static final String CRUISE_ID = "100001";
+
+ public static final String CRUISE_CGFS_ID = "100000";
+
+ public static final String OPERATION_1_ID = "100106";
+
+ public static final String OPERATION_2_ID = "100107";
+
+ public static final String SURVEY_CONTENT =
+ "Annee;Serie;Serie_Partielle;Navire;Pays;Zone_Etude;Campagne;Id_Sismer;Date_Deb_Campagne;Port_Deb_Campagne;Date_Fin_Campagne;Port_Fin_Campagne;Chef_Mission;Resp_Salle_Tri;Commentaire\n" +
+ "2013;Campagne CGFS;;278970;FRA;CGFS - Manche Est / Sud Mer du Nord;Campagne CGFS_2013;;01/05/2013 00:00:00;La Barbotière (Gujan-Mestras);31/05/2013 00:00:00;Etang de Palo;Vincent AURECHE;Alain TETARD;;";
+
+ public static final String GEAR_CARACTERISTICS_CONTENT =
+ "Annee;Serie;Serie_Partielle;Engin;Code_PMFM;Libelle_PMFM;Valeur\n" +
+ "2013;Campagne CGFS;;ScientificGear;289;Armature (drague) - engin - totale - Déclaration d'un professionnel;Lame;\n" +
+ "2013;Campagne CGFS;;ScientificGear;121;Diamètre du goulot (Casier) - engin - goulotte - Déclaration d'un professionnel;120.0;\n" +
+ "2013;Campagne CGFS;;ScientificGear;927;Maillage étiré de l'engin - engin - Maille des ailes - Inconnue;15.0;\n" +
+ "2013;Campagne CGFS;;ScientificGear;287;Volet dépresseur (drague) - engin - totale - Déclaration d'un professionnel;Oui;";
+
+ public static final String OPERATION_WITH_NO_CATCH_CONTENT =
+ "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;NavireAssocie;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
+ "2010;Campagne CGFS;;65;65;1;GOV 19.7/25.9;278970;13/10/2010 13:35:00;50.22833;0.31833;13/10/2010 14:05:00;50.22167;0.28333;30;Strate 4J;NA;Localité 4J2;N;Y;2512.0;NA;NA;NA;;;avarie - chalut annulé completement à poil;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;";
+
+ public static final String OPERATION_WITH_NO_CATCH_CONTENT_AND_NO_GEAR =
+ "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;NavireAssocie;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
+ "2010;Campagne CGFS;;65;65;1;;278970;13/10/2010 13:35:00;50.22833;0.31833;13/10/2010 14:05:00;50.22167;0.28333;30;Strate 4J;NA;Localité 4J2;N;Y;2512.0;NA;NA;NA;;;avarie - chalut annulé completement à poil;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;";
+
+ public static final String OPERATION_CONTENT =
+ "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;NavireAssocie;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
+ "2013;Campagne CGFS;;A;1;1;GOV 19.7/25.9;278970;01/05/2013 00:00:00;;;01/05/2013 00:23:00;;;23;Strate 1D;NA;Localité 1D2;?;N;;NA;NA;NA;Vincent AURECHE;;op1;120.0;Y;100.0;Y;20.0;Y;0.0;Y;;?;;?;120.0;Y;100.0;Y;100.0;Y;20.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;6.0;Y;\n" +
+ "2013;Campagne CGFS;;A;2;1;GOV 19.7/25.9;278970;11/05/2013 08:00:00;;;11/05/2013 08:23:00;;;23;Strate 1D;NA;Localité 1D2;?;N;;NA;NA;NA;Robert BELLAIL|Herve BARONE;;OP2;0.0;Y;0.0;Y;0.0;Y;0.0;Y;;?;;?;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;";
+
+ public static final String PARAMETER_CONTENT =
+ "Annee;Serie;Serie_Partielle;Code_station;Numero_Trait;Poche;Code_PMFM;Libelle_PMFm;Valeur\n" +
+ "2013;Campagne CGFS;;A;1;1;1164;Catégorie UE - produit/lot - totale - Diffusion par une Halle à marée;Cat UE10;\n" +
+ "2013;Campagne CGFS;;A;1;1;1302;(Gross Tonnage) : augmentation de tonnage accordée pour des raisons de sécurité - navire - totale - Déclaration d'un professionnel;10.0;\n" +
+ "2013;Campagne CGFS;;A;1;1;194;\"Etat de la mer - masse d'eau, eau brute - totale - Observation par un observateur\";\"2 - belle, vagues de 0.1 à 0.5 mètres\";\n" +
+ "2013;Campagne CGFS;;A;1;1;821;Direction vent - air - totale - Instrument de bord;0.1;\n" +
+ "2013;Campagne CGFS;;A;1;1;149;Coût de la glace - navire - totale - Déclaration d'un professionnel;10.0;\n" +
+ "2013;Campagne CGFS;;A;2;1;1062;Catégorie de fraicheur - produit/lot - totale - Diffusion par une Halle à marée;A - Catégorie A;\n" +
+ "2013;Campagne CGFS;;A;2;1;308;Nombre d'engin - engin - totale - Déclaration d'un professionnel;2.0;";
+
+ public static final String CATCH_CONTENT =
+ "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V_HV;Num_Ordre_V_HV_H2;Tot_V_HV;Ech_V_HV;Type_Volume_Poids_V_HV;Unite_Volume_Poids_V_HV;Class_Tri_;Num_Ordre_Class_Tri__H2;Tot_Class_Tri_;Ech_Class_Tri_;Type_Volume_Poids_Class_Tri_;Unite_Volume_Poids_Class_Tri_;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.0;1;;cm;0.5;5;5.0;20.0;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;2;;cm;0.5;2;5.0;20.0;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;11.0;3;;cm;0.5;1;5.0;20.0;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;3 - Stade 3;3;10.0;;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;11.0;1;;cm;0.5;5;10.0;10.0;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Femelle;2;50.0;30.0;Poids;kg;3 - Stade 3;3;10.0;;Poids;kg;NA;;;;;kg;1425;Longueur totale (LT) - individu - queue - Mesure au cm par un observateur;10.0;1;;cm;;5;30.0;3.3333333;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Femelle;2;50.0;30.0;Poids;kg;3 - Stade 3;3;10.0;;Poids;kg;NA;;;;;kg;1425;Longueur totale (LT) - individu - queue - Mesure au cm par un observateur;11.0;2;;cm;;6;30.0;3.3333333;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Femelle;2;50.0;30.0;Poids;kg;3 - Stade 3;3;10.0;;Poids;kg;NA;;;;;kg;1425;Longueur totale (LT) - individu - queue - Mesure au cm par un observateur;12.0;3;;cm;;7;30.0;3.3333333;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|;Vrac;1;100.0;;Poids;kg;M - Moyen;2;20.0;;Poids;kg;Femelle;2;50.0;30.0;Poids;kg;3 - Stade 3;3;10.0;;Poids;kg;NA;;;;;kg;;;;;;;;;20.0;5.0;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;2;20.0;1.0;";
+
+ public static final String CATCH_CONTENT_2 =
+ "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V_HV;Num_Ordre_V_HV_H2;Tot_V_HV;Ech_V_HV;Type_Volume_Poids_V_HV;Unite_Volume_Poids_V_HV;Class_Tri_;Num_Ordre_Class_Tri__H2;Tot_Class_Tri_;Ech_Class_Tri_;Type_Volume_Poids_Class_Tri_;Unite_Volume_Poids_Class_Tri_;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;365;Aequipecten opercularis;taxon;Vrac;1;0.005;0.005;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.005;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;491;Alloteuthis;taxon;Vrac;2;0.004;0.004;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.004;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;300;Buccinum undatum;taxon;Vrac;3;0.015;0.015;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.015;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1811;Callionymus lyra;taxon;Vrac;4;0.07;0.07;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.07;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1644;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;36.0;1;;cm;1.0;1;1.06;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1644;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;38.0;2;;cm;1.0;1;1.06;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;2;0.038;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;12.5;2;;cm;0.5;1;0.038;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;13.0;3;;cm;0.5;1;0.038;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;25.0;1;;cm;1.0;1;0.66;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;28.0;2;;cm;1.0;1;0.66;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;3;;cm;1.0;1;0.66;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;9.0;1;;cm;1.0;1;0.28;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;10.0;2;;cm;1.0;3;0.28;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;11.0;3;;cm;1.0;2;0.28;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1988;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;15.0;1;;cm;1.0;1;0.152;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1988;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;18.0;2;;cm;1.0;1;0.152;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1690;Mullus surmuletus;taxon;Vrac;10;0.036;0.036;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;1;;cm;1.0;1;0.036;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1978;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;26.0;1;;cm;1.0;1;0.852;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1978;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;2;;cm;1.0;1;0.852;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1351;Sardina pilchardus;taxon;Vrac;12;0.022;0.022;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;1;0.022;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1772;Scomber scombrus;taxon;Vrac;13;0.18;0.18;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;27.0;1;;cm;1.0;1;0.18;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1242;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;51.0;1;;cm;1.0;1;1.0;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1242;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;55.0;2;;cm;1.0;1;1.0;1.0;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;8.0;1;;cm;1.0;1;0.96;136.71875;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;9.0;2;;cm;1.0;20;0.96;136.71875;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;10.0;3;;cm;1.0;89;0.96;136.71875;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;4;;cm;1.0;5;0.96;136.71875;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;G - Gros;2;0.13;0.13;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;23.0;1;;cm;1.0;1;0.13;1009.6154;";
+
+ public static final String MARINE_LITTER_CONTENT =
+ "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;MarineLitterCategory;MarineLitterSizeCategory;Number;Weight;Commentaire\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;L1 PLASTIQUE;A: <5*5 cm= 25 cm2;2;5.0;S1;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;L1a Sacs;B: <10*10 cm= 100 cm2;3;1.0;S2;";
+
+ public static final String INDIVIDUAL_OBSERVATION_CONTENT =
+ "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;220;0.1;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;1433;307;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;307;10.0;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;1436;10;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;1435;A20;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;101;10.0;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;46;0L - 0 VMS - 1 LB;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100000;11242;Aaptos;P1;1388;5.0;";
+
+ public static final String ACCIDENTAL_CATCH_CONTENT =
+ "Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100001;3835;Abalistes;;1393;Rejet mort;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100001;3835;Abalistes;;196;Femelle;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100001;3835;Abalistes;;220;10.0;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100001;3835;Abalistes;;1433;1425;\n" +
+ "2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;100001;3835;Abalistes;;1425;4.0;";
+
+ public static final String SPECIES_CONTENT =
+ "Id;Code_Rubin;Nom Scientifique;Code campagne\n" +
+ "3835;ABAL;Abalistes;;\n" +
+ "11242;AAPT;Aaptos;;\n" +
+ "11243;AAPTAAP;Aaptos aaptos;;";
+
+ public static final String SPECIES_CONTENT_2 =
+ "Id;Code_Rubin;Nom Scientifique;Code campagne\n" +
+ "300;BUCCUND;Buccinum undatum;;\n" +
+ "365;AEQUOPE;Aequipecten opercularis;;\n" +
+ "489;LOLIVUL;Loligo vulgaris;LOLIVUL;\n" +
+ "491;ALLO;Alloteuthis;ALLOSPP;\n" +
+ "1242;SCYOCAN;Scyliorhinus canicula;SCYOCAN;\n" +
+ "1351;SARDPIL;Sardina pilchardus;SARDPIL;\n" +
+ "1362;ENGRENC;Engraulis encrasicolus;ENGRENC;\n" +
+ "1644;DICELAB;Dicentrarchus labrax;DICELAB;\n" +
+ "1662;TRACTRA;Trachurus trachurus;TRACTRA;\n" +
+ "1690;MULLSUR;Mullus surmuletus;MULLSUR;\n" +
+ "1772;SCOMSCO;Scomber scombrus;SCOMSCO;\n" +
+ "1811;CALMLYR;Callionymus lyra;CALMLYR;\n" +
+ "1978;PLEUPLA;Pleuronectes platessa;;\n" +
+ "1986;LIMDLIM;Limanda limanda;;\n" +
+ "1988;MICTKIT;Microstomus kitt;;";
+
+ public static final int NB_EXPECTED_CGFS_OPERATIONS = 106;
+
+ protected TuttiExportService service;
+
+ protected PersistenceService persistenceService;
+
+ protected ServiceDbResource.DataContext dataContext;
+
+ protected ProgressionModel progressionModel;
+
+ protected File dataDirectory;
+
+ @Before
+ public void setUp() throws Exception {
+
+ dataDirectory = dbResource.getServiceConfig().getDataDirectory();
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ persistenceService = serviceContext.getService(PersistenceService.class);
+
+ dbResource.setCountryInConfig("12");
+ dbResource.openDataContext();
+
+ service = serviceContext.getService(TuttiExportService.class);
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 2, OPERATION_1_ID, OPERATION_2_ID);
+
+ progressionModel = new ProgressionModel();
+ progressionModel.setTotal(9);
+ }
+
+ @Ignore
+ @Test
+ public void exportProgram() throws Exception {
+
+ File exportFile = new File(dataDirectory, "exportProgram.zip");
+
+ Files.createParentDirs(exportFile);
+
+ Assert.assertFalse(exportFile.exists());
+
+ service.exportProgram(dataContext.program.getId(), exportFile, progressionModel);
+ Assert.assertTrue(exportFile.exists());
+ }
+
+ @Test
+ public void exportCruise() throws Exception {
+
+ File exportFile = new File(dataDirectory, "exportCruise.zip");
+
+ Files.createParentDirs(exportFile);
+
+ Assert.assertFalse(exportFile.exists());
+
+ service.exportCruise(dataContext.cruise.getId(), exportFile, progressionModel);
+ Assert.assertTrue(exportFile.exists());
+ }
+
+ @Test
+ public void exportSurvey() throws Exception {
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportSurvey(exportContext, dataContext.cruise);
+ } finally {
+ exportContext.close();
+ }
+ ServiceDbResource.assertFileContent("Survey export:\n",
+ exportContext.surveyFile,
+ SURVEY_CONTENT);
+ }
+
+ @Test
+ public void exportGearCaracteristics() throws Exception {
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportGearCaracteristics(exportContext, dataContext.cruise);
+ } finally {
+ exportContext.close();
+ }
+ ServiceDbResource.assertFileContent("Gear caracteristics export:\n",
+ exportContext.gearCaracteristicsFile,
+ GEAR_CARACTERISTICS_CONTENT);
+ }
+
+ @Test
+ public void exportOperations() throws Exception {
+
+// loadData(PROGRAM_ID, CRUISE_CGFS_ID);
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportOperations(exportContext, dataContext.cruise, dataContext.operations);
+ } finally {
+ exportContext.close();
+ }
+ ServiceDbResource.assertFileContent("Operation export:\n",
+ exportContext.operationFile,
+ OPERATION_CONTENT);
+ }
+
+ @Test
+ public void exportOperationsWithNoCatches() throws Exception {
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
+
+ FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100105");
+ dataContext.operations = Lists.newArrayList(operation);
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportOperations(exportContext, dataContext.cruise, dataContext.operations);
+ } finally {
+ exportContext.close();
+ }
+
+ ServiceDbResource.assertFileContent("Operation export:\n",
+ exportContext.operationFile,
+ OPERATION_WITH_NO_CATCH_CONTENT);
+ }
+
+ @Test
+ public void exportOperationsWithNoGear() throws Exception {
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
+
+ FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100105");
+ operation.setGear(null);
+ dataContext.operations = Lists.newArrayList(operation);
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportOperations(exportContext, dataContext.cruise, dataContext.operations);
+ } finally {
+ exportContext.close();
+ }
+
+ ServiceDbResource.assertFileContent("Operation export:\n",
+ exportContext.operationFile,
+ OPERATION_WITH_NO_CATCH_CONTENT_AND_NO_GEAR);
+ }
+
+ @Test
+ public void exportParameters() throws Exception {
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportParameters(exportContext, dataContext.cruise, dataContext.operations);
+ } finally {
+ exportContext.close();
+ }
+ ServiceDbResource.assertFileContent("Parameter export:\n",
+ exportContext.parameterFile,
+ PARAMETER_CONTENT);
+ }
+
+ @Test
+ public void exportCatches() throws Exception {
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
+ } finally {
+ exportContext.close();
+ }
+ ServiceDbResource.assertFileContent("Catch export:\n",
+ exportContext.catchFile,
+ CATCH_CONTENT);
+ }
+
+ // To fix http://forge.codelutin.com/issues/2692
+ @Test
+ public void exportCatchesAndSpecies() throws Exception {
+
+ File protocolFile = new File("src/test/resources/tuttiProtocol.tuttiProtocol");
+
+ TuttiProtocol protocol = dbResource.loadProtocol(protocolFile);
+
+ persistenceService.setProtocol(protocol);
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
+
+ FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100000");
+ dataContext.operations = Lists.newArrayList(operation);
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
+ service.exportSpecies(exportContext, exportContext.getSpeciesToExport());
+ } finally {
+ exportContext.close();
+ }
+
+ ServiceDbResource.assertFileContent("species export:\n",
+ exportContext.speciesFile,
+ SPECIES_CONTENT_2);
+
+ ServiceDbResource.assertFileContent("Catch export:\n",
+ exportContext.catchFile,
+ CATCH_CONTENT_2);
+
+
+ }
+
+ // To fix http://forge.codelutin.com/issues/2523
+ @Test
+ public void exportBadCatches() throws Exception {
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
+ } finally {
+ exportContext.close();
+ }
+ }
+
+ @Test
+ public void exportMarineLitters() throws Exception {
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportMarineLitters(exportContext, dataContext.cruise, dataContext.operations);
+ } finally {
+ exportContext.close();
+ }
+ ServiceDbResource.assertFileContent("MarineLitter export:\n",
+ exportContext.marineLitterFile,
+ MARINE_LITTER_CONTENT);
+ }
+
+ @Test
+ public void exportIndividualObservations() throws Exception {
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportIndividualObservations(exportContext, dataContext.cruise, dataContext.operations);
+ } finally {
+ exportContext.close();
+ }
+ ServiceDbResource.assertFileContent("individualObservation export:\n",
+ exportContext.individualObservationFile,
+ INDIVIDUAL_OBSERVATION_CONTENT);
+ }
+
+ @Test
+ public void exportAccidentalCatch() throws Exception {
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ service.exportAccidentalCatch(exportContext, dataContext.cruise, dataContext.operations);
+ } finally {
+ exportContext.close();
+ }
+ ServiceDbResource.assertFileContent("accidentalCatch export:\n",
+ exportContext.accidentalCatchFile,
+ ACCIDENTAL_CATCH_CONTENT);
+ }
+
+ @Test
+ public void exportSpecies() throws Exception {
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory);
+
+ try {
+ List<Species> allReferentSpecies =
+ persistenceService.getAllReferentSpecies();
+
+ Map<String, Species> allReferentSpeciesById =
+ TuttiEntities.splitById(allReferentSpecies);
+ exportContext.addSpecies(allReferentSpeciesById.get("35883"));
+ exportContext.addSpecies(allReferentSpeciesById.get("35884"));
+ exportContext.addSpecies(allReferentSpeciesById.get("19279"));
+
+ service.exportSpecies(exportContext,
+ exportContext.getSpeciesToExport());
+ } finally {
+ exportContext.close();
+ }
+ ServiceDbResource.assertFileContent("species export:\n",
+ exportContext.speciesFile,
+ SPECIES_CONTENT);
+ }
+
+}
Copied: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java (from rev 1366, trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/ExportCatchesReportServiceTest.java)
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java (rev 0)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,70 @@
+package fr.ifremer.tutti.service.export.pdf;
+
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.ServiceDbResource;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.Locale;
+
+/**
+ * Created on 11/19/13.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.10
+ */
+public class CatchesPdfExportServiceTest {
+
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.readDb("dbMedits");
+
+ public static final String PROGRAM_ID = "CAM-MEDITS";
+
+ public static final String CRUISE_ID = "100001";
+
+ public static final String OPERATION_1_ID = "100106";
+
+ protected CatchesPdfExportService exportService;
+
+ protected PersistenceService persistenceService;
+
+ protected File dataDirectory;
+
+ @Before
+ public void setUp() throws Exception {
+
+ dataDirectory = dbResource.getServiceConfig().getDataDirectory();
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ persistenceService = serviceContext.getService(PersistenceService.class);
+
+ serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
+ exportService = serviceContext.getService(CatchesPdfExportService.class);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void generateFishingOperationPDFFile() throws Exception {
+
+ File exportFile = new File(dataDirectory, "exportOperation.pdf");
+
+ Assert.assertFalse(exportFile.exists());
+
+ exportService.generateFishingOperationPDFFile(exportFile,
+ OPERATION_1_ID,
+ Locale.FRENCH);
+
+ Assert.assertTrue(exportFile.exists());
+ }
+}
Copied: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportServiceTest.java (from rev 1361, trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/CatchesSumatraExportServiceTest.java)
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportServiceTest.java (rev 0)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportServiceTest.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -0,0 +1,112 @@
+package fr.ifremer.tutti.service.export.sumatra;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $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.service.ServiceDbResource;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import fr.ifremer.tutti.service.catches.TuttiWeightComputingException;
+import fr.ifremer.tutti.service.export.sumatra.CatchesSumatraExportService;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import java.io.File;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.4
+ */
+public class CatchesSumatraExportServiceTest {
+
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.readDb("dbExport");
+
+ public static final String PROGRAM_ID = "CAM-TEST_ELEVATION";
+
+ public static final String CRUISE_BAD_ID = "100003";
+
+ public static final String CRUISE_ID = "100004";
+
+ public static final String OPERATION_1_ID = "100116";
+
+ public static final String OPERATION_BAD_1_ID = "100112";
+
+ public static final String OPERATION_BAD_2_ID = "100113";
+
+ public static final String OPERATION_BAD_3_ID = "100115";
+
+ public static final String EXPORT_CONTENT =
+ "Station;Espèce;Total;NbIndividus\n" +
+ "A;Chama magna;100.0;40;\n" +
+ "A;Echinogammarus;100.0;417;\n" +
+ "A;Brissopsis atlantica;100.0;94;";
+
+ protected CatchesSumatraExportService service;
+
+ protected ServiceDbResource.DataContext dataContext;
+
+ protected File dataDirectory;
+
+ @Before
+ public void setUp() throws Exception {
+
+ dataDirectory = dbResource.getServiceConfig().getDataDirectory();
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ dbResource.openDataContext();
+
+ service = serviceContext.getService(CatchesSumatraExportService.class);
+ }
+
+ @Test(expected = TuttiWeightComputingException.class)
+ public void testExportCruiseForSumatraBadCruise() throws Exception {
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_BAD_ID, 3,
+ OPERATION_BAD_2_ID,
+ OPERATION_BAD_1_ID,
+ OPERATION_BAD_3_ID);
+
+ File exportFile = new File(dataDirectory, "exportSumatra.csv");
+
+ service.exportCruiseForSumatra(exportFile, CRUISE_BAD_ID);
+ }
+
+ @Test
+ public void testExportCruiseForSumatra() throws Exception {
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 1,
+ OPERATION_1_ID);
+
+ File exportFile = new File(dataDirectory, "exportSumatra.csv");
+
+ service.exportCruiseForSumatra(exportFile, CRUISE_ID);
+
+ ServiceDbResource.assertFileContent("Sumatra export file:\n",
+ exportFile,
+ EXPORT_CONTENT);
+ }
+}
Deleted: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/CatchesSumatraExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/CatchesSumatraExportServiceTest.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/CatchesSumatraExportServiceTest.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -1,111 +0,0 @@
-package fr.ifremer.tutti.service.sumatra;
-
-/*
- * #%L
- * Tutti :: Service
- * $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.service.ServiceDbResource;
-import fr.ifremer.tutti.service.TuttiServiceContext;
-import fr.ifremer.tutti.service.catches.TuttiWeightComputingException;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-import java.io.File;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- */
-public class CatchesSumatraExportServiceTest {
-
- @ClassRule
- public static final ServiceDbResource dbResource =
- ServiceDbResource.readDb("dbExport");
-
- public static final String PROGRAM_ID = "CAM-TEST_ELEVATION";
-
- public static final String CRUISE_BAD_ID = "100003";
-
- public static final String CRUISE_ID = "100004";
-
- public static final String OPERATION_1_ID = "100116";
-
- public static final String OPERATION_BAD_1_ID = "100112";
-
- public static final String OPERATION_BAD_2_ID = "100113";
-
- public static final String OPERATION_BAD_3_ID = "100115";
-
- public static final String EXPORT_CONTENT =
- "Station;Espèce;Total;NbIndividus\n" +
- "A;Chama magna;100.0;40;\n" +
- "A;Echinogammarus;100.0;417;\n" +
- "A;Brissopsis atlantica;100.0;94;";
-
- protected CatchesSumatraExportService service;
-
- protected ServiceDbResource.DataContext dataContext;
-
- protected File dataDirectory;
-
- @Before
- public void setUp() throws Exception {
-
- dataDirectory = dbResource.getServiceConfig().getDataDirectory();
-
- TuttiServiceContext serviceContext = dbResource.getServiceContext();
-
- dbResource.openDataContext();
-
- service = serviceContext.getService(CatchesSumatraExportService.class);
- }
-
- @Test(expected = TuttiWeightComputingException.class)
- public void testExportCruiseForSumatraBadCruise() throws Exception {
-
- dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_BAD_ID, 3,
- OPERATION_BAD_2_ID,
- OPERATION_BAD_1_ID,
- OPERATION_BAD_3_ID);
-
- File exportFile = new File(dataDirectory, "exportSumatra.csv");
-
- service.exportCruiseForSumatra(exportFile, CRUISE_BAD_ID);
- }
-
- @Test
- public void testExportCruiseForSumatra() throws Exception {
-
- dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 1,
- OPERATION_1_ID);
-
- File exportFile = new File(dataDirectory, "exportSumatra.csv");
-
- service.exportCruiseForSumatra(exportFile, CRUISE_ID);
-
- ServiceDbResource.assertFileContent("Sumatra export file:\n",
- exportFile,
- EXPORT_CONTENT);
- }
-}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -38,19 +38,19 @@
import fr.ifremer.tutti.service.TuttiDataContext;
import fr.ifremer.tutti.service.TuttiServiceContext;
import fr.ifremer.tutti.service.ValidationService;
-import fr.ifremer.tutti.service.catches.ExportCatchesReportService;
+import fr.ifremer.tutti.service.export.pdf.CatchesPdfExportService;
import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
import fr.ifremer.tutti.service.catches.WeightCleaningService;
import fr.ifremer.tutti.service.catches.WeightComputingService;
import fr.ifremer.tutti.service.catches.multipost.MultiPostExportService;
import fr.ifremer.tutti.service.catches.multipost.MultiPostImportService;
-import fr.ifremer.tutti.service.export.TuttiExportService;
+import fr.ifremer.tutti.service.export.generic.TuttiExportService;
import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
import fr.ifremer.tutti.service.pupitri.PupitriImportExportService;
import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
import fr.ifremer.tutti.service.referential.TuttiReferentialSynchronizeService;
import fr.ifremer.tutti.service.report.ReportService;
-import fr.ifremer.tutti.service.sumatra.CatchesSumatraExportService;
+import fr.ifremer.tutti.service.export.sumatra.CatchesSumatraExportService;
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.content.MainUI;
import fr.ifremer.tutti.ui.swing.util.TuttiErrorHelper;
@@ -563,8 +563,8 @@
return serviceContext.getService(ValidationService.class);
}
- public ExportCatchesReportService getGeneratePDFService() {
- return serviceContext.getService(ExportCatchesReportService.class);
+ public CatchesPdfExportService getGeneratePDFService() {
+ return serviceContext.getService(CatchesPdfExportService.class);
}
public TuttiExportService getTuttiExportService() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -28,7 +28,7 @@
import fr.ifremer.tutti.TuttiBusinessException;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.service.export.TuttiExportService;
+import fr.ifremer.tutti.service.export.generic.TuttiExportService;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -26,7 +26,7 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.service.sumatra.CatchesSumatraExportService;
+import fr.ifremer.tutti.service.export.sumatra.CatchesSumatraExportService;
import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
import org.apache.commons.logging.Log;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -29,7 +29,7 @@
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.service.export.TuttiExportService;
+import fr.ifremer.tutti.service.export.generic.TuttiExportService;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -27,7 +27,7 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.service.catches.ExportCatchesReportService;
+import fr.ifremer.tutti.service.export.pdf.CatchesPdfExportService;
import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
@@ -96,7 +96,7 @@
}
// export catches
- ExportCatchesReportService service =
+ CatchesPdfExportService service =
getContext().getGeneratePDFService();
service.generateCruisePDFFile(file, cruise.getId(), getConfig().getI18nLocale());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationForSumatraAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationForSumatraAction.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationForSumatraAction.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -27,7 +27,7 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.sumatra.CatchesSumatraExportService;
+import fr.ifremer.tutti.service.export.sumatra.CatchesSumatraExportService;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationReportAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationReportAction.java 2013-11-21 14:30:34 UTC (rev 1369)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationReportAction.java 2013-11-21 15:41:34 UTC (rev 1370)
@@ -27,7 +27,7 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.catches.ExportCatchesReportService;
+import fr.ifremer.tutti.service.export.pdf.CatchesPdfExportService;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -96,7 +96,7 @@
}
// export catches
- ExportCatchesReportService service =
+ CatchesPdfExportService service =
getContext().getGeneratePDFService();
service.generateFishingOperationPDFFile(file, fishingOperation.getId(), getConfig().getI18nLocale());
1
0
Author: tchemit
Date: 2013-11-21 15:30:34 +0100 (Thu, 21 Nov 2013)
New Revision: 1369
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1369
Log:
use last version of adagio
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-11-21 09:18:40 UTC (rev 1368)
+++ trunk/pom.xml 2013-11-21 14:30:34 UTC (rev 1369)
@@ -137,7 +137,7 @@
<slf4jVersion>1.7.5</slf4jVersion>
- <adagioVersion>3.4.0-1-SNAPSHOT</adagioVersion>
+ <adagioVersion>3.4.0-1</adagioVersion>
<birtVersion>4.2.1a</birtVersion>
<bluecoveVersion>2.1.0</bluecoveVersion>
1
0
r1368 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db
by tchemit@users.forge.codelutin.com 21 Nov '13
by tchemit@users.forge.codelutin.com 21 Nov '13
21 Nov '13
Author: tchemit
Date: 2013-11-21 10:18:40 +0100 (Thu, 21 Nov 2013)
New Revision: 1368
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1368
Log:
fix #3841: [TECH] Am?\195?\169lioration du d?\195?\169marrage de l'application (redirige vers la home)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-11-21 08:52:45 UTC (rev 1367)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-11-21 09:18:40 UTC (rev 1368)
@@ -32,6 +32,7 @@
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.content.SelectCruiseAction;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import org.apache.commons.logging.Log;
@@ -156,7 +157,7 @@
try {
getContext().setDbExist(true);
getContext().setDbLoaded(true);
- getHandler().reloadPersistenceService();
+ handler.reloadPersistenceService();
} catch (Exception e) {
if (log.isErrorEnabled()) {
@@ -164,7 +165,7 @@
}
// no more db
getContext().setDbLoaded(false);
- getHandler().reloadPersistenceService();
+ handler.reloadPersistenceService();
// could not load db
throw new TuttiBusinessException(_("tutti.dbManager.action.importdb.couldNotOpen"), e);
@@ -177,7 +178,7 @@
progressionModel.increments(_("tutti.importDb.step.checkSchemaVersion"));
TuttiPersistence persistenceService =
- getHandler().getPersistenceService();
+ handler.getPersistenceService();
dbVersion = persistenceService.getDbVersion();
@@ -215,7 +216,7 @@
message,
_("tutti.dbManager.action.upgradeDb.schema.to.update.message.help"));
int i = JOptionPane.showConfirmDialog(
- getHandler().getTopestUI(),
+ handler.getTopestUI(),
htmlMessage,
_("tutti.dbManager.title.schema.toupdate"),
JOptionPane.OK_CANCEL_OPTION,
@@ -243,7 +244,7 @@
message,
_("tutti.dbManager.action.upgradeDb.schema.too.high.help"));
int i = JOptionPane.showConfirmDialog(
- getHandler().getTopestUI(),
+ handler.getTopestUI(),
htmlMessage,
_("tutti.dbManager.title.schema.toupdate"),
JOptionPane.OK_CANCEL_OPTION,
@@ -264,7 +265,7 @@
// ------------------------------------------------------------------ //
progressionModel.increments(_("tutti.importDb.step.closeDb"));
- TuttiActionHelper.runInternalAction(getHandler(), CloseDbAction.class);
+ TuttiActionHelper.runInternalAction(handler, CloseDbAction.class);
return;
}
@@ -283,7 +284,7 @@
progressionModel.increments(message);
sendMessage(message);
- getHandler().getPersistenceService().updateSchema();
+ handler.getPersistenceService().updateSchema();
sendMessage(_("tutti.flash.info.db.schema.updated", dbVersion, applicationVersion));
}
@@ -301,6 +302,12 @@
log.debug("Check db context");
}
getContext().checkDbContext();
+
+ // ------------------------------------------------------------------ //
+ // --- change screen //
+ // ------------------------------------------------------------------ //
+
+ TuttiActionHelper.runInternalAction(handler, SelectCruiseAction.class);
}
@Override
1
0