Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
February 2013
- 6 participants
- 236 discussions
r468 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing
by tchemit@users.forge.codelutin.com 25 Feb '13
by tchemit@users.forge.codelutin.com 25 Feb '13
25 Feb '13
Author: tchemit
Date: 2013-02-25 17:39:38 +0100 (Mon, 25 Feb 2013)
New Revision: 468
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/468
Log:
fixes 2055: [TECH] Des erreurs se produisent sur les interfaces graphiques
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-02-25 16:02:11 UTC (rev 467)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-02-25 16:39:38 UTC (rev 468)
@@ -55,7 +55,8 @@
// override default exception management (after config init)
Thread.setDefaultUncaughtExceptionHandler(new TuttiExceptionHandler());
- System.setProperty("sun.awt.exception.handler", TuttiExceptionHandler.class.getName());
+ // See http://forge.codelutin.com/issues/2055
+ //System.setProperty("sun.awt.exception.handler", TuttiExceptionHandler.class.getName());
// Create configuration
TuttiApplicationConfig config =
1
0
r467 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species
by tchemit@users.forge.codelutin.com 25 Feb '13
by tchemit@users.forge.codelutin.com 25 Feb '13
25 Feb '13
Author: tchemit
Date: 2013-02-25 17:02:11 +0100 (Mon, 25 Feb 2013)
New Revision: 467
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/467
Log:
add icons + mnemonic on select species actions
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.jaxx
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.css 2013-02-25 15:51:17 UTC (rev 466)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.css 2013-02-25 16:02:11 UTC (rev 467)
@@ -28,4 +28,16 @@
property: selectedSpecies;
selectedItem: {model.getSelectedSpecies()};
data: {model.getSpecies()};
+}
+
+#cancelButton {
+ text: "tutti.action.cancel";
+ actionIcon: cancel;
+ mnemonic:A;
+}
+
+#validateButton {
+ text: "tutti.action.validate";
+ actionIcon: accept;
+ mnemonic:V;
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.jaxx 2013-02-25 15:51:17 UTC (rev 466)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.jaxx 2013-02-25 16:02:11 UTC (rev 467)
@@ -52,9 +52,9 @@
constructorParams='this' genericType='Species'/>
<JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'>
- <JButton id='cancelButton' text='tutti.action.cancel'
+ <JButton id='cancelButton'
onActionPerformed='model.setSelectedSpecies(null); handler.closeDialog(this)'/>
- <JButton id='validateButton' text='tutti.action.validate'
+ <JButton id='validateButton'
onActionPerformed='handler.closeDialog(this)'/>
</JPanel>
1
0
r466 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/util resources
by tchemit@users.forge.codelutin.com 25 Feb '13
by tchemit@users.forge.codelutin.com 25 Feb '13
25 Feb '13
Author: tchemit
Date: 2013-02-25 16:51:17 +0100 (Mon, 25 Feb 2013)
New Revision: 466
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/466
Log:
fixes #2008: [PROTOCOLE] Nom de protocole mal contr?\195?\180l?\195?\169
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiCollectionUniqueKeyValidator.java
Modified:
trunk/tutti-ui-swing/src/main/resources/validators.xml
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiCollectionUniqueKeyValidator.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiCollectionUniqueKeyValidator.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiCollectionUniqueKeyValidator.java 2013-02-25 15:51:17 UTC (rev 466)
@@ -0,0 +1,132 @@
+package fr.ifremer.tutti.ui.swing.util;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import org.nuiton.validator.xwork2.field.CollectionUniqueKeyValidator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * To fix a bug (will be moved back to nuiton-validator) (see
+ * http://nuiton.org/issues/2545)
+ *
+ * TODO Remove this when using nuiton-validator 2.6.10 and reuse the basic validator.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0.1
+ */
+public class TuttiCollectionUniqueKeyValidator extends CollectionUniqueKeyValidator {
+
+ @Override
+ public void validateWhenNotSkip(Object object) throws ValidationException {
+
+ if (keys == null || keys.length == 0) {
+ throw new ValidationException("no unique keys defined");
+ }
+
+ String fieldName = getFieldName();
+
+ Collection<?> col = getCollection(object);
+
+ if (log.isDebugEnabled()) {
+ log.debug("collection found : " + col);
+ }
+ Object againstBean = againstProperty == null ? null :
+ getFieldValue(againstProperty, object);
+
+ if (log.isDebugEnabled()) {
+ log.debug("againtBean = " + againstBean);
+ }
+ Integer againstIndex = (Integer) (againstIndexExpression == null ?
+ -1 :
+ getFieldValue(againstIndexExpression, object));
+ if (againstIndex == null) {
+ againstIndex = -1;
+ }
+
+ if (!againstMe && againstBean == null && col.size() < 2) {
+ // la liste ne contient pas deux entrées donc c'est valide
+ return;
+ }
+
+ if (againstMe) {
+ // try on this object
+ againstBean = object;
+ if (log.isDebugEnabled()) {
+ log.debug("againtBean from me = " + againstBean);
+ }
+ }
+
+
+ boolean answer = true;
+
+ Integer againstHashCode = againstBean == null ?
+ null : getUniqueKeyHashCode(againstBean);
+ if (log.isDebugEnabled()) {
+ log.debug("hash for new key " + againstHashCode);
+ }
+
+ if (againstHashCode == null && nullValueSkipped) {
+
+ // clef nulle, donc pas d'erreur vu que le flag a ete positionne
+ return;
+ }
+ List<Integer> hashCodes = new ArrayList<Integer>();
+
+ int index = 0;
+ for (Object o : col) {
+ Integer hash = getUniqueKeyHashCode(o);
+
+ if (log.isDebugEnabled()) {
+ log.debug("hash for object " + o + " = " + hash);
+ }
+
+ if (hash == null && nullValueSkipped) {
+
+ // clef nulle, donc pas d'erreur vu que le flag a ete positionne
+ continue;
+ }
+
+ if (againstBean == null) {
+ if (hashCodes.contains(hash)) {
+
+ // on a deja rencontre cette clef unique,
+ // donc la validation a echouee
+ answer = false;
+ if (log.isDebugEnabled()) {
+ log.debug("Found same hashcode, not unique!");
+ }
+ break;
+ }
+ } else {
+ // utilisation de againstBean
+ if (againstIndex != -1) {
+ if (index != againstIndex &&
+ hash.equals(againstHashCode)) {
+ // on a deja rencontre cette clef unique,
+ // donc la validation a echouee
+ answer = false;
+ break;
+ }
+ } else {
+ if (!againstBean.equals(o) &&
+ hash.equals(againstHashCode)) {
+ // on a deja rencontre cette clef unique,
+ // donc la validation a echouee
+ answer = false;
+ break;
+ }
+ }
+ }
+ // nouveau hashcode enregistre
+ hashCodes.add(hash);
+ // index suivant
+ index++;
+ }
+
+ if (!answer) {
+ addFieldError(fieldName, object);
+ }
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiCollectionUniqueKeyValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/resources/validators.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/validators.xml 2013-02-25 15:16:54 UTC (rev 465)
+++ trunk/tutti-ui-swing/src/main/resources/validators.xml 2013-02-25 15:51:17 UTC (rev 466)
@@ -42,7 +42,9 @@
<validator name="fieldexpression" class="com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"/>
<validator name="email" class="com.opensymphony.xwork2.validator.validators.EmailValidator"/>
- <validator name="collectionUniqueKey" class="org.nuiton.validator.xwork2.field.CollectionUniqueKeyValidator"/>
+ <!--TODO Remove this when using nuiton-validator 2.6.10 and reuse the basic validator.-->
+ <!--<validator name="collectionUniqueKey" class="org.nuiton.validator.xwork2.field.CollectionUniqueKeyValidator"/>-->
+ <validator name="collectionUniqueKey" class="fr.ifremer.tutti.ui.swing.util.TuttiCollectionUniqueKeyValidator"/>
<validator name="fieldexpressionwithparams" class="org.nuiton.validator.xwork2.field.FieldExpressionWithParamsValidator"/>
</validators>
1
0
r465 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service
by blavenier@users.forge.codelutin.com 25 Feb '13
by blavenier@users.forge.codelutin.com 25 Feb '13
25 Feb '13
Author: blavenier
Date: 2013-02-25 16:16:54 +0100 (Mon, 25 Feb 2013)
New Revision: 465
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/465
Log:
Fix :
- Keep rankrOrder in batchSpecies (refs #2004)
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-02-25 14:32:30 UTC (rev 464)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-02-25 15:16:54 UTC (rev 465)
@@ -615,6 +615,9 @@
// TODO BL : vérifier cela (est-ce que l'item est ajouté à son père AVANT d'être passé au service ?)
rankOrder += (short) source.getParentBatch().getChildBatchs().size();
}
+ else if (target.getParentBatch() != null && target.getParentBatch().getChildBatchs() != null){
+ rankOrder += (short) target.getParentBatch().getChildBatchs().size();
+ }
target.setRankOrder(rankOrder);
}
1
0
See <http://ci.nuiton.org/jenkins/job/tutti/380/changes>
Changes:
[blavenier] ref refs #1936: [CAPTURE] - Espèce - pouvoir changer le nom d'une espèce
- Add changeSpeciesBatchSpecies() implementation
Fix :
- Fix save/retrieve of qualitative value on operation (refs #2028)
Add :
- Ajout de la conversion possible d'un arbre d'échantillonnage (refs #1997)
------------------------------------------
Started by an SCM change
Building on master in workspace <http://ci.nuiton.org/jenkins/job/tutti/ws/>
Updating http://svn.forge.codelutin.com/svn/tutti/trunk to revision '2013-02-25T15:17:03.947 +0100'
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
A tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch
A tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
A tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch
A tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java
U tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java
U tutti-persistence/pom.xml
U tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
U pom.xml
At revision 461
Parsing POMs
Modules changed, recalculating dependency graph
[trunk] $ /opt/jdk/bin/java -Xmx256m -XX:-UseGCOverheadLimit -cp /var/local/jenkins/data/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.2.jar:/opt/maven3/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /opt/maven3 /opt/repo/apache-tomcat-7.0.34/webapps/jenkins/WEB-INF/lib/remoting-2.20.jar /var/local/jenkins/data/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.2.jar 48065
<===[JENKINS REMOTING CAPACITY]===> channel started
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven: -B -f <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml> -U -e clean install
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Tutti
[INFO] Tutti :: Persistence
[INFO] Tutti :: Service
[INFO] Tutti :: UI
Projects to build: [MavenProject: fr.ifremer:tutti:1.1-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-persistence:1.1-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-service:1.1-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-service/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-ui-swing:1.1-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-ui-swing/pom.xml]>
projectStarted fr.ifremer:tutti:1.1-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti 1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
mojoStarted org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tutti ---
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target>
mojoSucceeded org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
mojoStarted org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (check-project-files) @ tutti ---
mojoSucceeded org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
mojoStarted org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir)
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ tutti ---
[INFO] Executing tasks
mojoSucceeded org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir)
main:
[mkdir] Created dir: <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/surefire-workdir>
[INFO] Executed tasks
mojoStarted org.apache.maven.plugins:maven-site-plugin:3.2(attach-descriptor)
[INFO]
[INFO] --- maven-site-plugin:3.2:attach-descriptor (attach-descriptor) @ tutti ---
mojoSucceeded org.apache.maven.plugins:maven-site-plugin:3.2(attach-descriptor)
mojoStarted org.apache.maven.plugins:maven-install-plugin:2.4(default-install)
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ tutti ---
[INFO] Installing <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml> to /var/local/maven/data/repository/fr/ifremer/tutti/1.1-SNAPSHOT/tutti-1.1-SNAPSHOT.pom
[INFO] Installing <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/tutti-1.1-SNAPSHOT-s…> to /var/local/maven/data/repository/fr/ifremer/tutti/1.1-SNAPSHOT/tutti-1.1-SNAPSHOT-site_fr.xml
mojoSucceeded org.apache.maven.plugins:maven-install-plugin:2.4(default-install)
projectSucceeded fr.ifremer:tutti:1.1-SNAPSHOT
projectStarted fr.ifremer.tutti:tutti-persistence:1.1-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti :: Persistence 1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/fr/ifremer/adagio/adagi…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/… (2 KB at 4.7 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/fr/ifremer/adagio/adagi…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/… (600 B at 7.9 KB/sec)
mojoStarted org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tutti-persistence ---
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target>
mojoSucceeded org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
mojoStarted org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (check-project-files) @ tutti-persistence ---
mojoSucceeded org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
mojoStarted org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
[INFO]
[INFO] --- eugene-maven-plugin:2.6.1:generate (default) @ tutti-persistence ---
[INFO] Process phase [zargo] for one entry.
[INFO] Expanding 1 xmi file(s) from <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…> to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Generate one file in 30.515ms.
[INFO] Process phase [xmi] for one entry.
[INFO] Processing XSL tranformation on <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…> for 1 file(s).
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…> to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Generate one file in 2.242s.
[INFO] Process phase [model] for one entry.
INFO [pool-1-thread-1] (ObjectModelReader.java:273) loadModelProperties - 19 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Apply generator JavaInterfaceTransformer
[INFO] Apply generator SimpleJavaBeanTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:911) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.Program], already found in class-path.
[INFO] Apply generator JavaEnumerationTransformer
[INFO] No file generated.
[INFO] Add compile source root : <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Add resource root :Resource {targetPath: null, filtering: false, FileSet {directory: <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…,> PatternSet [includes: {}, excludes: {**/*.java}]}}
mojoSucceeded org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:parserJava (scan-sources) @ tutti-persistence ---
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
forkedProjectStarted fr.ifremer.tutti:tutti-persistence:1.1-SNAPSHOT
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(get)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:get (get) @ tutti-persistence ---
[INFO] Copying tutti-persistence.properties to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(get)
forkedProjectSucceeded fr.ifremer.tutti:tutti-persistence:1.1-SNAPSHOT
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:gen (scan-sources) @ tutti-persistence ---
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
mojoStarted org.apache.maven.plugins:maven-resources-plugin:2.6(default-resources)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tutti-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 11 resources
[INFO] Copying 0 resource
mojoSucceeded org.apache.maven.plugins:maven-resources-plugin:2.6(default-resources)
mojoStarted org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ tutti-persistence ---
[INFO] Compiling 85 source files to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/cl…>
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] bootstrap class path not set in conjunction with -source 1.6
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[450,81] error: unmappable character for encoding UTF-8
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[450,87] error: unmappable character for encoding UTF-8
[INFO] 2 errors
[INFO] -------------------------------------------------------------
mojoFailed org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)
projectFailed fr.ifremer.tutti:tutti-persistence:1.1-SNAPSHOT
sessionEnded
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Tutti ............................................. SUCCESS [6.044s]
[INFO] Tutti :: Persistence .............................. FAILURE [8.234s]
[INFO] Tutti :: Service .................................. SKIPPED
[INFO] Tutti :: UI ....................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.737s
[INFO] Finished at: Mon Feb 25 15:17:26 CET 2013
[INFO] Final Memory: 23M/114M
[INFO] ------------------------------------------------------------------------
Projects to build: [MavenProject: fr.ifremer:tutti:1.1-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-persistence:1.1-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-service:1.1-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-service/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-ui-swing:1.1-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-ui-swing/pom.xml]>
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-service/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer.tutti$tutti-service/builds/2013-02-25_15-17-06/archive/fr.ifremer.tutti/tutti-service/1.1-SNAPSHOT/tutti-service-1.1-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-ui-swing/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer.tutti$tutti-ui-swing/builds/2013-02-25_15-17-06/archive/fr.ifremer.tutti/tutti-ui-swing/1.1-SNAPSHOT/tutti-ui-swing-1.1-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer$tutti/builds/2013-02-25_15-17-06/archive/fr.ifremer/tutti/1.1-SNAPSHOT/tutti-1.1-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/tutti-1.1-SNAPSHOT-s…> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer$tutti/builds/2013-02-25_15-17-06/archive/fr.ifremer/tutti/1.1-SNAPSHOT/tutti-1.1-SNAPSHOT-site_fr.xml
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer.tutti$tutti-persistence/builds/2013-02-25_15-17-06/archive/fr.ifremer.tutti/tutti-persistence/1.1-SNAPSHOT/tutti-persistence-1.1-SNAPSHOT.pom
Waiting for Jenkins to finish collecting data
mavenExecutionResult exceptions not empty
message : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project tutti-persistence: Compilation failure
cause : Compilation failure
Stack trace :
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project tutti-persistence: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:729)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 27 more
Sending e-mails to: tutti-commits(a)list.forge.codelutin.com benoit.lavenier(a)e-is.pro
channel stopped
1
3
25 Feb '13
See <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/3…>
Changes:
[blavenier] ref refs #1936: [CAPTURE] - Espèce - pouvoir changer le nom d'une espèce
- Add changeSpeciesBatchSpecies() implementation
Fix :
- Fix save/retrieve of qualitative value on operation (refs #2028)
Add :
- Ajout de la conversion possible d'un arbre d'échantillonnage (refs #1997)
------------------------------------------
projectStarted fr.ifremer.tutti:tutti-persistence:1.1-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti :: Persistence 1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/fr/ifremer/adagio/adagi…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/… (2 KB at 4.7 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/fr/ifremer/adagio/adagi…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/… (600 B at 7.9 KB/sec)
mojoStarted org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tutti-persistence ---
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
mojoSucceeded org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
mojoStarted org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (check-project-files) @ tutti-persistence ---
mojoSucceeded org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
mojoStarted org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
[INFO]
[INFO] --- eugene-maven-plugin:2.6.1:generate (default) @ tutti-persistence ---
[INFO] Process phase [zargo] for one entry.
[INFO] Expanding 1 xmi file(s) from <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Generate one file in 30.515ms.
[INFO] Process phase [xmi] for one entry.
[INFO] Processing XSL tranformation on <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> for 1 file(s).
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Generate one file in 2.242s.
[INFO] Process phase [model] for one entry.
INFO [pool-1-thread-1] (ObjectModelReader.java:273) loadModelProperties - 19 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Apply generator JavaInterfaceTransformer
[INFO] Apply generator SimpleJavaBeanTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:911) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.Program], already found in class-path.
[INFO] Apply generator JavaEnumerationTransformer
[INFO] No file generated.
[INFO] Add compile source root : <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Add resource root :Resource {targetPath: null, filtering: false, FileSet {directory: <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…,> PatternSet [includes: {}, excludes: {**/*.java}]}}
mojoSucceeded org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:parserJava (scan-sources) @ tutti-persistence ---
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
forkedProjectStarted fr.ifremer.tutti:tutti-persistence:1.1-SNAPSHOT
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(get)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:get (get) @ tutti-persistence ---
[INFO] Copying tutti-persistence.properties to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(get)
forkedProjectSucceeded fr.ifremer.tutti:tutti-persistence:1.1-SNAPSHOT
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:gen (scan-sources) @ tutti-persistence ---
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
mojoStarted org.apache.maven.plugins:maven-resources-plugin:2.6(default-resources)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tutti-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 11 resources
[INFO] Copying 0 resource
mojoSucceeded org.apache.maven.plugins:maven-resources-plugin:2.6(default-resources)
mojoStarted org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ tutti-persistence ---
[INFO] Compiling 85 source files to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] bootstrap class path not set in conjunction with -source 1.6
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[450,81] error: unmappable character for encoding UTF-8
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[450,87] error: unmappable character for encoding UTF-8
[INFO] 2 errors
[INFO] -------------------------------------------------------------
mojoFailed org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)
projectFailed fr.ifremer.tutti:tutti-persistence:1.1-SNAPSHOT
1
3
r464 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service tutti-persistence/src/main/resources tutti-service/src/main/java/fr/ifremer/tutti/service tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program
by tchemit@users.forge.codelutin.com 25 Feb '13
by tchemit@users.forge.codelutin.com 25 Feb '13
25 Feb '13
Author: tchemit
Date: 2013-02-25 15:32:30 +0100 (Mon, 25 Feb 2013)
New Revision: 464
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/464
Log:
fixes #2037: [CAMPAGNE] - Gestion des campagnes - Information affich?\195?\169e erron?\195?\169e pour la zone de la campagne
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.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-02-25 14:32:11 UTC (rev 463)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-02-25 14:32:30 UTC (rev 464)
@@ -236,8 +236,23 @@
//-- Program methods --//
//------------------------------------------------------------------------//
+ /**
+ * Get all programs.
+ * <p/>
+ * <strong>Note:</strong> For each program, his zone is loaded.
+ *
+ * @return the list of programs found in db.
+ */
List<Program> getAllProgram();
+ /**
+ * Get the program for the given {@code id}.
+ * <p/>
+ * <strong>Note:</strong> his zone is loaded.
+ *
+ * @param id id of the program to load
+ * @return the loaded program
+ */
Program getProgram(String id);
@Transactional(readOnly = false)
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceService.java 2013-02-25 14:32:11 UTC (rev 463)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceService.java 2013-02-25 14:32:30 UTC (rev 464)
@@ -39,8 +39,23 @@
@Transactional(readOnly = true)
public interface ProgramPersistenceService extends TuttiPersistenceServiceImplementor {
+ /**
+ * Get all programs.
+ * <p/>
+ * <strong>Note:</strong> For each program, his zone is loaded.
+ *
+ * @return the list of programs found in db.
+ */
List<Program> getAllProgram();
+ /**
+ * Get the program for the given {@code id}.
+ * <p/>
+ * <strong>Note:</strong> his zone is loaded.
+ *
+ * @param id id of the program to load
+ * @return the loaded program
+ */
Program getProgram(String id);
@Transactional(readOnly = false)
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceServiceImpl.java 2013-02-25 14:32:11 UTC (rev 463)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceServiceImpl.java 2013-02-25 14:32:30 UTC (rev 464)
@@ -75,15 +75,18 @@
if (enumeration.PROGRAM_CODE_SCIENTIFIC_CRUISE_PREFIX != null) {
codePattern = enumeration.PROGRAM_CODE_SCIENTIFIC_CRUISE_PREFIX + codePattern;
}
- Iterator<Object[]> list = queryList("allPrograms",
- "codePattern", StringType.INSTANCE, codePattern
+ Iterator<Object[]> list = queryList(
+ "allPrograms",
+ "codePattern", StringType.INSTANCE, codePattern,
+ "locationLevelId", IntegerType.INSTANCE, enumeration.LOCATION_LEVEL_ID_PROGRAM,
+ "locationClassificationId", IntegerType.INSTANCE, enumeration.LOCATION_CLASSIFICATION_ID_SECTOR
);
List<Program> result = Lists.newArrayList();
while (list.hasNext()) {
Object[] source = list.next();
Program target = new Program();
- loadProgram(target, source, false);
+ loadProgram(target, source);
result.add(target);
}
return result;
@@ -105,7 +108,7 @@
Object[] source = list.next();
result = new Program();
- loadProgram(result, source, true);
+ loadProgram(result, source);
} else {
result = null;
}
@@ -161,14 +164,14 @@
*/
public static final String EMPTY_COMMENT = "$$EMPTY_COMMENT$$";
- protected void loadProgram(Program result, Object[] source, boolean loadZone) {
+ protected void loadProgram(Program result, Object[] source) {
result.setId((String) source[0]);
result.setName((String) source[1]);
result.setComment((String) source[2]);
if (EMPTY_COMMENT.equals(result.getComment())) {
result.setComment(null);
}
- if (loadZone && source[3] != null) {
+ if (source[3] != null) {
Zone zone = new Zone();
zone.setId(String.valueOf(source[3]));
zone.setLabel((String) source[4]);
Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-25 14:32:11 UTC (rev 463)
+++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-25 14:32:30 UTC (rev 464)
@@ -37,12 +37,25 @@
SELECT
p.code,
p.name,
- p.description
+ p.description,
+ l.id,
+ l.label,
+ l.name
FROM
ProgramImpl p
+ LEFT OUTER JOIN p.locations l
WHERE
p.code LIKE :codePattern
+ AND (
+ l is null OR (
+ l.locationLevel.id = :locationLevelId
+ AND l.locationClassification.id = :locationClassificationId
+ )
+ )
]]>
+ <query-param name="codePattern" type="java.lang.String"/>
+ <query-param name="locationLevelId" type="java.lang.Integer"/>
+ <query-param name="locationClassificationId" type="java.lang.Integer"/>
</query>
<!-- [DAT-02] Get all cruises for a given program (to list with no detail) -->
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-02-25 14:32:11 UTC (rev 463)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-02-25 14:32:30 UTC (rev 464)
@@ -115,69 +115,8 @@
}
} else {
- // still on dev driver
-
-// File storageDirectory = TuttiPersistenceDevImpl.getStorageDirectory(serviceConfig.getApplicationConfig());
-
-// if (log.isWarnEnabled()) {
-//
-// log.warn("--------------------------------------------------------------------");
-// log.warn("");
-// log.warn("Could not find database directory at " + config.getDbDirectory());
-// log.warn("Will still use dev dataStorage in " + storageDirectory);
-// log.warn("");
-// log.warn("--------------------------------------------------------------------");
-// }
-
driver = new TuttiPersistenceNoDbImpl();
-// driver = new TuttiPersistenceDevImpl(serviceConfig.getApplicationConfig()) {
-//
-// ProtocolPersistenceService protocolPersistenceService = new ProtocolPersistenceServiceImpl();
-//
-// @Override
-// public void init() {
-// super.init();
-//
-// protocolPersistenceService.init();
-// }
-//
-// @Override
-// public boolean isProtocolExist(String id) {
-// return protocolPersistenceService.isProtocolExist(id);
-// }
-//
-// @Override
-// public List<String> getAllProtocolNames() {
-// return protocolPersistenceService.getAllProtocolNames();
-// }
-//
-// @Override
-// public List<TuttiProtocol> getAllProtocol() {
-// return protocolPersistenceService.getAllProtocol();
-// }
-//
-// @Override
-// public TuttiProtocol getProtocol(String id) {
-// return protocolPersistenceService.getProtocol(id);
-// }
-//
-// @Override
-// public TuttiProtocol createProtocol(TuttiProtocol bean) {
-// return protocolPersistenceService.createProtocol(bean);
-// }
-//
-// @Override
-// public TuttiProtocol saveProtocol(TuttiProtocol bean) {
-// return protocolPersistenceService.saveProtocol(bean);
-// }
-//
-// @Override
-// public void deleteProtocol(String id) {
-// protocolPersistenceService.deleteProtocol(id);
-// }
-// };
-
if (log.isInfoEnabled()) {
log.info("Will open persistence driver " +
driver.getImplementationName());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2013-02-25 14:32:11 UTC (rev 463)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2013-02-25 14:32:30 UTC (rev 464)
@@ -73,15 +73,7 @@
public void beforeInitUI() {
SelectCruiseUIModel model = new SelectCruiseUIModel();
- //TODO TC: shoudl have program with their zone here directly
List<Program> programs = persistenceService.getAllProgram();
- List<Program> loadedPrograms =
- Lists.newArrayListWithCapacity(programs.size());
- for (Program program : programs) {
- loadedPrograms.add(persistenceService.getProgram(program.getId()));
- }
- programs = loadedPrograms;
-
model.setPrograms(programs);
if (programs.isEmpty()) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2013-02-25 14:32:11 UTC (rev 463)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2013-02-25 14:32:30 UTC (rev 464)
@@ -24,7 +24,6 @@
* #L%
*/
-import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
@@ -72,13 +71,9 @@
//TODO 20130206 kmorin put the programs loaded in the home screen in a
//kind of context to avoid loading the programs again
List<Program> programs = persistenceService.getAllProgram();
- List<Program> loadedPrograms =
- Lists.newArrayListWithCapacity(programs.size());
- for (Program program : programs) {
- loadedPrograms.add(persistenceService.getProgram(program.getId()));
- }
- model.setExistingPrograms(loadedPrograms);
+ model.setExistingPrograms(programs);
+
String surveyId = context.getProgramId();
if (surveyId == null) {
1
0
r463 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence
by blavenier@users.forge.codelutin.com 25 Feb '13
by blavenier@users.forge.codelutin.com 25 Feb '13
25 Feb '13
Author: blavenier
Date: 2013-02-25 15:32:11 +0100 (Mon, 25 Feb 2013)
New Revision: 463
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/463
Log:
remove some no - UTF-8 caracters
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-02-25 14:30:44 UTC (rev 462)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-02-25 14:32:11 UTC (rev 463)
@@ -447,7 +447,7 @@
try {
return catchBatchService.getCatchBatchFromFishingOperation(id, true);
} catch (CatchBatchValidationException e) {
- // TODO Code lutin : throw exception and ask user : "Voulez convertir les donn�es d'�chantillonnage dans un format compatible tutti ?"
+ // TODO Code lutin : throw exception and ask user : "Voulez convertir les donnees d'echantillonnage dans un format compatible tutti ?"
e.printStackTrace();
return null;
}
1
0
r462 - in trunk/tutti-persistence/src: main/java/fr/ifremer/tutti/persistence test/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 25 Feb '13
by tchemit@users.forge.codelutin.com 25 Feb '13
25 Feb '13
Author: tchemit
Date: 2013-02-25 15:30:44 +0100 (Mon, 25 Feb 2013)
New Revision: 462
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/462
Log:
remove dev persistence implementation
Removed:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java
Modified:
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java
Deleted: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2013-02-25 14:11:54 UTC (rev 461)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2013-02-25 14:30:44 UTC (rev 462)
@@ -1,1470 +0,0 @@
-package fr.ifremer.tutti.persistence;
-
-/*
- * #%L
- * Tutti :: Persistence Dev (impl)
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.entities.AbstractTuttiEntity;
-import fr.ifremer.tutti.persistence.entities.IdAware;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
-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.FishingOperationAware;
-import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch;
-import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
-import fr.ifremer.tutti.persistence.entities.referential.Country;
-import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Person;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import fr.ifremer.tutti.persistence.entities.referential.Zone;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.ApplicationConfig;
-import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderFactory;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-/**
- * Persistence service implementation for dev purpose (no real db).
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class TuttiPersistenceDevImpl implements TuttiPersistence {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(TuttiPersistenceDevImpl.class);
-
- public enum CaracteristicEnum {
- All,
- SizeCategory,
- SexCategory,
- SortedUnsortedCategory,
- MaturityCategory,
- MacroWasteCategory,
- MacroWasteSizeCategory
- }
-
- public static final List<String> FILE_KEYS = Lists.newArrayList(
- "fr.ifremer.tutti.persistence.entities.data.Attachment",
- "fr.ifremer.tutti.persistence.entities.data.AccidentalBatch",
- "fr.ifremer.tutti.persistence.entities.data.BenthosBatch",
- "fr.ifremer.tutti.persistence.entities.data.FishingOperation",
- "fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch",
- "fr.ifremer.tutti.persistence.entities.data.PlanktonBatch",
- "fr.ifremer.tutti.persistence.entities.data.Program",
- "fr.ifremer.tutti.persistence.entities.data.Cruise",
- "fr.ifremer.tutti.persistence.entities.data.CatchBatch",
- "fr.ifremer.tutti.persistence.entities.data.SpeciesBatch",
- "fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency",
- "fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol",
- "fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue",
- "fr.ifremer.tutti.persistence.entities.referential.Country",
- "fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation#Strata",
- "fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation#SubStrata",
- "fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation#Localite",
- "fr.ifremer.tutti.persistence.entities.referential.Gear#Scientific",
- "fr.ifremer.tutti.persistence.entities.referential.Gear#Fishing",
- "fr.ifremer.tutti.persistence.entities.referential.Person",
- "fr.ifremer.tutti.persistence.entities.referential.Species",
- "fr.ifremer.tutti.persistence.entities.referential.Vessel#Scientific",
- "fr.ifremer.tutti.persistence.entities.referential.Vessel#Fishing",
- "fr.ifremer.tutti.persistence.entities.referential.Zone"
- );
-
- static {
- for (CaracteristicEnum caracteristicEnum :
- CaracteristicEnum.values()) {
- FILE_KEYS.add(getKey(Caracteristic.class, caracteristicEnum.name()));
- }
-
- if (log.isInfoEnabled()) {
- log.info("Found " + FILE_KEYS.size() + " files.");
- }
- }
-
- public static final String SKIP_FIXTURES_OPTION = "LoadFixtures";
-
- public static final Function<TuttiProtocol, String> GET_PROTOCOL_NAME = new Function<TuttiProtocol, String>() {
-
- @Override
- public String apply(TuttiProtocol input) {
- return input.getName();
- }
- };
-
- /**
- * Persistence config.
- *
- * @since 0.1
- */
- protected final ApplicationConfig config;
-
- /**
- * Cache of data.
- *
- * @since 0.1
- */
- protected final ArrayListMultimap<String, IdAware> cache = ArrayListMultimap.create();
-
- /**
- * Cache of binder.
- *
- * @since 0.2
- */
- protected final Map<String, Binder<? extends IdAware, ? extends IdAware>> binderCache = Maps.newHashMap();
-
-
- protected final File storageDirectory;
-
-
- public static File getStorageDirectory(ApplicationConfig config) {
- return new File(config.getOptionAsFile("tutti.data.directory"), "devStorage");
- }
-
- public TuttiPersistenceDevImpl(ApplicationConfig config) {
-
- Preconditions.checkNotNull(config, " No config property setted");
-
- this.config = config;
-
- this.storageDirectory = getStorageDirectory(this.config);
- }
-
- //------------------------------------------------------------------------//
- //-- Technical methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public String getImplementationName() {
- return "Persistence Dev implementation";
- }
-
- @Override
- public void init() {
-
- try {
-
- FileUtils.forceMkdir(storageDirectory);
- } catch (IOException e) {
- throw new RuntimeException("Could not create directory", e);
- }
-
- cache.clear();
-
- boolean loadFixtures =
- config.getOptionAsBoolean(SKIP_FIXTURES_OPTION);
- if (!loadFixtures) {
-
- if (log.isInfoEnabled()) {
- log.info("Load default fixtures...");
- }
- TuttiPersistenceDevFixtures fixtures =
- new TuttiPersistenceDevFixtures();
-
- for (String entityType : FILE_KEYS) {
- try {
- loadEntities(entityType, fixtures);
- } catch (IOException e) {
- throw new RuntimeException("Could not load entities " + entityType, e);
- }
- }
- }
- }
-
- @Override
- public void close() throws IOException {
-
- if (log.isInfoEnabled()) {
- log.info("Close persistence driver " + getImplementationName());
- }
- binderCache.clear();
-
- for (String entityType : cache.keySet()) {
- persistToFile(entityType);
- }
- }
-
- //------------------------------------------------------------------------//
- //-- Referential methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<Species> getAllSpecies() {
- List<Species> result = getDataInNewList(Species.class.getName());
- return result;
- }
-
- @Override
- public List<Species> getAllReferentSpecies() {
- throw new IllegalStateException("method 'getAllReferentSpecies' not implemented");
- }
-
- @Override
- public List<Species> getAllSpecies(TuttiProtocol protocol) {
- List<Species> result = getAllSpecies();
- if (protocol != null && !protocol.isSpeciesEmpty()) {
- Map<String, Species> map = TuttiEntities.splitById(result);
- for (SpeciesProtocol speciesProtocol : protocol.getSpecies()) {
- map.get(speciesProtocol.getSpeciesReferenceTaxonId()).setSurveyCode(speciesProtocol.getSpeciesSurveyCode());
- }
- }
- return result;
- }
-
- @Override
- public List<Caracteristic> getAllCaracteristic() {
- List<Caracteristic> result = getAllCaracteristic(CaracteristicEnum.All);
- return result;
- }
-
- @Override
- public List<Zone> getAllProgramZone() {
- List<Zone> result = getDataInNewList(Zone.class.getName());
- return result;
- }
-
- @Override
- public List<Country> getAllCountry() {
- List<Country> result = getDataInNewList(Country.class.getName());
- return result;
- }
-
- @Override
- public List<FishingOperationLocation> getAllFishingOperationStrata(String zoneId) {
- List<FishingOperationLocation> result = getDataInNewList(getKey(FishingOperationLocation.class, "Strata"));
- return result;
- }
-
- @Override
- public List<FishingOperationLocation> getAllFishingOperationSubStrata(String zoneId, String strataId) {
- List<FishingOperationLocation> result = getDataInNewList(getKey(FishingOperationLocation.class, "SubStrata"));
- return result;
- }
-
- @Override
- public List<FishingOperationLocation> getAllFishingOperationLocation(String zoneId, String strataId, String subStrataId) {
- List<FishingOperationLocation> result = getDataInNewList(getKey(FishingOperationLocation.class, "Localite"));
- return result;
- }
-
- @Override
- public List<Vessel> getAllScientificVessel() {
- List<Vessel> result = getDataInNewList(getKey(Vessel.class, "Scientific"));
- return result;
- }
-
- @Override
- public List<Vessel> getAllFishingVessel() {
- List<Vessel> result = getDataInNewList(getKey(Vessel.class, "Fishing"));
- return result;
- }
-
- @Override
- public List<Gear> getAllScientificGear() {
- List<Gear> result = getDataInNewList(getKey(Gear.class, "Scientific"));
- return result;
- }
-
- @Override
- public List<Gear> getAllFishingGear() {
- List<Gear> result = getDataInNewList(getKey(Gear.class, "Fishing"));
- return result;
- }
-
- @Override
- public List<Person> getAllPerson() {
- List<Person> result = getDataInNewList(Person.class.getName());
- return result;
- }
-
- @Override
- public Caracteristic getSizeCategoryCaracteristic() {
- return getCaracteristic(CaracteristicEnum.SizeCategory);
- }
-
- @Override
- public Caracteristic getSexCaracteristic() {
- return getCaracteristic(CaracteristicEnum.SexCategory);
- }
-
- @Override
- public Caracteristic getSortedUnsortedCaracteristic() {
- return getCaracteristic(CaracteristicEnum.SortedUnsortedCategory);
- }
-
- @Override
- public Caracteristic getMaturityCaracteristic() {
- return getCaracteristic(CaracteristicEnum.MaturityCategory);
- }
-
- @Override
- public Caracteristic getMacroWasteCategoryCaracteristic() {
- return getCaracteristic(CaracteristicEnum.MacroWasteCategory);
- }
-
- @Override
- public Caracteristic getMacroWasteSizeCategoryCaracteristic() {
- return getCaracteristic(CaracteristicEnum.MacroWasteSizeCategory);
- }
-
- @Override
- public Vessel getVessel(String vesselCode) {
- return getBean(Vessel.class.getName(), vesselCode);
- }
-
- @Override
- public Person getPerson(Integer personId) {
- return getBean(Person.class.getName(), personId.toString());
- }
-
- @Override
- public Gear getGear(Integer gearCode) {
- return getBean(Gear.class.getName(), gearCode.toString());
- }
-
- @Override
- public boolean isSortedQualitativeValue(CaracteristicQualitativeValue value) {
- return value != null && value.getId().equals("311");
- }
-
- @Override
- public List<Species> importTemporarySpecies(List<Species> species) {
- throw new IllegalStateException("method 'importTemporarySpecies' not implemented");
- }
-
- @Override
- public List<Vessel> importTemporaryVessel(List<Vessel> vessels) {
- throw new IllegalStateException("method 'importTemporaryVessel' not implemented");
- }
-
- @Override
- public List<Person> importTemporaryPerson(List<Person> persons) {
- throw new IllegalStateException("method 'importTemporaryPerson' not implemented");
- }
-
- @Override
- public List<Gear> importTemporaryGear(List<Gear> gears) {
- throw new IllegalStateException("method 'importTemporaryGear' not implemented");
- }
-
- //------------------------------------------------------------------------//
- //-- Program methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<Program> getAllProgram() {
- List<Program> result = getDataInNewList(Program.class.getName());
- return result;
- }
-
- @Override
- public Program getProgram(String id) {
- Program result = getBean(Program.class.getName(), id);
- return result;
- }
-
- @Override
- public Program createProgram(Program bean) {
- Program result = create(Program.class.getName(), bean);
- return result;
- }
-
- @Override
- public Program saveProgram(Program bean) {
- Program result = save(Program.class.getName(), bean);
- return result;
- }
-
- //------------------------------------------------------------------------//
- //-- Cruise methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<Cruise> getAllCruise(final String programId) {
- List<Cruise> result = getFilteredDataList(Cruise.class.getName(), new Predicate<Cruise>() {
- @Override
- public boolean apply(Cruise input) {
- return programId.equals(input.getProgram().getId());
- }
- });
- return result;
- }
-
- @Override
- public Cruise getCruise(String id) {
- Cruise result = getBean(Cruise.class.getName(), id);
- return result;
- }
-
- @Override
- public Cruise createCruise(Cruise bean) {
- Cruise result = create(Cruise.class.getName(), bean);
- return result;
- }
-
- @Override
- public Cruise saveCruise(Cruise bean) {
- Cruise result = save(Cruise.class.getName(), bean);
- return result;
- }
-
- //------------------------------------------------------------------------//
- //-- Protocol methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<String> getAllProtocolNames() {
- throw new IllegalStateException("method 'getAllProtocolNames' not implemented");
- }
-
- @Override
- public List<TuttiProtocol> getAllProtocol() {
- throw new IllegalStateException("method 'getAllProtocol' not implemented");
- }
-
- @Override
- public boolean isProtocolExist(String id) {
- throw new IllegalStateException("method 'isProtocolExist' not implemented");
- }
-
- @Override
- public TuttiProtocol getProtocol(String id) {
- throw new IllegalStateException("method 'getProtocol' not implemented");
- }
-
- @Override
- public TuttiProtocol createProtocol(TuttiProtocol bean) {
- throw new IllegalStateException("method 'createProtocol' not implemented");
- }
-
- @Override
- public TuttiProtocol saveProtocol(TuttiProtocol bean) {
- throw new IllegalStateException("method 'saveProtocol' not implemented");
- }
-
- @Override
- public void deleteProtocol(String id) {
- throw new IllegalStateException("method 'deleteProtocol' not implemented");
- }
-
- //------------------------------------------------------------------------//
- //-- FishingOperation methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<FishingOperation> getAllFishingOperation(final String cruiseId) {
- List<FishingOperation> result = getFilteredDataList(FishingOperation.class.getName(), new Predicate<FishingOperation>() {
- @Override
- public boolean apply(FishingOperation input) {
- return cruiseId.equals(input.getCruise().getId());
- }
- });
- return result;
- }
-
- @Override
- public FishingOperation getFishingOperation(String id) {
- List<FishingOperation> data = getData(FishingOperation.class.getName());
- FishingOperation result = TuttiEntities.findById(data, id);
- return result;
- }
-
- @Override
- public FishingOperation createFishingOperation(FishingOperation bean) {
- FishingOperation result = create(FishingOperation.class.getName(), bean);
- return result;
- }
-
- @Override
- public FishingOperation saveFishingOperation(FishingOperation bean) {
- FishingOperation result = save(FishingOperation.class.getName(), bean);
- return result;
- }
-
- //------------------------------------------------------------------------//
- //-- CatchBatch methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public CatchBatch getCatchBatchFromFishingOperation(String id) {
- List<CatchBatch> data = getData(CatchBatch.class.getName());
- CatchBatch result = null;
- for (CatchBatch catchBatch : data) {
- if (id.equals(catchBatch.getFishingOperation().getId())) {
- result = catchBatch;
- break;
- }
- }
- return result;
- }
-
- @Override
- public CatchBatch createCatchBatch(CatchBatch bean) {
- CatchBatch result = create(CatchBatch.class.getName(), bean);
- return result;
- }
-
- @Override
- public CatchBatch saveCatchBatch(CatchBatch bean) {
- CatchBatch result = save(CatchBatch.class.getName(), bean);
- return result;
- }
-
- //------------------------------------------------------------------------//
- //-- Species Batch methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<SpeciesBatch> getAllRootSpeciesBatch(String fishingOperationId) {
- List<SpeciesBatch> result = getAllTraitFilterBatches(
- SpeciesBatch.class.getName(), fishingOperationId, new Predicate<SpeciesBatch>() {
-
- @Override
- public boolean apply(SpeciesBatch input) {
- return input.getParentBatch() == null;
- }
- });
- return result;
- }
-
- private SpeciesBatch getSpeciesBatch(String id) {
- SpeciesBatch result = getBean(SpeciesBatch.class.getName(), id);
- return result;
- }
-
- @Override
- public SpeciesBatch createSpeciesBatch(SpeciesBatch bean,
- String parentBatchId) {
-
- boolean withParent = parentBatchId != null;
-
- SpeciesBatch result = create(SpeciesBatch.class.getName(), bean, !withParent);
-
- if (withParent) {
-
- // link to parent
- SpeciesBatch parentBatch = getSpeciesBatch(parentBatchId);
- result.setParentBatch(parentBatch);
-
- // add to parent childs
- List<SpeciesBatch> childBatchs = parentBatch.getChildBatchs();
- if (childBatchs == null) {
- childBatchs = Lists.newArrayList();
- parentBatch.setChildBatchs(childBatchs);
- }
- childBatchs.add(result);
-
- // now persist species batches
- persistToFile(SpeciesBatch.class.getName());
- }
- return result;
- }
-
- @Override
- public SpeciesBatch saveSpeciesBatch(SpeciesBatch bean) {
- SpeciesBatch result = save(SpeciesBatch.class.getName(), bean);
- return result;
- }
-
- @Override
- public void deleteSpeciesBatch(String id) {
- remove(SpeciesBatch.class.getName(), id);
- }
-
- @Override
- public void deleteSpeciesSubBatch(String id) {
- Preconditions.checkNotNull(id, "Can't save a bean with null id");
- SpeciesBatch bean = getBean(SpeciesBatch.class.getName(), id);
- Preconditions.checkNotNull(
- bean, "SpeciesBatch with id: " + id + " does not exist");
-
- Set<SpeciesBatch> collected = Sets.newHashSet();
- collectChilds(bean, collected);
- for (SpeciesBatch toDelete : collected) {
- cache.remove(SpeciesBatch.class, toDelete);
- }
- bean.setChildBatchs(null);
- persistToFile(SpeciesBatch.class.getName());
- }
-
- @Override
- public void changeSpeciesBatchSpecies(String batchId, Species species) {
- throw new IllegalStateException("method 'changeSpeciesBatchSpecies' not implemented");
- }
-
- protected void collectChilds(SpeciesBatch bean, Set<SpeciesBatch> collected) {
- if (!bean.isChildBatchsEmpty()) {
- for (SpeciesBatch batch : bean.getChildBatchs()) {
- collected.add(batch);
- collectChilds(batch, collected);
- }
- }
- }
-
- @Override
- public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(final String speciesBatchId) {
- List<SpeciesBatchFrequency> result = getFilteredDataList(SpeciesBatchFrequency.class.getName(), new Predicate<SpeciesBatchFrequency>() {
- @Override
- public boolean apply(SpeciesBatchFrequency input) {
- return speciesBatchId.equals(input.getBatch().getId());
- }
- });
- return result;
- }
-
- @Override
- public List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(String speciesBatchId,
- List<SpeciesBatchFrequency> frequencies) {
-
- // get existing data
- List<SpeciesBatchFrequency> existingData =
- getAllSpeciesBatchFrequency(speciesBatchId);
-
- List<SpeciesBatchFrequency> result =
- persistList(SpeciesBatchFrequency.class.getName(),
- existingData,
- frequencies);
- return result;
- }
-
- //------------------------------------------------------------------------//
- //-- Benthos Batch methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<BenthosBatch> getAllBenthosBatch(String fishingOperationId) {
- List<BenthosBatch> result = getAllTraitFilterBatches(
- BenthosBatch.class.getName(), fishingOperationId, null);
- return result;
- }
-
- @Override
- public BenthosBatch getBenthosBatch(String id) {
- BenthosBatch result = getBean(BenthosBatch.class.getName(), id);
- return result;
- }
-
- @Override
- public BenthosBatch createBenthosBatch(BenthosBatch bean) {
- BenthosBatch result = create(BenthosBatch.class.getName(), bean);
- return result;
- }
-
- @Override
- public BenthosBatch saveBenthosBatch(BenthosBatch bean) {
- BenthosBatch result = save(BenthosBatch.class.getName(), bean);
- return result;
- }
-
- @Override
- public void deleteBenthosBatch(String id) {
- remove(BenthosBatch.class.getName(), id);
- }
-
- //------------------------------------------------------------------------//
- //-- Plancton Batch methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
- List<PlanktonBatch> result = getAllTraitFilterBatches(
- PlanktonBatch.class.getName(), fishingOperationId, null);
- return result;
- }
-
- @Override
- public PlanktonBatch getPlanktonBatch(String id) {
- PlanktonBatch result = getBean(PlanktonBatch.class.getName(), id);
- return result;
- }
-
- @Override
- public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) {
- PlanktonBatch result = create(PlanktonBatch.class.getName(), bean);
- return result;
- }
-
- @Override
- public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) {
- PlanktonBatch result = save(PlanktonBatch.class.getName(), bean);
- return result;
- }
-
- @Override
- public void deletePlanktonBatch(String id) {
- remove(PlanktonBatch.class.getName(), id);
- }
-
- //------------------------------------------------------------------------//
- //-- Macrodechet Batch methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<MacroWasteBatch> getAllMacroWasteBatch(String fishingOperationId) {
- List<MacroWasteBatch> result = getAllTraitFilterBatches(
- MacroWasteBatch.class.getName(), fishingOperationId, null);
- return result;
- }
-
- @Override
- public MacroWasteBatch getMacroWasteBatch(String id) {
- MacroWasteBatch result = getBean(MacroWasteBatch.class.getName(), id);
- return result;
- }
-
- @Override
- public MacroWasteBatch createMacroWasteBatch(MacroWasteBatch bean) {
- MacroWasteBatch result = create(MacroWasteBatch.class.getName(), bean);
- return result;
- }
-
- @Override
- public MacroWasteBatch saveMacroWasteBatch(MacroWasteBatch bean) {
- MacroWasteBatch result = save(MacroWasteBatch.class.getName(), bean);
- return result;
- }
-
- @Override
- public void deleteMacroWasteBatch(String id) {
- remove(MacroWasteBatch.class.getName(), id);
- }
-
- //------------------------------------------------------------------------//
- //-- Accidental Batch methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId) {
- List<AccidentalBatch> result = getAllTraitFilterBatches(
- AccidentalBatch.class.getName(), fishingOperationId, null);
- return result;
- }
-
- @Override
- public AccidentalBatch getAccidentalBatch(String id) {
- AccidentalBatch result = getBean(AccidentalBatch.class.getName(), id);
- return result;
- }
-
- @Override
- public AccidentalBatch createAccidentalBatch(AccidentalBatch bean) {
- AccidentalBatch result = create(AccidentalBatch.class.getName(), bean);
- return result;
- }
-
- @Override
- public AccidentalBatch saveAccidentalBatch(AccidentalBatch bean) {
- AccidentalBatch result = save(AccidentalBatch.class.getName(), bean);
- return result;
- }
-
- @Override
- public void deleteAccidentalBatch(String id) {
- remove(AccidentalBatch.class.getName(), id);
- }
-
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
-
- protected <B> Class<B> getType(String type) {
- String typeName = type;
- int i = type.indexOf('#');
- if (i > -1) {
- typeName = type.substring(0, i);
- }
- try {
- Class<B> result = (Class<B>) Class.forName(typeName);
- return result;
- } catch (Exception e) {
- throw new RuntimeException("No class named " + typeName, e);
- }
- }
-
- protected <B extends IdAware> Binder<B, B> getBinder(String type) {
-
- Binder<B, B> result = (Binder<B, B>) binderCache.get(type);
- if (result == null) {
-
- Class<B> binderType = getType(type);
-
- result = BinderFactory.newBinder(binderType);
- binderCache.put(type, result);
- }
- return result;
- }
-
- protected <B extends IdAware> void persist(String beanType,
- B source,
- B target,
- boolean synchFile) {
-
- getBinder(beanType).copyExcluding(source, target, AbstractTuttiEntity.PROPERTY_ID);
- if (source.getId() == null) {
- target.setId(UUID.randomUUID().toString());
- }
- if (!cache.containsEntry(beanType, target)) {
- cache.put(beanType, target);
- }
- if (synchFile) {
- persistToFile(beanType);
- }
- }
-
- protected <B extends IdAware> List<B> persistList(String beanType,
- List<B> existingData,
- List<B> newData) {
-
- Map<B, B> toPersist = Maps.newHashMap();
-
- // mark all old entry to be dettach
- TuttiEntities.fillEntries(toPersist,
- existingData,
- TuttiEntities.<B, B>newConstantFunction(null));
-
- // index them by id
- Map<String, B> existingById = TuttiEntities.splitById(existingData);
-
- for (B source : newData) {
-
- B target;
-
- if (TuttiEntities.isNew(source)) {
-
- // must create it
- Class<B> type = getType(beanType);
- target = TuttiEntities.newEntity(type);
- } else {
-
- // get existing data
- target = existingById.get(source.getId());
- }
-
- // store it to be persist in one time
- toPersist.put(target, source);
- }
-
- // persist (entry with a value) and dettach (entry with no value)
-
- List<B> result = Lists.newArrayList();
-
- for (Map.Entry<B, B> entry : toPersist.entrySet()) {
- B source = entry.getValue();
- B target = entry.getKey();
- if (source == null) {
-
- // dettach entity
- cache.remove(beanType, target);
- } else {
-
- // persist entity
- persist(beanType, source, target, false);
-
- // store it back in result
- result.add(target);
- }
- }
- persistToFile(beanType);
-
- return result;
- }
-
- protected <B extends IdAware> List<B> loadEntities(String entityType,
- TuttiPersistenceDevFixtures fix) throws IOException {
- File storageFile = getStorageFile(entityType);
-
- List<B> result;
-
- if (storageFile.exists()) {
- if (log.isDebugEnabled()) {
- log.debug("Load data from file: " + storageFile);
- }
-
- ObjectInputStream oos =
- new ObjectInputStream(new FileInputStream(storageFile));
- try {
-
- result = (List<B>) oos.readObject();
- oos.close();
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Could not find a class ", e);
- } finally {
- IOUtils.closeQuietly(oos);
- }
-
- cache.putAll(entityType, result);
- } else {
-
- result = fix.getData(entityType);
-
- cache.putAll(entityType, result);
-
- // persist it right now
- persistToFile(entityType);
- }
-
- return result;
- }
-
- public static String getKey(Class<?> type, String context) {
- String key = type.getName();
- if (context != null) {
- key += '#' + context;
- }
- return key;
- }
-
- protected <B extends IdAware> List<B> loadEntities(String entityType,
- List<B> defaultList) throws IOException {
- File storageFile = getStorageFile(entityType);
-
- List<B> result;
-
- if (storageFile.exists()) {
- if (log.isDebugEnabled()) {
- log.debug("Load data from file: " + storageFile);
- }
-
- ObjectInputStream oos =
- new ObjectInputStream(new FileInputStream(storageFile));
- try {
-
- result = (List<B>) oos.readObject();
- oos.close();
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Could not find a class ", e);
- } finally {
- IOUtils.closeQuietly(oos);
- }
-
- } else {
- result = defaultList;
-
- // persist it right now
- persistToFile(entityType);
- }
-
- cache.putAll(entityType, result);
- return result;
- }
-
- protected <B> File getStorageFile(String entityType) {
- File result = new File(storageDirectory, entityType + ".ser");
- return result;
- }
-
- public <B extends IdAware> void persistToFile(String entityType) {
-
- List<B> entities = getDataInNewList(entityType);
- File storageFile = getStorageFile(entityType);
-
- if (log.isDebugEnabled()) {
- log.debug("Persist storage to file: " + storageFile);
- }
- ObjectOutputStream oos = null;
- try {
- oos = new ObjectOutputStream(new FileOutputStream(storageFile));
- oos.writeObject(entities);
-
- oos.close();
- } catch (IOException e) {
- throw new RuntimeException(
- "Could not persist to file: " + storageFile, e);
- } finally {
- if (oos != null) {
- IOUtils.closeQuietly(oos);
- }
- }
- }
-
- protected <B extends IdAware> List<B> getData(String entityType) {
- List<B> result = (List<B>) cache.get(entityType);
- return result;
- }
-
- protected <B extends IdAware> List<B> getDataInNewList(String entityType) {
- List<B> result = getData(entityType);
- return Lists.newArrayList(result);
- }
-
- protected <B extends IdAware, E> List<E> getTransformedDataList(String entityType, Function<B, E> function) {
- List<B> result = getData(entityType);
- return Lists.newArrayList(Iterables.transform(result, function));
- }
-
- protected <B extends IdAware> List<B> getFilteredDataList(String entityType, Predicate<B> predicate) {
- List<B> result = getData(entityType);
- return Lists.newArrayList(Iterables.filter(result, predicate));
- }
-
- protected <B extends FishingOperationAware> List<B> getAllTraitFilterBatches(
- String beanType,
- String traitId,
- Predicate<B> extraPredicate) {
- Predicate<B> predicate = TuttiEntities.newTraitIdPredicate(traitId);
- if (extraPredicate != null) {
- predicate = Predicates.and(predicate, extraPredicate);
- }
- List<B> result = getFilteredDataList(beanType, predicate);
- return result;
- }
-
- protected <B extends IdAware> B create(String type, B bean) {
- return create(type, bean, true);
- }
-
- public <B extends IdAware> B create(String type,
- B bean,
- boolean sychronize) {
- Preconditions.checkNotNull(bean, "Can't persist a null bean");
- B result = TuttiEntities.newEntity(bean);
- persist(type, bean, result, sychronize);
- return result;
- }
-
- protected <B extends IdAware> B save(String type, B bean) {
- Preconditions.checkNotNull(bean, "Can't persist a null bean");
- String id = bean.getId();
- Preconditions.checkNotNull(id, "Can't save a bean with null id");
- B result = getBean(type, id);
- Preconditions.checkNotNull(
- result, "Can't save a not persisted bean with id: " + id);
- persist(type, bean, result, true);
- return result;
- }
-
- protected <B extends IdAware> void remove(String type, String id) {
- Preconditions.checkNotNull(id, "Can't delete a null id");
- B bean = getBean(type, id);
- //FIXME tchemit Should never happen!
- if (bean == null) {
- if (log.isWarnEnabled()) {
- log.warn("No bean with id: " + id);
- }
- }
-// Preconditions.checkNotNull(bean, "Can't delete a null bean");
- cache.remove(type, bean);
- persistToFile(type);
- }
-
- protected <B extends IdAware> B getBean(String type, String id) {
- List<B> data = getData(type);
- B result = TuttiEntities.findById(data, id);
- return result;
- }
-
- protected List<Caracteristic> getAllCaracteristic(CaracteristicEnum categoryId) {
- List<Caracteristic> result = getDataInNewList(getKey(Caracteristic.class, categoryId.name()));
- return result;
- }
-
- protected Caracteristic getCaracteristic(CaracteristicEnum categoryId) {
- List<Caracteristic> data = getData(getKey(Caracteristic.class, categoryId.name()));
- Caracteristic result = data.get(0);
- return result;
- }
-
- /**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
- public static class TuttiPersistenceDevFixtures {
-
- protected final ArrayListMultimap<String, IdAware> cache;
-
- protected void putInCache(Class<?> type, IdAware b) {
- putInCache(type, null, b);
- }
-
- protected void putInCache(Class<?> type, String context, IdAware b) {
- String key = getKey(type, context);
- cache.put(key, b);
- }
-
- public TuttiPersistenceDevFixtures() {
-
- // inject default datas (only referential)
-
- cache = ArrayListMultimap.create();
-
- Zone z;
- z = new Zone();
- z.setId(UUID.randomUUID().toString());
- z.setName("zone1");
- putInCache(Zone.class, z);
-
- FishingOperationLocation l;
- FishingOperationLocation sl;
- FishingOperationLocation ssl;
-
- l = new FishingOperationLocation();
- l.setId(UUID.randomUUID().toString());
- l.setName("zone1 - strata1");
- l.setZone(z);
- putInCache(FishingOperationLocation.class, "Strata", l);
-
- sl = new FishingOperationLocation();
- sl.setId(UUID.randomUUID().toString());
- sl.setName("strat1 - substrata1");
- sl.setParent(l);
- putInCache(FishingOperationLocation.class, "SubStrata", sl);
-
- ssl = new FishingOperationLocation();
- ssl.setId(UUID.randomUUID().toString());
- ssl.setName("substrata1 - localite1");
- ssl.setLocalite(true);
- ssl.setParent(sl);
- putInCache(FishingOperationLocation.class, "Localite", ssl);
-
- ssl = new FishingOperationLocation();
- ssl.setId(UUID.randomUUID().toString());
- ssl.setName("substrata1 - localite2");
- ssl.setLocalite(true);
- ssl.setParent(sl);
- putInCache(FishingOperationLocation.class, "Localite", ssl);
-
- sl = new FishingOperationLocation();
- sl.setId(UUID.randomUUID().toString());
- sl.setName("strat1 - substrata2");
- sl.setParent(l);
- putInCache(FishingOperationLocation.class, "SubStrata", sl);
-
- ssl = new FishingOperationLocation();
- ssl.setId(UUID.randomUUID().toString());
- ssl.setName("substrata2 - localite1");
- ssl.setLocalite(true);
- ssl.setParent(sl);
- putInCache(FishingOperationLocation.class, "Localite", ssl);
-
- ssl = new FishingOperationLocation();
- ssl.setId(UUID.randomUUID().toString());
- ssl.setName("substrata2 - localite2");
- ssl.setLocalite(true);
- ssl.setParent(sl);
- putInCache(FishingOperationLocation.class, "Localite", ssl);
-
- l = new FishingOperationLocation();
- l.setId(UUID.randomUUID().toString());
- l.setName("zone1 - strata2");
- l.setZone(z);
- putInCache(FishingOperationLocation.class, "Strata", l);
-
- ssl = new FishingOperationLocation();
- ssl.setId(UUID.randomUUID().toString());
- ssl.setName("strata2 - localite1");
- ssl.setParent(l);
- ssl.setLocalite(true);
- putInCache(FishingOperationLocation.class, "Localite", ssl);
-
- ssl = new FishingOperationLocation();
- ssl.setId(UUID.randomUUID().toString());
- ssl.setName("strata2 - localite2");
- ssl.setParent(l);
- ssl.setLocalite(true);
- putInCache(FishingOperationLocation.class, "Localite", ssl);
-
- z = new Zone();
- z.setId(UUID.randomUUID().toString());
- z.setName("zone2");
- putInCache(Zone.class, z);
-
- l = new FishingOperationLocation();
- l.setId(UUID.randomUUID().toString());
- l.setName("zone2 - strata1");
- l.setZone(z);
- putInCache(FishingOperationLocation.class, "Strata", l);
-
- l = new FishingOperationLocation();
- l.setId(UUID.randomUUID().toString());
- l.setName("zone2 - strata2");
- l.setZone(z);
- putInCache(FishingOperationLocation.class, "Strata", l);
-
- Country c;
- c = new Country();
- c.setId(UUID.randomUUID().toString());
- c.setName("France");
- putInCache(Country.class, c);
-
- c = new Country();
- c.setId(UUID.randomUUID().toString());
- c.setName("Espagne");
- putInCache(Country.class, c);
-
- Vessel v;
-
- v = new Vessel();
- v.setId(UUID.randomUUID().toString());
- v.setName("THALASSA");
- v.setScientificVessel(true);
- v.setRegistrationCode("RegistrationCode1");
- putInCache(Vessel.class, "Scientific", v);
-
- v = new Vessel();
- v.setId(UUID.randomUUID().toString());
- v.setName("THALASSA-II");
- v.setScientificVessel(true);
- v.setRegistrationCode("RegistrationCode2");
- putInCache(Vessel.class, "Scientific", v);
-
- v = new Vessel();
- v.setId(UUID.randomUUID().toString());
- v.setName("Fishing1");
- v.setScientificVessel(false);
- v.setRegistrationCode("RegistrationCode1");
- putInCache(Vessel.class, "Fishing", v);
-
- v = new Vessel();
- v.setId(UUID.randomUUID().toString());
- v.setName("Fishing2");
- v.setScientificVessel(false);
- v.setRegistrationCode("RegistrationCode1");
- putInCache(Vessel.class, "Fishing", v);
-
-
- Gear g;
-
- g = new Gear();
- g.setId(UUID.randomUUID().toString());
- g.setName("Gear-Scientific-1");
- putInCache(Gear.class, "Scientific", g);
-
- g = new Gear();
- g.setId(UUID.randomUUID().toString());
- g.setName("Gear-Scientific-2");
- putInCache(Gear.class, "Scientific", g);
-
- g = new Gear();
- g.setId(UUID.randomUUID().toString());
- g.setName("Gear-Fishing-1");
- putInCache(Gear.class, "Fishing", g);
-
- g = new Gear();
- g.setId(UUID.randomUUID().toString());
- g.setName("Gear-Fishing-2");
- putInCache(Gear.class, "Fishing", g);
-
- Person u;
-
- u = new Person();
- u.setId(UUID.randomUUID().toString());
- u.setName("Vincent Badts");
- u.setFirstName("Vincent");
- u.setLastName("Badts");
- putInCache(Person.class, u);
-
- u = new Person();
- u.setId(UUID.randomUUID().toString());
- u.setName("Jean claude Mahet");
- u.setFirstName("Jean claude");
- u.setLastName("Mahet");
- putInCache(Person.class, u);
-
- u = new Person();
- u.setId(UUID.randomUUID().toString());
- u.setName("Luisa Metral");
- u.setFirstName("Luisa");
- u.setLastName("Metral");
- putInCache(Person.class, u);
-
- u = new Person();
- u.setId(UUID.randomUUID().toString());
- u.setName("Jean Hervé Bourdeix");
- u.setFirstName("Jean Hervé");
- u.setLastName("Bourdeix");
- putInCache(Person.class, u);
-
- u = new Person();
- u.setId(UUID.randomUUID().toString());
- u.setName("Ysabelle Cheret");
- u.setFirstName("Ysabelle");
- u.setLastName("Cheret");
- putInCache(Person.class, u);
-
- u = new Person();
- u.setId(UUID.randomUUID().toString());
- u.setName("Blandine Brisset");
- u.setFirstName("Blandine");
- u.setLastName("Brisset");
- putInCache(Person.class, u);
-
- Caracteristic ca;
-
- Species sp;
-
- sp = new Species();
- sp.setId(UUID.randomUUID().toString());
- sp.setRefTaxCode("BAR");
- sp.setName("Bar");
- putInCache(Species.class, sp);
-
- sp = new Species();
- sp.setId(UUID.randomUUID().toString());
- sp.setRefTaxCode("CHIN");
- sp.setName("Chinchard");
- putInCache(Species.class, sp);
-
- sp = new Species();
- sp.setId(UUID.randomUUID().toString());
- sp.setRefTaxCode("FLE");
- sp.setName("Flet");
- putInCache(Species.class, sp);
-
- sp = new Species();
- sp.setId(UUID.randomUUID().toString());
- sp.setRefTaxCode("LIM");
- sp.setName("Limande");
- putInCache(Species.class, sp);
-
- ca = createQualitativeCaracteristic("MacroWaste", CaracteristicEnum.MacroWasteCategory.name());
-
- createCaracteristicQualitativeValue(ca, "Bottle");
- createCaracteristicQualitativeValue(ca, "Sheet");
- createCaracteristicQualitativeValue(ca, "Bag");
- createCaracteristicQualitativeValue(ca, "Caps/ lids");
- createCaracteristicQualitativeValue(ca, "Fishing line (monofilament)");
- createCaracteristicQualitativeValue(ca, "Fishing line (entangled)");
- createCaracteristicQualitativeValue(ca, "Synthetic rope");
- createCaracteristicQualitativeValue(ca, "Cable ties");
- createCaracteristicQualitativeValue(ca, "Strapping band");
- createCaracteristicQualitativeValue(ca, "Crates abd containers");
- createCaracteristicQualitativeValue(ca, "Boots");
- createCaracteristicQualitativeValue(ca, "Balloons");
- createCaracteristicQualitativeValue(ca, "bobbins (fishing)");
- createCaracteristicQualitativeValue(ca, "tyre");
- createCaracteristicQualitativeValue(ca, "glove");
- createCaracteristicQualitativeValue(ca, "diapers");
- createCaracteristicQualitativeValue(ca, "cotton buds");
- createCaracteristicQualitativeValue(ca, "cigarette butts");
- createCaracteristicQualitativeValue(ca, "condoms");
- createCaracteristicQualitativeValue(ca, "syringes");
- createCaracteristicQualitativeValue(ca, "sanitary towels / tampon");
- createCaracteristicQualitativeValue(ca, "jar");
- createCaracteristicQualitativeValue(ca, "piece");
-
- ca = createQualitativeCaracteristic("MacroWaste Size category",
- CaracteristicEnum.MacroWasteSizeCategory.name());
- createCaracteristicQualitativeValue(ca, "<5*5cm = 25cm²");
- createCaracteristicQualitativeValue(ca, "<10*10cm = 100cm²");
- createCaracteristicQualitativeValue(ca, "<20*20cm = 400cm²");
- createCaracteristicQualitativeValue(ca, "<50*50cm = 2500cm²");
- createCaracteristicQualitativeValue(ca, "<100*100cm = 1m²");
- createCaracteristicQualitativeValue(ca, ">100*100cm = 1m²");
-
- ca = createQualitativeCaracteristic("Sorted / Unsorted Category", CaracteristicEnum.SortedUnsortedCategory.name());
-
- createCaracteristicQualitativeValue(ca, "Vrac");
- createCaracteristicQualitativeValue(ca, "Hors Vrac");
-
- ca = createQualitativeCaracteristic("Species Sex Category", CaracteristicEnum.SexCategory.name());
-
- createCaracteristicQualitativeValue(ca, "Male");
- createCaracteristicQualitativeValue(ca, "Femelle");
- createCaracteristicQualitativeValue(ca, "Indéterminé");
-
- ca = createQualitativeCaracteristic("Species Maturity Category", CaracteristicEnum.MaturityCategory.name());
-
- createCaracteristicQualitativeValue(ca, "0");
- createCaracteristicQualitativeValue(ca, "1");
- createCaracteristicQualitativeValue(ca, "2");
-
- ca = createQualitativeCaracteristic("Species Size Category", CaracteristicEnum.SizeCategory.name());
-
- createCaracteristicQualitativeValue(ca, "Petit");
- createCaracteristicQualitativeValue(ca, "Gros");
- }
-
- protected void createCaracteristicQualitativeValue(Caracteristic ca, String name) {
- CaracteristicQualitativeValue cqv = new CaracteristicQualitativeValue();
- cqv.setId(UUID.randomUUID().toString());
- cqv.setName(name);
- ca.addQualitativeValue(cqv);
- putInCache(CaracteristicQualitativeValue.class, name, cqv);
- }
-
- protected Caracteristic createQualitativeCaracteristic(String name, String category) {
- Caracteristic ca = new Caracteristic();
- ca.setId(UUID.randomUUID().toString());
- ca.setName(name);
- ca.setCategory(category);
- ca.setCaracteristicType(CaracteristicType.QUALITATIVE);
- ca.setQualitativeValue(Lists.<CaracteristicQualitativeValue>newArrayList());
- putInCache(Caracteristic.class, category, ca);
- return ca;
- }
-
- protected Caracteristic createNumberCaracteristic(String name, String category) {
- Caracteristic ca = new Caracteristic();
- ca.setId(UUID.randomUUID().toString());
- ca.setName(name);
- ca.setCategory(category);
- ca.setCaracteristicType(CaracteristicType.NUMBER);
- putInCache(Caracteristic.class, category, ca);
- return ca;
- }
-
- public <B extends IdAware> List<B> getData(String entityType) {
- List<B> result = (List<B>) cache.get(entityType);
- return result;
- }
- }
-}
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java 2013-02-25 14:11:54 UTC (rev 461)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java 2013-02-25 14:30:44 UTC (rev 462)
@@ -24,11 +24,9 @@
* #L%
*/
-import com.google.common.base.Preconditions;
import fr.ifremer.adagio.core.service.technical.CacheService;
import fr.ifremer.tutti.persistence.DatabaseFixtures;
import fr.ifremer.tutti.persistence.DatabaseResource;
-import fr.ifremer.tutti.persistence.TuttiPersistenceDevImpl;
import fr.ifremer.tutti.persistence.entities.IdAware;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -42,20 +40,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.NonUniqueResultException;
-import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
-import org.nuiton.util.ApplicationConfig;
import java.io.IOException;
import java.util.List;
-import static fr.ifremer.tutti.persistence.TuttiPersistenceDevImpl.CaracteristicEnum;
-
/**
* To test {@link ReferentialPersistenceService} for read operation.
*
@@ -71,8 +65,6 @@
private static final Log log =
LogFactory.getLog(ReferentialPersistenceServiceReadTest.class);
- protected static TuttiPersistenceDevImpl storage;
-
protected ReferentialPersistenceService service;
protected CacheService cacheService;
@@ -82,43 +74,9 @@
@BeforeClass
public static void beforeClass() throws IOException {
- // create a storage
-
- ApplicationConfig applicationConfig = dbResource.getConfig().getConfig();
-
- applicationConfig.setOption(
- TuttiPersistenceDevImpl.SKIP_FIXTURES_OPTION, Boolean.TRUE.toString());
-
- storage = new TuttiPersistenceDevImpl(applicationConfig) {
-
- @Override
- public <B extends IdAware> B create(String type,
- B bean,
- boolean sychronize) {
- Preconditions.checkNotNull(bean, "Can't persist a null bean");
- B result = TuttiEntities.newEntity(bean);
- result.setId(bean.getId());
- if (log.isDebugEnabled()) {
- log.debug("Will persist [" + type + ":" + bean.getId() + "]");
- }
- super.persist(type, bean, result, sychronize);
- return result;
- }
- };
-
- if (log.isInfoEnabled()) {
- log.info("Will init persistence driver " + storage.getImplementationName());
- }
-
- storage.init();
-
TuttiPersistenceServiceLocator.instance().getCacheService().clearAllCaches();
}
- @AfterClass
- public static void afterClass() throws IOException {
- storage.close();
- }
@Before
public void setUp() throws Exception {
@@ -134,18 +92,12 @@
public void getAllProgramZone() {
List<Zone> result = service.getAllProgramZone();
assertResultList(result, fixtures.refNbProgramZone());
-
- persistList(Zone.class, result);
- assertSize(result, storage.getAllProgramZone());
}
@Test
public void getAllCountry() {
List<Country> result = service.getAllCountry();
assertResultList(result, fixtures.refNbCountry());
-
- persistList(Country.class, result);
- assertSize(result, storage.getAllCountry());
}
@Test
@@ -154,9 +106,6 @@
List<FishingOperationLocation> result =
service.getAllFishingOperationStrata(zoneId);
assertResultList(result, fixtures.refNbStrata());
-
- persistList(FishingOperationLocation.class, "Strata", result);
- assertSize(result, storage.getAllFishingOperationStrata(zoneId));
}
@Test
@@ -166,9 +115,6 @@
service.getAllFishingOperationSubStrata(zoneId, null);
assertResultList(result, 0);
- persistList(FishingOperationLocation.class, "SubStrata", result);
- assertSize(result, storage.getAllFishingOperationSubStrata(zoneId, null));
-
// try with a strataId
String strataId = dbResource.getFixtures().strataId();
result = service.getAllFishingOperationLocation(zoneId, strataId, null);
@@ -182,9 +128,6 @@
service.getAllFishingOperationLocation(zoneId, null, null);
assertResultList(result, fixtures.refNbLocalite());
- persistList(FishingOperationLocation.class, "Localite", result);
- assertSize(result, storage.getAllFishingOperationLocation(zoneId, null, null));
-
// try with a strataId
String strataId = dbResource.getFixtures().strataId();
result = service.getAllFishingOperationLocation(zoneId, strataId, null);
@@ -200,8 +143,6 @@
public void getAllScientificVessel() {
List<Vessel> result = service.getAllScientificVessel();
assertResultList(result, fixtures.refNbScientificVessel());
- persistList(Vessel.class, "Scientific", result);
- assertSize(result, storage.getAllScientificVessel());
}
@Test
@@ -226,45 +167,30 @@
//TODO-tc We should not test cache performance like this, depends to much of the computer usage,...
// float reduceFactor = delta2 * 100 / delta1;
// Assert.assertTrue("The cache on getAllFishingVessel() should have speed up more than factor 10. Make sure EhCache is well configured.", reduceFactor < 0.1);
-
- persistList(Vessel.class, "Fishing", result);
- assertSize(result, storage.getAllFishingVessel());
}
@Test
public void getAllScientificGear() {
List<Gear> result = service.getAllScientificGear();
assertResultList(result, fixtures.refNbScientificGear());
-
- persistList(Gear.class, "Scientific", result);
- assertSize(result, storage.getAllScientificGear());
}
@Test
public void getAllFishingGear() {
List<Gear> result = service.getAllFishingGear();
assertResultList(result, fixtures.refNbFishingGear());
-
- persistList(Gear.class, "Fishing", result);
- assertSize(result, storage.getAllFishingGear());
}
@Test
public void getAllPerson() {
List<Person> result = service.getAllPerson();
assertResultList(result, fixtures.refNbPerson());
-
- persistList(Person.class, result);
- assertSize(result, storage.getAllPerson());
}
@Test
public void getAllSpecies() {
List<Species> result = service.getAllSpecies();
assertResultList(result, fixtures.refNbSpecies());
-
- persistList(Species.class, result);
- assertSize(result, storage.getAllSpecies());
}
@Test
@@ -301,51 +227,42 @@
public void getAllCaracteristic() {
List<Caracteristic> result = service.getAllCaracteristic();
assertResultList(result, fixtures.refNbCaracteristic());
-
- persistList(Caracteristic.class, CaracteristicEnum.All.name(), result);
- assertSize(result, storage.getAllCaracteristic());
}
@Test
public void getSizeCategoryCaracteristic() {
Caracteristic result = service.getSizeCategoryCaracteristic();
assertCaracteristicQualitative(result, 6);
- persist(Caracteristic.class, CaracteristicEnum.SizeCategory.name(), result);
}
@Test
public void getSexCaracteristic() {
Caracteristic result = service.getSexCaracteristic();
assertCaracteristicQualitative(result, 4);
- persist(Caracteristic.class, CaracteristicEnum.SexCategory.name(), result);
}
@Test
public void getSortedUnsortedCaracteristic() {
Caracteristic result = service.getSortedUnsortedCaracteristic();
assertCaracteristicQualitative(result, 2);
- persist(Caracteristic.class, CaracteristicEnum.SortedUnsortedCategory.name(), result);
}
@Test
public void getMaturityCaracteristic() {
Caracteristic result = service.getMaturityCaracteristic();
assertCaracteristicQualitative(result, 6);
- persist(Caracteristic.class, CaracteristicEnum.MaturityCategory.name(), result);
}
@Test
public void getMacroWasteCategoryCaracteristic() {
Caracteristic result = service.getMacroWasteCategoryCaracteristic();
assertCaracteristicQualitative(result, 21);
- persist(Caracteristic.class, CaracteristicEnum.MacroWasteCategory.name(), result);
}
@Test
public void getMacroWasteSizeCategoryCaracteristic() {
Caracteristic result = service.getMacroWasteSizeCategoryCaracteristic();
assertCaracteristicQualitative(result, 6);
- persist(Caracteristic.class, CaracteristicEnum.MacroWasteSizeCategory.name(), result);
}
@Test
@@ -363,28 +280,6 @@
System.out.println(obj);
}
- protected <S extends IdAware> void persistList(Class<S> type, List<S> result) {
- persistList(type, null, result);
- }
-
- protected <S extends IdAware> void persistList(Class<S> type, String context, List<S> result) {
-
- String key = TuttiPersistenceDevImpl.getKey(type, context);
- for (S s : result) {
- storage.create(key, s, false);
- }
- storage.persistToFile(key);
- }
-
- protected <S extends IdAware> void persist(Class<S> type, S result) {
- persist(type, null, result);
- }
-
- protected <S extends IdAware> void persist(Class<S> type, String context, S result) {
- String key = TuttiPersistenceDevImpl.getKey(type, context);
- storage.create(key, result, true);
- }
-
protected void assertSize(List<?> expectedList, List<?> storageList) {
Assert.assertNotNull(expectedList);
Assert.assertNotNull(storageList);
1
0
25 Feb '13
Author: blavenier
Date: 2013-02-25 15:11:54 +0100 (Mon, 25 Feb 2013)
New Revision: 461
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/461
Log:
ref refs #1936: [CAPTURE] - Esp?\195?\168ce - pouvoir changer le nom d'une esp?\195?\168ce
- Add changeSpeciesBatchSpecies() implementation
Fix :
- Fix save/retrieve of qualitative value on operation (refs #2028)
Add :
- Ajout de la conversion possible d'un arbre d'?\195?\169chantillonnage (refs #1997)
Added:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java
Modified:
trunk/pom.xml
trunk/tutti-persistence/pom.xml
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/service/BatchPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-02-25 13:39:39 UTC (rev 460)
+++ trunk/pom.xml 2013-02-25 14:11:54 UTC (rev 461)
@@ -138,7 +138,7 @@
<slf4jVersion>1.7.2</slf4jVersion>
- <adagioVersion>3.3.2</adagioVersion>
+ <adagioVersion>3.3.3-SNAPSHOT</adagioVersion>
<msaccessImporterVersion>1.4.1</msaccessImporterVersion>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-persistence/pom.xml 2013-02-25 14:11:54 UTC (rev 461)
@@ -162,6 +162,13 @@
<artifactId>spring-test</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jmock</groupId>
+ <artifactId>jmock-junit4</artifactId>
+ <version>2.5.1</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
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-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -305,6 +305,7 @@
* @param id id of the fihsing operation
* @return found catchbatch
*/
+ @Transactional(readOnly = false)
CatchBatch getCatchBatchFromFishingOperation(String id);
/**
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-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -25,6 +25,8 @@
*/
import com.google.common.collect.Maps;
+
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
@@ -442,7 +444,13 @@
@Override
public CatchBatch getCatchBatchFromFishingOperation(String id) {
- return catchBatchService.getCatchBatchFromFishingOperation(id);
+ try {
+ return catchBatchService.getCatchBatchFromFishingOperation(id, true);
+ } catch (CatchBatchValidationException e) {
+ // TODO Code lutin : throw exception and ask user : "Voulez convertir les donn�es d'�chantillonnage dans un format compatible tutti ?"
+ e.printStackTrace();
+ return null;
+ }
}
@Override
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java 2013-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -27,7 +27,13 @@
import org.springframework.transaction.annotation.Transactional;
+import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
+import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
+
@Transactional(readOnly = true)
public interface BatchPersistenceService extends CatchBatchPersistenceService, SpeciesBatchPersistenceService {
+ void cleanEntity(CatchBatch catchBatch, boolean keepTotalWeight);
+
+ void setCatchBatchDao(CatchBatchExtendDao dao);
}
\ No newline at end of file
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -25,24 +25,49 @@
*/
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.FlushMode;
+import org.hibernate.type.IntegerType;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.stereotype.Service;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+
import fr.ifremer.adagio.core.dao.data.batch.Batch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatchDao;
import fr.ifremer.adagio.core.dao.data.batch.denormalized.DenormalizedBatchDao;
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationError;
import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidator;
+import fr.ifremer.adagio.core.dao.data.measure.Measurement;
import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
import fr.ifremer.adagio.core.dao.data.operation.FishingOperationImpl;
import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValue;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl;
import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxon;
import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxonImpl;
import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
@@ -50,34 +75,10 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.persistence.service.measure.MeasurementPersistenceHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.FlushMode;
-import org.hibernate.type.IntegerType;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.dao.DataIntegrityViolationException;
-import org.springframework.dao.DataRetrievalFailureException;
-import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import java.io.Serializable;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
@Service("batchPersistenceService")
public class BatchPersistenceServiceImpl
- extends AbstractPersistenceService implements BatchPersistenceService, CatchBatchValidator {
+ extends AbstractPersistenceService implements BatchPersistenceService {
/** Logger. */
private static final Log log =
@@ -95,46 +96,34 @@
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
- @Resource(name = "measurementPersistenceHelper")
- protected MeasurementPersistenceHelper measurementHelper;
-
+ @Resource(name = "scientificCruiseCatchBatchValidator")
+ protected CatchBatchValidator catchBatchValidator;
+
@Override
public void init() {
super.init();
- catchBatchDao.registerCatchBatchValidator(this);
+ catchBatchDao.registerCatchBatchValidator(catchBatchValidator);
}
@Override
public void close() {
- catchBatchDao.unregisterCatchBatchValidator(this);
+ catchBatchDao.unregisterCatchBatchValidator(catchBatchValidator);
super.close();
}
@Override
- public boolean isEnable(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
- // Apply validation only on catch batch for fishingOperation
- return (catchBatch.getFishingOperation() != null);
+ public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException {
+ return getCatchBatchFromFishingOperation(fishingOperationId, false);
}
@Override
- public List<CatchBatchValidationError> validate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
- List<CatchBatchValidationError> errors = Lists.newArrayList();
- validate(catchBatch.getChildBatchs(), errors, 1);
- return errors;
- }
-
- @Override
- public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) {
+ public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId, boolean tryToRepair) throws CatchBatchValidationException {
Preconditions.checkNotNull(fishingOperationId);
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
fr.ifremer.adagio.core.dao.data.batch.CatchBatch source;
- try {
- source = catchBatchDao.loadFullTree(catchBatchId, true, true);
- } catch (CatchBatchValidationException e) {
- throw new DataRetrievalFailureException("Invalid batch tree structure, for fishing operation id=" + fishingOperationId, e);
- }
+ source = catchBatchDao.loadFullTree(catchBatchId, true, tryToRepair);
CatchBatch result = new CatchBatch();
result.setId(source.getId().toString());
@@ -157,12 +146,16 @@
// Inert
SortingBatch inertBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(),
"referenceTaxonId", enumeration.REFERENCE_TAXON_ID_INERT);
- result.setSpeciesTotalInertWeight(inertBatch.getWeight());
+ if (inertBatch != null) {
+ result.setSpeciesTotalInertWeight(inertBatch.getWeight());
+ }
// Alive no itemized
SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(),
"referenceTaxonId", enumeration.REFERENCE_TAXON_ID_LIFE);
- result.setSpeciesTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight());
+ if (livingNotItemizedBatch != null) {
+ result.setSpeciesTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight());
+ }
}
// TODO : Benthos, Plancton...
@@ -171,27 +164,59 @@
// Hors Vrac
SortingBatch horsVracBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(),
"pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID);
- result.setCatchTotalUnsortedWeight(horsVracBatch.getWeight());
- {
- // Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(),
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
-
- result.setSpeciesTotalUnsortedWeight(speciesBatch.getWeight());
-
- // TODO : Benthos, Plancton...
+ if (horsVracBatch != null) {
+ result.setCatchTotalUnsortedWeight(horsVracBatch.getWeight());
+ {
+ // Species
+ SortingBatch speciesBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+
+ result.setSpeciesTotalUnsortedWeight(speciesBatch.getWeight());
+
+ // TODO : Benthos, Plancton...
+ }
}
// Non trié
SortingBatch unsortedBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(),
"pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_UNSORTED_ID);
- result.setCatchTotalRejectedWeight(unsortedBatch.getWeight());
+ if (unsortedBatch != null) {
+ result.setCatchTotalRejectedWeight(unsortedBatch.getWeight());
+ }
return result;
}
+
+ @Override
+ public void cleanEntity(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
+ boolean keepTotalWeight) {
+
+ // TODO BL : voir si nécessaire :
+ for (Iterator<Batch> iterator = catchBatch.getChildBatchs().iterator(); iterator.hasNext();) {
+ Batch batch = (Batch) iterator.next();
+ catchBatchDao.removeWithChildren(batch.getId());
+ }
+ catchBatch.getChildBatchs().clear();
+
+ // Create a new tutti bean CatchBatch, need for method beanToEntity()
+ fr.ifremer.tutti.persistence.entities.data.CatchBatch bean = new fr.ifremer.tutti.persistence.entities.data.CatchBatch();
+ bean.setId(catchBatch.getId().toString());
+
+ // Link the bean to a fake fishingOperation, need in the preconditions for method beanToEntity()
+ FishingOperation fishingOperation = new FishingOperation();
+ fishingOperation.setId(catchBatch.getFishingOperation().getId().toString());
+ bean.setFishingOperation(fishingOperation);
+ // If need, copy the total weight, to be sure beanToEntity() will restore it
+ if (keepTotalWeight) {
+ bean.setCatchTotalWeight(catchBatch.getWeight());
+ }
+
+ beanToEntity(bean, catchBatch, true);
+ }
+
+
@Override
-
public CatchBatch createCatchBatch(CatchBatch bean) {
Preconditions.checkNotNull(bean);
Preconditions.checkArgument(bean.getId() == null);
@@ -215,7 +240,7 @@
return bean;
}
-
+
@Override
@CacheEvict(value = "batchTree", key = "#bean.fishingOperation.id")
public CatchBatch saveCatchBatch(CatchBatch bean) {
@@ -268,13 +293,15 @@
SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
"pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
"pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- for (Iterator<Batch> iterator = horsVracSpeciesBatch.getChildBatchs().iterator(); iterator.hasNext(); ) {
- SortingBatch source = (SortingBatch) iterator.next();
-
- SpeciesBatch target = new SpeciesBatch();
-
- entityToBean(source, target);
- result.add(target);
+ if (horsVracSpeciesBatch != null) {
+ for (Iterator<Batch> iterator = horsVracSpeciesBatch.getChildBatchs().iterator(); iterator.hasNext(); ) {
+ SortingBatch source = (SortingBatch) iterator.next();
+
+ SpeciesBatch target = new SpeciesBatch();
+
+ entityToBean(source, target);
+ result.add(target);
+ }
}
return result;
@@ -303,7 +330,7 @@
if (source.getSortingMeasurements().size() == 1) {
sm = source.getSortingMeasurements().iterator().next();
} else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) {
- sm = measurementHelper.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
+ sm = catchBatchDao.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
}
if (sm != null) {
SampleCategoryEnum sampleCategory = referentialService.getSampleCategoryByPmfmId(sm.getPmfm().getId());
@@ -552,76 +579,6 @@
// -- Internal methods --//
// ------------------------------------------------------------------------//
- protected void validate(Collection<Batch> batchs, List<CatchBatchValidationError> errors, int treeLevel) {
-
- List<Integer> expectedPmfms = null;
- boolean expectedReferenceTaxon = false;
- // First tree level : should have pmfm SORTED (Vrac, Hors Vrac, Non trié)
- if (treeLevel == 1) {
- expectedPmfms = Lists.newArrayList(enumeration.PMFM_ID_SORTED_UNSORTED);
- }
- // Second tree level : should have pmfm SORTING_TYPE (Species, Benthos...)
- else if (treeLevel == 2) {
- expectedPmfms = Lists.newArrayList(enumeration.PMFM_ID_SORTING_TYPE);
- } else if (treeLevel == 3) {
- expectedReferenceTaxon = true;
- } else if (treeLevel > 3) {
- expectedPmfms = referentialService.getSampleCategoryIds();
- expectedPmfms.remove(enumeration.PMFM_ID_SORTED_UNSORTED);
- }
-
- // First level : should be only PMFM=SORTED
- for (Iterator<Batch> iterator = batchs.iterator(); iterator.hasNext(); ) {
- SortingBatch batch = (SortingBatch) iterator.next();
- boolean batchHasError = false;
-
- // For all sorting measurements
- if (batch.getSortingMeasurements() != null && batch.getSortingMeasurements().size() > 0) {
- for (Iterator<SortingMeasurement> iterator2 = batch.getSortingMeasurements().iterator(); iterator2.hasNext(); ) {
- SortingMeasurement sm = iterator2.next();
- Integer pmfmId = sm.getPmfm().getId();
- if (expectedReferenceTaxon) {
- CatchBatchValidationError error = new CatchBatchValidationError(
- "tutti.persistence.batch.validation.onlyTaxonButPmfmFound",
- _("tutti.persistence.batch.validation.onlyTaxonButPmfmFound", batch.getId(), pmfmId),
- CatchBatchValidationError.GRAVITY_ERROR);
- errors.add(error);
- } else if (expectedPmfms.contains(pmfmId) == false) {
- if (sm.getNumericalValue() == null || batch.getChildBatchs().size() > 0) {
- batchHasError = true;
- CatchBatchValidationError error = new CatchBatchValidationError(
- "tutti.persistence.batch.validation.pmfmNotFound",
- _("tutti.persistence.batch.validation.pmfmNotFound",
- batch.getId(), Arrays.toString(expectedPmfms.toArray()), pmfmId),
- CatchBatchValidationError.GRAVITY_ERROR);
- errors.add(error);
- }
- }
- }
- } else if (expectedPmfms != null && expectedPmfms.size() > 0) {
- batchHasError = true;
- CatchBatchValidationError error = new CatchBatchValidationError(
- "tutti.persistence.batch.validation.pmfmNotFound",
- _("tutti.persistence.batch.validation.pmfmNotFound",
- batch.getId(), Arrays.toString(expectedPmfms.toArray()), "null"),
- CatchBatchValidationError.GRAVITY_ERROR);
- errors.add(error);
- }
-
- if (!batchHasError && expectedReferenceTaxon == true && batch.getReferenceTaxon() == null) {
- CatchBatchValidationError error = new CatchBatchValidationError(
- "tutti.persistence.batch.validation.referenceTaxonNotFound",
- _("tutti.persistence.batch.validation.referenceTaxonNotFound", batch.getId()),
- CatchBatchValidationError.GRAVITY_ERROR);
- errors.add(error);
- }
-
- if (!batchHasError) {
- validate(batch.getChildBatchs(), errors, treeLevel + 1);
- }
- }
- }
-
protected void beanToEntity(SpeciesBatch source,
SortingBatch target,
String parentBatchId,
@@ -668,11 +625,11 @@
if (copyIfNull && source.getWeight() == null && source.getSampleCategoryWeight() == null) {
// Nothing to do : will be removed later, using notChangedSortingMeasurements
} else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
} else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -686,7 +643,7 @@
samplingRatioText = samplingRatioText.replaceAll(",", ".");
target.setSamplingRatioText(samplingRatioText);
target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight());
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -695,10 +652,10 @@
if (copyIfNull && (source.getSampleCategoryType() == null || source.getSampleCategoryValue() == null)) {
// Nothing to do : will be removed later, using notChangedSortingMeasurements
} else if (source.getSampleCategoryType() != null && source.getSampleCategoryValue() != null) {
- Integer pmfmId = measurementHelper.sampleCategory2PmfmId(source.getSampleCategoryType());
+ Integer pmfmId = sampleCategory2PmfmId(source.getSampleCategoryType());
// Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
- SortingMeasurement sortingMeasurement = measurementHelper.setSortingMeasurement(target, recorderDepartmentId,
+ SortingMeasurement sortingMeasurement = setSortingMeasurement(target, recorderDepartmentId,
source.getSampleCategoryType(), source.getSampleCategoryValue());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
@@ -765,7 +722,7 @@
// Or retrieve parent batch, from pmfm id
else {
// Retrieve category type
- Integer pmfmId = measurementHelper.sampleCategory2PmfmId(source.getSampleCategoryType());
+ Integer pmfmId = sampleCategory2PmfmId(source.getSampleCategoryType());
if (pmfmId == null || !pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
throw new DataIntegrityViolationException(MessageFormat.format(
"A species batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
@@ -873,7 +830,7 @@
if (copyIfNull && source.getWeight() == null) {
// Nothing to do : will be removed later, using notChangedSortingMeasurements
} else if (source.getWeight() != null) {
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -883,7 +840,7 @@
// Nothing to do : will be removed later, using notChangedSortingMeasurements
} else if (source.getLengthStepCaracteristic() != null && source.getLengthStep() != null) {
Integer pmfmId = Integer.valueOf(source.getLengthStepCaracteristic().getId());
- SortingMeasurement sortingMeasurement = measurementHelper.setSortingMeasurement(target, recorderDepartmentId, pmfmId,
+ SortingMeasurement sortingMeasurement = setSortingMeasurement(target, recorderDepartmentId, pmfmId,
source.getLengthStep());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
@@ -978,7 +935,7 @@
if (copyIfNull && source.getCatchTotalWeight() == null) {
// Nothing to do : will be removed later, using notChangedQuantificationMeasurements
} else if (source.getCatchTotalWeight() != null) {
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getCatchTotalWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -1129,7 +1086,7 @@
}
for (Batch childBatch : parentBatch.getChildBatchs()) {
SortingBatch childSortingBatch = (SortingBatch) childBatch;
- SortingMeasurement sm = measurementHelper.getSortingMeasurement((SortingBatch) childBatch, pmfmId, null, false);
+ SortingMeasurement sm = catchBatchDao.getSortingMeasurement((SortingBatch) childBatch, pmfmId, null, false);
if (sm != null && sm.getQualitativeValue() != null && sm.getQualitativeValue().getId() != null) {
batchByQualitativeValueId.put(sm.getQualitativeValue().getId(), childSortingBatch);
}
@@ -1197,7 +1154,7 @@
if (copyIfNull && (sortingPmfmId == null || sortingQualitativeValueId == null)) {
// Nothing to do : will be removed later, using notChangedSortingMeasurements
} else if (sortingPmfmId != null && sortingQualitativeValueId != null) {
- SortingMeasurement sm = measurementHelper.setSortingMeasurement(target, recorderDepartmentId, sortingPmfmId, sortingQualitativeValueId);
+ SortingMeasurement sm = setSortingMeasurement(target, recorderDepartmentId, sortingPmfmId, sortingQualitativeValueId);
notChangedSortingMeasurements.remove(sm);
}
@@ -1220,7 +1177,7 @@
if (batchReferenceWeight == null) {
batchReferenceWeight = sampleWeight;
}
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -1287,7 +1244,7 @@
if (batchReferenceWeight == null) {
batchReferenceWeight = sampleWeight;
}
- QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target,
+ QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -1309,4 +1266,80 @@
// TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?)
return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
}
+
+ public void setMeasurement(Measurement measurement, Caracteristic caracteristic, Serializable value) {
+ if (caracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
+ measurement.setAlphanumericalValue((String) value);
+ } else if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
+ measurement.setNumericalValue((Float) value);
+ } else if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
+ Integer qvId = null;
+ if (value instanceof CaracteristicQualitativeValue) {
+ qvId = Integer.valueOf(((CaracteristicQualitativeValue) value).getId());
+ } else if (value instanceof Integer) {
+ qvId = (Integer) value;
+ }
+ // TODO BL : not used ? => to remove
+ else {
+ qvId = Integer.valueOf(value.toString());
+ }
+ QualitativeValue qv = load(QualitativeValueImpl.class, qvId);
+ measurement.setQualitativeValue(qv);
+ }
+ }
+
+ public SortingMeasurement setSortingMeasurement(
+ SortingBatch sortingBatch, Integer recorderDepartmentId,
+ SampleCategoryEnum sampleCategory, Serializable value) {
+ Preconditions.checkNotNull(sampleCategory);
+ Preconditions.checkNotNull(value);
+
+ Integer pmfmId = sampleCategory2PmfmId(sampleCategory);
+
+ Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
+ SortingMeasurement sortingMeasurement = catchBatchDao.getSortingMeasurement(
+ sortingBatch, pmfmId, recorderDepartmentId, true);
+ setMeasurement(sortingMeasurement, caracteristic, value);
+ return sortingMeasurement;
+ }
+
+ public SortingMeasurement setSortingMeasurement(
+ SortingBatch sortingBatch, Integer recorderDepartmentId,
+ Integer pmfmId, Serializable value) {
+ Preconditions.checkNotNull(pmfmId);
+ Preconditions.checkNotNull(value);
+
+ Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
+ SortingMeasurement sortingMeasurement = catchBatchDao.getSortingMeasurement(
+ sortingBatch, pmfmId, recorderDepartmentId, true);
+ setMeasurement(sortingMeasurement, caracteristic, value);
+ return sortingMeasurement;
+ }
+
+ public Integer sampleCategory2PmfmId(SampleCategoryEnum sampleCategory) {
+ Integer pmfmId = null;
+ if (sampleCategory == SampleCategoryEnum.sortedUnsorted) {
+ pmfmId = enumeration.PMFM_ID_SORTED_UNSORTED;
+ } else if (sampleCategory == SampleCategoryEnum.size) {
+ pmfmId = enumeration.PMFM_ID_SIZE_CATEGORY;
+ } else if (sampleCategory == SampleCategoryEnum.maturity) {
+ pmfmId = enumeration.PMFM_ID_MATURITY;
+ } else if (sampleCategory == SampleCategoryEnum.sex) {
+ pmfmId = enumeration.PMFM_ID_SEX;
+ } else if (sampleCategory == SampleCategoryEnum.age) {
+ pmfmId = enumeration.PMFM_ID_AGE;
+ }
+ if (pmfmId == null) {
+ throw new IllegalArgumentException("Unable to find corresponding PMFM.ID for sampleCategory : " + sampleCategory.name());
+ }
+ return pmfmId;
+ }
+
+ /**
+ * Need for JMock injection, in unit test
+ * @param catchBatchDao
+ */
+ public void setCatchBatchDao(CatchBatchExtendDao catchBatchDao) {
+ this.catchBatchDao = catchBatchDao;
+ }
}
\ No newline at end of file
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java 2013-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import org.springframework.transaction.annotation.Transactional;
@@ -42,10 +43,21 @@
*
* @param id id of the fihsing operation
* @return found catchbatch
+ * @throws CatchBatchValidationException
*/
- CatchBatch getCatchBatchFromFishingOperation(String id);
+ CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException;
/**
+ * Get the catchBatch from the fishing Operation id.
+ *
+ * @param id id of the fihsing operation
+ * @return found catchbatch
+ * @throws CatchBatchValidationException
+ */
+ @Transactional(readOnly = false)
+ CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId, boolean tryToRepair) throws CatchBatchValidationException;
+
+ /**
* Create the given CatchBatch and return it.
*
* @param bean catchBatch to create
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -24,8 +24,30 @@
* #L%
*/
+import java.sql.Timestamp;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.type.IntegerType;
+import org.hibernate.type.StringType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.stereotype.Service;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+
import fr.ifremer.adagio.core.dao.administration.programStrategy.ProgramDao;
import fr.ifremer.adagio.core.dao.administration.user.PersonDao;
import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip;
@@ -33,6 +55,7 @@
import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise;
import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruiseDao;
import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeatures;
+import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeaturesExtendDao;
import fr.ifremer.adagio.core.dao.referential.QualityFlag;
import fr.ifremer.adagio.core.dao.referential.QualityFlagDao;
import fr.ifremer.adagio.core.dao.referential.gear.GearDao;
@@ -48,27 +71,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import fr.ifremer.tutti.persistence.service.measure.MeasurementPersistenceHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.type.IntegerType;
-import org.hibernate.type.StringType;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataRetrievalFailureException;
-import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import java.sql.Timestamp;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
@@ -119,8 +122,8 @@
@Resource(name = "gearDao")
protected GearDao gearDao;
- @Resource(name = "measurementPersistenceHelper")
- protected MeasurementPersistenceHelper measurementHelper;
+ @Resource(name = "gearPhysicalFeaturesDao")
+ protected GearPhysicalFeaturesExtendDao gearPhysicalFeaturesDao;
protected Calendar calendar = new GregorianCalendar();
@@ -500,7 +503,7 @@
// Create or update a geaPhysicalFeatures for each gears in the cruise
for (int i = 0; i < source.getGear().size(); i++) {
Gear gear = source.getGear().get(i);
- GearPhysicalFeatures guf = measurementHelper.getGearPhysicalfeatures(fishingTrip, Integer.valueOf(gear.getId()), true);
+ GearPhysicalFeatures guf = gearPhysicalFeaturesDao.getGearPhysicalfeatures(fishingTrip, Integer.valueOf(gear.getId()), true);
notChangedGearPhysicalFeatures.remove(guf);
guf.setStartDate(fishingTrip.getDepartureDateTime());
@@ -513,9 +516,9 @@
// Trawl net (store in Gear Physical features)
if (copyIfNull && source.getMultirigNumber() == null) {
- measurementHelper.removeGearPhysicalMeasurement(guf, enumeration.PMFM_ID_MULTIRIG_NUMBER);
+ gearPhysicalFeaturesDao.removeGearPhysicalMeasurement(guf, enumeration.PMFM_ID_MULTIRIG_NUMBER);
} else {
- measurementHelper.setGearPhysicalMeasurement(target, guf, enumeration.PMFM_ID_MULTIRIG_NUMBER, Float.valueOf(source.getMultirigNumber()), null, null);
+ gearPhysicalFeaturesDao.setGearPhysicalMeasurement(target, guf, enumeration.PMFM_ID_MULTIRIG_NUMBER, Float.valueOf(source.getMultirigNumber()), null, null);
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -24,9 +24,34 @@
* #L%
*/
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.FlushMode;
+import org.hibernate.type.IntegerType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.stereotype.Service;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+
import fr.ifremer.adagio.core.dao.data.batch.denormalized.DenormalizedBatch;
import fr.ifremer.adagio.core.dao.data.fishingArea.FishingArea;
import fr.ifremer.adagio.core.dao.data.fishingArea.FishingArea2RegulationLocation;
@@ -44,6 +69,7 @@
import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise;
import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruiseDao;
import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeatures;
+import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeaturesExtendDao;
import fr.ifremer.adagio.core.dao.data.vessel.feature.use.GearUseFeatures;
import fr.ifremer.adagio.core.dao.data.vessel.feature.use.VesselUseFeatures;
import fr.ifremer.adagio.core.dao.data.vessel.feature.use.isActive;
@@ -61,34 +87,12 @@
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation;
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import fr.ifremer.tutti.persistence.service.measure.MeasurementPersistenceHelper;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.FlushMode;
-import org.hibernate.type.IntegerType;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataIntegrityViolationException;
-import org.springframework.dao.DataRetrievalFailureException;
-import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import java.io.Serializable;
-import java.sql.Timestamp;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
@@ -101,15 +105,15 @@
LogFactory.getLog(FishingOperationPersistenceServiceImpl.class);
- @Resource(name = "measurementPersistenceHelper")
- protected MeasurementPersistenceHelper measurementHelper;
-
@Autowired
protected ReferentialPersistenceService referentialService;
@Resource(name = "scientificCruiseDao")
protected ScientificCruiseDao scientificCruiseDao;
+ @Resource(name = "gearPhysicalFeaturesDao")
+ protected GearPhysicalFeaturesExtendDao gearPhysicalFeaturesDao;
+
@Resource(name = "fishingOperationDao")
protected FishingOperationDao fishingOperationDao;
@@ -166,9 +170,7 @@
}
if (fishingOperationNumberStr.matches("\\d+")) {
fishingOperation.setFishingOperationNumber(Integer.valueOf(fishingOperationNumberStr));
- } else {
- // TODO BL : invalid op.name format : log ?
- }
+ }
}
// If not found, compute it using a counter (see "order by startDateTime" in HQL query)
@@ -197,10 +199,7 @@
fishingOperation.setMultirigAggregation("1");
}
-
fishingOperations.add(fishingOperation);
- // TODO BLA: code utile juste pour les tests UI
- //fishingOperations.add(getFishingOperation(source[0].toString()));
}
return fishingOperations;
}
@@ -288,7 +287,6 @@
// Gear :
Integer gearId = (Integer) source[colIndex++];
if (gearId != null) {
- // TODO TC : activer un cache sur getGear()
fr.ifremer.tutti.persistence.entities.referential.Gear gear = referentialService.getGear(gearId);
result.setGear(gear);
}
@@ -421,7 +419,12 @@
// Haul valid ?
else if (enumeration.PMFM_ID_HAUL_VALID.equals(pmfmId)) {
- result.setFishingOperationValid(enumeration.QUALITATIVE_HAUL_VALID_YES.equals(qualitativeValueId));
+ if (qualitativeValueId != null) {
+ result.setFishingOperationValid(enumeration.QUALITATIVE_HAUL_VALID_YES.equals(qualitativeValueId));
+ }
+ else {
+ result.setFishingOperationValid(null);
+ }
}
// Station Number :
@@ -438,7 +441,12 @@
} else if (environmentCaracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
value = alphanumericalValue;
} else if (environmentCaracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
- value = qualitativeValueId;
+ for (CaracteristicQualitativeValue qv : environmentCaracteristic.getQualitativeValue()) {
+ if (qualitativeValueId == Integer.parseInt(qv.getId())) {
+ value = qv;
+ break;
+ }
+ }
}
environmentCaracteristics.put(environmentCaracteristic, value);
}
@@ -481,7 +489,12 @@
} else if (gearShootingCaracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
value = alphanumericalValue;
} else if (gearShootingCaracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
- value = qualitativeValueId;
+ for (CaracteristicQualitativeValue qv : gearShootingCaracteristic.getQualitativeValue()) {
+ if (qualitativeValueId == Integer.parseInt(qv.getId())) {
+ value = qv;
+ break;
+ }
+ }
}
gearShootingCaracteristics.put(gearShootingCaracteristic, value);
}
@@ -565,7 +578,7 @@
// Retrieve entities : Gear Physical Features
GearPhysicalFeatures gearPhysicalFeatures = target.getGearPhysicalFeatures();
if (gearPhysicalFeatures == null && source.getGear() != null && source.getGear().getId() != null) {
- gearPhysicalFeatures = measurementHelper.getGearPhysicalfeatures(fishingTrip, Integer.valueOf(source.getGear().getId()));
+ gearPhysicalFeatures = gearPhysicalFeaturesDao.getGearPhysicalfeatures(fishingTrip, Integer.valueOf(source.getGear().getId()));
if (gearPhysicalFeatures == null) {
throw new DataIntegrityViolationException("An operation could not use a gear that is not declared in the cruise.");
}
@@ -607,7 +620,7 @@
// Retrieve multirig number, from Gear physical features
int cruiseMultirigCount = 1; // default value
if (gearPhysicalFeatures != null) {
- GearPhysicalMeasurement gpmMultirigCount = measurementHelper.getGearPhysicalMeasurement(gearPhysicalFeatures, enumeration.PMFM_ID_MULTIRIG_NUMBER);
+ GearPhysicalMeasurement gpmMultirigCount = gearPhysicalFeaturesDao.getGearPhysicalMeasurement(gearPhysicalFeatures, enumeration.PMFM_ID_MULTIRIG_NUMBER);
if (gpmMultirigCount != null && gpmMultirigCount.getNumericalValue() != null) {
cruiseMultirigCount = gpmMultirigCount.getNumericalValue().intValue();
}
@@ -1136,11 +1149,11 @@
} else if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
measurement.setNumericalValue((Float) value);
} else if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
- Integer qvId;
- if (value instanceof Integer) {
+ Integer qvId = null;
+ if (value instanceof CaracteristicQualitativeValue) {
+ qvId = Integer.valueOf(((CaracteristicQualitativeValue) value).getId());
+ } else if (value instanceof Integer) {
qvId = (Integer) value;
- } else {
- qvId = Integer.valueOf(value.toString());
}
QualitativeValue qv = load(QualitativeValueImpl.class, qvId);
measurement.setQualitativeValue(qv);
@@ -1159,7 +1172,7 @@
} else if (numericalValue != null) {
gearUseMeasurement.setNumericalValue(numericalValue);
} else if (qualitativevalueId != null) {
- QualitativeValue qv = (QualitativeValue) getCurrentSession().load(QualitativeValueImpl.class, qualitativevalueId);
+ QualitativeValue qv = load(QualitativeValueImpl.class, qualitativevalueId);
gearUseMeasurement.setQualitativeValue(qv);
}
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -0,0 +1,253 @@
+package fr.ifremer.tutti.persistence.service.batch;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.stereotype.Component;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import fr.ifremer.adagio.core.dao.data.batch.Batch;
+import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
+import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
+import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchQuickFix;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationError;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidator;
+import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
+import fr.ifremer.tutti.persistence.service.BatchPersistenceService;
+import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
+
+@Component(value = "scientificCruiseCatchBatchValidator")
+public class ScientificCruiseCatchBatchValidator implements CatchBatchValidator {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ScientificCruiseCatchBatchValidator.class);
+
+ @Autowired
+ protected BatchPersistenceService batchService;
+
+ @Autowired
+ protected ReferentialPersistenceService referentialService;
+
+ @Autowired
+ protected CatchBatchExtendDao catchBatchDao;
+
+ @Autowired
+ protected TuttiEnumerationFile enumeration;
+
+ public ScientificCruiseCatchBatchValidator() {
+ }
+
+ @Override
+ public boolean isEnable(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
+ // Apply validation only on catch batch for fishingOperation
+ return (catchBatch.getFishingOperation() != null);
+ }
+
+ @Override
+ public List<CatchBatchValidationError> validate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
+ List<CatchBatchValidationError> errors = Lists.newArrayList();
+ validate(catchBatch.getChildBatchs(), errors, 1);
+ return errors;
+ }
+
+ // ------------------------------------------------------------------------//
+ // -- Internal methods --//
+ // ------------------------------------------------------------------------//
+
+ protected void validate(Collection<Batch> batchs, List<CatchBatchValidationError> errors, int treeLevel) {
+
+ // Vrac
+ SortingBatch vracBatch = catchBatchDao.getSortingBatch(batchs,
+ "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID);
+ if (vracBatch == null) {
+ addError(errors, "tutti.persistence.batch.validation.vracNotFound", null);
+ } else {
+ // Vrac > Species
+ SortingBatch speciesBatch = catchBatchDao.getSortingBatch(vracBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ if (speciesBatch == null) {
+ addError(errors, "tutti.persistence.batch.validation.vracSpeciesNotFound", null);
+ } else {
+ // Vrac > Species > Inert
+ SortingBatch inertBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(),
+ "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_INERT);
+ if (inertBatch == null) {
+ addWarning(errors, "tutti.persistence.batch.validation.vracSpeciesInertNotFound");
+ }
+
+ // Vrac > Species > Alive no itemized
+ SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(),
+ "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_LIFE);
+ if (livingNotItemizedBatch == null) {
+ addWarning(errors, "tutti.persistence.batch.validation.vracSpeciesLifeNotFound");
+ }
+ }
+
+ // TODO : Benthos, Plancton...
+ }
+
+ // Hors Vrac
+ SortingBatch horsVracBatch = catchBatchDao.getSortingBatch(batchs,
+ "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED,
+ enumeration.QUALITATIVE_HORS_VRAC_ID);
+ if (horsVracBatch == null) {
+ addWarning(errors, "tutti.persistence.batch.validation.horsVracSpeciesNotFound");
+ } else {
+ // Hors Vrac > Species
+ SortingBatch speciesBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ if (speciesBatch == null) {
+ addWarning(errors, "tutti.persistence.batch.validation.horsVracSpeciesNotFound");
+ }
+
+ // TODO : Benthos, Plancton...
+ }
+
+ // Unsorted
+ SortingBatch unsortedBatch = catchBatchDao.getSortingBatch(batchs,
+ "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED,
+ enumeration.QUALITATIVE_UNSORTED_ID);
+ if (unsortedBatch == null) {
+ addWarning(errors, "tutti.persistence.batch.validation.unsortedNotFound");
+ }
+
+ // May be, the tree is an old structure
+ if (vracBatch == null && horsVracBatch == null && unsortedBatch == null) {
+ boolean allBatchHasSpecies = true;
+ boolean allBatchHasVrac = true;
+ boolean someBatchHasSortingMeasurement = false;
+ for (Iterator<Batch> iterator = batchs.iterator(); iterator.hasNext();) {
+ SortingBatch batch = (SortingBatch) iterator.next();
+ if (allBatchHasSpecies && batch.getReferenceTaxon() == null) {
+ allBatchHasSpecies = false;
+ break;
+ }
+ if (allBatchHasVrac && batch.getSortingMeasurements() != null) {
+ if (batch.getSortingMeasurements().size() > 1) {
+ allBatchHasVrac = false;
+ someBatchHasSortingMeasurement = true;
+ }
+ else if (batch.getSortingMeasurements().size() == 1) {
+ someBatchHasSortingMeasurement = true;
+ SortingMeasurement sm = batch.getSortingMeasurements().iterator().next();
+ if (enumeration.PMFM_ID_SORTED_UNSORTED.equals(sm.getPmfm().getId()) == false
+ || sm.getQualitativeValue() == null
+ || enumeration.QUALITATIVE_VRAC_ID.equals(sm.getQualitativeValue().getId()) == false) {
+ allBatchHasVrac = false;
+ }
+ }
+ }
+ }
+ if (allBatchHasSpecies && !someBatchHasSortingMeasurement) {
+ errors.clear();
+ addError(errors, "tutti.persistence.batch.validation.onlySpeciesBatchStructure", new CatchBatchQuickFix() {
+ @Override
+ public CatchBatch repair(CatchBatch catchBatch) {
+ return ScientificCruiseCatchBatchValidator.this.repairHistoricalData(catchBatch, false);
+ }
+ });
+ }
+ else if (allBatchHasSpecies && someBatchHasSortingMeasurement && allBatchHasVrac) {
+ errors.clear();
+ addError(errors, "tutti.persistence.batch.validation.onlySpeciesBatchStructure", new CatchBatchQuickFix() {
+ @Override
+ public CatchBatch repair(CatchBatch catchBatch) {
+ return ScientificCruiseCatchBatchValidator.this.repairHistoricalData(catchBatch, true);
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Repair tree batch, when only species have been found under the cacth batch.
+ * This append typically with CGFS cruise.
+ * @param catchBatch
+ * @return
+ */
+ protected CatchBatch repairHistoricalData(CatchBatch catchBatch, boolean batchHasVracSortingMeasurement) {
+ Preconditions.checkNotNull(catchBatch);
+ Preconditions.checkNotNull(catchBatch.getId());
+ Preconditions.checkNotNull(catchBatch.getFishingOperation());
+ Preconditions.checkNotNull(catchBatch.getFishingOperation().getId());
+
+ // Copy catch batch children
+ Collection<Batch> speciesBatchChilds = Sets.newHashSet();
+ speciesBatchChilds.addAll(catchBatch.getChildBatchs());
+ catchBatch.setChildBatchs(new HashSet<Batch>());
+
+ // Clean catch batch
+ batchService.cleanEntity(catchBatch, true);
+
+ SortingBatch speciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ if (speciesBatch == null) {
+ throw new DataIntegrityViolationException("Invalid batch tree format. Could not retrieve 'Vrac>Species' batch.");
+ }
+
+ // For all species batch : set the batch 'Vrac>Species' as new parent
+ for (Iterator<Batch> iterator = speciesBatchChilds.iterator(); iterator.hasNext();) {
+ SortingBatch batch = (SortingBatch) iterator.next();
+ batch.setParentBatch(speciesBatch);
+
+ if (batchHasVracSortingMeasurement) {
+ // Remove redundant 'Vrac' sorting measurement
+ SortingMeasurement sm = catchBatchDao.getSortingMeasurement(batch, enumeration.PMFM_ID_SORTED_UNSORTED, null, false);
+ batch.getSortingMeasurements().remove(sm);
+ }
+
+ batch.setExhaustiveInventory(Boolean.TRUE);
+
+ // Add an offset into the rank order, because of special batchs 'Biota' (=live) and 'Inert'
+ short rankOrder = (short)(batch.getRankOrder().shortValue() + 2);
+ batch.setRankOrder(rankOrder);
+
+ // Reset comments if set to "taxon"
+ if (batch.getComments() != null && "taxon".equals(batch.getComments())) {
+ batch.setComments(null);
+ }
+
+ speciesBatch.getChildBatchs().add(batch);
+ }
+
+ // Save mofidifications :
+ catchBatchDao.update(catchBatch);
+
+ return catchBatch;
+ }
+
+ protected void addError(List<CatchBatchValidationError> errors, String messageKey, CatchBatchQuickFix quickFix) {
+ CatchBatchValidationError error = new CatchBatchValidationError(
+ messageKey,
+ _(messageKey),
+ CatchBatchValidationError.GRAVITY_ERROR);
+ error.setQuickFixes(Lists.newArrayList(quickFix));
+ errors.add(error);
+ }
+
+ protected void addWarning(List<CatchBatchValidationError> errors, String messageKey) {
+ CatchBatchValidationError error = new CatchBatchValidationError(
+ messageKey,
+ _(messageKey),
+ CatchBatchValidationError.GRAVITY_WARNING);
+ errors.add(error);
+ }
+
+}
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-02-25 14:11:54 UTC (rev 461)
@@ -12,7 +12,11 @@
tutti.option.persistence.jdbc.url.description=URL de connexion à la base de données
tutti.option.persistence.jdbc.username.description=Login de l'utilisateur pour se connecter à la base de données
tutti.option.persistence.protocol.directory.description=Répertoire où sont conservés les protocoles
-tutti.persistence.batch.validation.onlyTaxonButPmfmFound=Batch [id\=%s] should not have any sorting measurement (should only have a reference taxon), but found pmfm [id\=%s].
-tutti.persistence.batch.validation.pmfmNotFound=Batch [id\=%s] should have a sorting measurement with a pmfm id in %s or a length pmfm, but found pmfm [id\=%s].
-tutti.persistence.batch.validation.referenceTaxonNotFound=Batch [id\=%s] should have a reference taxon.
+tutti.persistence.batch.validation.horsVracNotFound=Lot 'Hors Vrac' non trouvé, ou configuré avec d'autres critères de classement.
+tutti.persistence.batch.validation.horsVracSpeciesNotFound=Batch 'Hors Vrac > Espèces' non trouvé ou configuré avec d'autres critères de classement.
+tutti.persistence.batch.validation.unsortedNotFound=Batch 'Hors Vrac > Espèces' non trouvé ou configuré avec d'autres critères de classement.
+tutti.persistence.batch.validation.vracNotFound=Lot 'Vrac' non trouvé, ou configuré avec d'autres critères de classement.
+tutti.persistence.batch.validation.vracSpeciesInertNotFound=Lot 'Vrac > Espèces > Inerte' non trouvé, ou configuré avec d'autres critères de classement.
+tutti.persistence.batch.validation.vracSpeciesLifeNotFound=Lot 'Vrac > Espèces > Biota' non trouvé, ou configuré avec d'autres critères de classement.
+tutti.persistence.batch.validation.vracSpeciesNotFound=Lot 'Vrac > Espèces' non trouvé, ou configuré avec d'autres critères de classement.
tutti.persistence.config=Configuration de la persistence de Tutti
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -24,8 +24,28 @@
* #L%
*/
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.springframework.dao.DataRetrievalFailureException;
+
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.DatabaseResource;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
@@ -37,586 +57,587 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.springframework.dao.DataRetrievalFailureException;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
/**
* To test {@link CatchBatchPersistenceService} for write operation.
- *
+ *
* @author tchemit <chemit(a)codelutin.com>
* @since 1.0
*/
public class BatchPersistenceServiceWriteTest {
- @ClassRule
- public static final DatabaseResource dbResource = DatabaseResource.writeDb();
+ @ClassRule
+ public static final DatabaseResource dbResource = DatabaseResource.writeDb();
- protected BatchPersistenceService service;
+ protected BatchPersistenceService service;
- protected CruisePersistenceService cruiseService;
+ protected CruisePersistenceService cruiseService;
- protected FishingOperationPersistenceService fishingOperationService;
+ protected FishingOperationPersistenceService fishingOperationService;
- protected CatchBatchPersistenceService catchBatchService;
+ protected CatchBatchPersistenceService catchBatchService;
- protected ReferentialPersistenceService referentialService;
+ protected ReferentialPersistenceService referentialService;
+
+ /*
+ * Entities prepared in setUp() :
+ * */
+ protected Cruise cruise;
- protected Cruise cruise;
+ protected FishingOperation fishingOperationNoCatchBatch;
- protected FishingOperation fishingOperationNoCatchBatch;
+ protected FishingOperation fishingOperationWithEmptyBatch;
- protected FishingOperation fishingOperationWithEmptyBatch;
+ protected CatchBatch catchBacth;
- protected CatchBatch catchBacth;
+ protected List<Species> species;
- protected List<Species> species;
+ protected Caracteristic sortedUnsortedPMFM;
- protected Caracteristic sortedUnsortedPMFM;
+ protected CaracteristicQualitativeValue horsVracQualitativeValue;
- protected CaracteristicQualitativeValue horsVracQualitativeValue;
+ protected CaracteristicQualitativeValue vracQualitativeValue;
- protected CaracteristicQualitativeValue vracQualitativeValue;
+ protected Caracteristic maturityPMFM;
- protected Caracteristic maturityPMFM;
+ protected CaracteristicQualitativeValue firstMaturityQualitativeValue;
- protected CaracteristicQualitativeValue firstMaturityQualitativeValue;
+ protected Caracteristic sexPMFM;
- protected Caracteristic sexPMFM;
+ protected CaracteristicQualitativeValue maleQualitativeValue;
- protected CaracteristicQualitativeValue maleQualitativeValue;
+ protected CaracteristicQualitativeValue femaleQualitativeValue;
- protected CaracteristicQualitativeValue femaleQualitativeValue;
+ protected CaracteristicQualitativeValue unkQualitativeValue;
- protected CaracteristicQualitativeValue unkQualitativeValue;
+ protected Caracteristic frequencyPMFM;
- protected Caracteristic frequencyPMFM;
+ @Before
+ public void setUp() throws Exception {
+ service = TuttiPersistenceServiceLocator.getBatchPersistenceService();
+ cruiseService = TuttiPersistenceServiceLocator.getCruisePersistenceService();
+ fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
+ catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
+ referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
- @Before
- public void setUp() throws Exception {
- service = TuttiPersistenceServiceLocator.getBatchPersistenceService();
- cruiseService = TuttiPersistenceServiceLocator.getCruisePersistenceService();
- fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
- catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
- referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
+ species = referentialService.getAllSpecies();
+ assertNotNull(species);
+ assertTrue(species.size() > 2);
- species = referentialService.getAllSpecies();
- assertNotNull(species);
- assertTrue(species.size() > 2);
+ cruise = cruiseService.getCruise(dbResource.getFixtures().cruiseId());
+ cruise.setId(null);
+ Calendar calendar = new GregorianCalendar();
+ cruise.setBeginDate(calendar.getTime());
+ cruise.setYear(calendar.get(Calendar.YEAR));
+ calendar.add(Calendar.MONTH, 1); // add one month
+ cruise.setEndDate(calendar.getTime());
+ cruise = cruiseService.createCruise(cruise);
- cruise = cruiseService.getCruise(dbResource.getFixtures().cruiseId());
- cruise.setId(null);
- Calendar calendar = new GregorianCalendar();
- cruise.setBeginDate(calendar.getTime());
- cruise.setYear(calendar.get(Calendar.YEAR));
- calendar.add(Calendar.MONTH, 1); // add one month
- cruise.setEndDate(calendar.getTime());
- cruise = cruiseService.createCruise(cruise);
+ // Create a first operation, with no cacth batch : to test CatchBatch insert/update :
+ List<FishingOperation> fishingOperations = fishingOperationService.getAllFishingOperation(dbResource.getFixtures().cruiseId());
+ assertNotNull(fishingOperations);
+ assertTrue(fishingOperations.size() > 0);
+ fishingOperationNoCatchBatch = fishingOperations.get(0);
+ fishingOperationNoCatchBatch = fishingOperationService.getFishingOperation(fishingOperationNoCatchBatch.getId());
+ fishingOperationNoCatchBatch.setId(null);
+ fishingOperationNoCatchBatch.setCruise(cruise);
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY, 1);
+ calendar.set(Calendar.MILLISECOND, 0);
+ fishingOperationNoCatchBatch.setGearShootingStartDate(calendar.getTime());
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY, 10);
+ calendar.set(Calendar.MILLISECOND, 0);
+ fishingOperationNoCatchBatch.setGearShootingEndDate(calendar.getTime());
+ fishingOperationNoCatchBatch = fishingOperationService.createFishingOperation(fishingOperationNoCatchBatch);
- // Create a first operation, with no cacth batch : to test CatchBatch insert/update :
- List<FishingOperation> fishingOperations = fishingOperationService.getAllFishingOperation(dbResource.getFixtures().cruiseId());
- assertNotNull(fishingOperations);
- assertTrue(fishingOperations.size() > 0);
- fishingOperationNoCatchBatch = fishingOperations.get(0);
- fishingOperationNoCatchBatch = fishingOperationService.getFishingOperation(fishingOperationNoCatchBatch.getId());
- fishingOperationNoCatchBatch.setId(null);
- fishingOperationNoCatchBatch.setCruise(cruise);
- calendar.setTime(new Date());
- calendar.set(Calendar.HOUR_OF_DAY, 1);
- calendar.set(Calendar.MILLISECOND, 0);
- fishingOperationNoCatchBatch.setGearShootingStartDate(calendar.getTime());
- calendar.setTime(new Date());
- calendar.set(Calendar.HOUR_OF_DAY, 10);
- calendar.set(Calendar.MILLISECOND, 0);
- fishingOperationNoCatchBatch.setGearShootingEndDate(calendar.getTime());
- fishingOperationNoCatchBatch = fishingOperationService.createFishingOperation(fishingOperationNoCatchBatch);
+ // Create a second operation, with no cacth batch : to test CatchBatch insert/update :
+ fishingOperationWithEmptyBatch = fishingOperations.get(1);
+ fishingOperationWithEmptyBatch = fishingOperationService.getFishingOperation(fishingOperationWithEmptyBatch.getId());
+ fishingOperationWithEmptyBatch.setId(null);
+ fishingOperationWithEmptyBatch.setCruise(cruise);
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY, 11);
+ calendar.set(Calendar.MILLISECOND, 0);
+ fishingOperationWithEmptyBatch.setGearShootingStartDate(calendar.getTime());
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY, 12);
+ calendar.set(Calendar.MILLISECOND, 0);
+ fishingOperationWithEmptyBatch.setGearShootingEndDate(calendar.getTime());
+ fishingOperationWithEmptyBatch = fishingOperationService.createFishingOperation(fishingOperationWithEmptyBatch);
- // Create a second operation, with no cacth batch : to test CatchBatch insert/update :
- fishingOperationWithEmptyBatch = fishingOperations.get(1);
- fishingOperationWithEmptyBatch = fishingOperationService.getFishingOperation(fishingOperationWithEmptyBatch.getId());
- fishingOperationWithEmptyBatch.setId(null);
- fishingOperationWithEmptyBatch.setCruise(cruise);
- calendar.setTime(new Date());
- calendar.set(Calendar.HOUR_OF_DAY, 11);
- calendar.set(Calendar.MILLISECOND, 0);
- fishingOperationWithEmptyBatch.setGearShootingStartDate(calendar.getTime());
- calendar.setTime(new Date());
- calendar.set(Calendar.HOUR_OF_DAY, 12);
- calendar.set(Calendar.MILLISECOND, 0);
- fishingOperationWithEmptyBatch.setGearShootingEndDate(calendar.getTime());
- fishingOperationWithEmptyBatch = fishingOperationService.createFishingOperation(fishingOperationWithEmptyBatch);
+ catchBacth = new CatchBatch();
+ catchBacth.setFishingOperation(fishingOperationWithEmptyBatch);
+ catchBacth = catchBatchService.createCatchBatch(catchBacth);
- catchBacth = new CatchBatch();
- catchBacth.setFishingOperation(fishingOperationWithEmptyBatch);
- catchBacth = catchBatchService.createCatchBatch(catchBacth);
+ sortedUnsortedPMFM = referentialService.getSortedUnsortedCaracteristic();
+ horsVracQualitativeValue = sortedUnsortedPMFM.getQualitativeValue(0);
+ vracQualitativeValue = sortedUnsortedPMFM.getQualitativeValue(1);
+ maturityPMFM = referentialService.getMaturityCaracteristic();
+ firstMaturityQualitativeValue = maturityPMFM.getQualitativeValue(0);
+ sexPMFM = referentialService.getSexCaracteristic();
+ maleQualitativeValue = sexPMFM.getQualitativeValue(1);
+ femaleQualitativeValue = sexPMFM.getQualitativeValue(2);
+ unkQualitativeValue = sexPMFM.getQualitativeValue(3);
- sortedUnsortedPMFM = referentialService.getSortedUnsortedCaracteristic();
- horsVracQualitativeValue = sortedUnsortedPMFM.getQualitativeValue(0);
- vracQualitativeValue = sortedUnsortedPMFM.getQualitativeValue(1);
- maturityPMFM = referentialService.getMaturityCaracteristic();
- firstMaturityQualitativeValue = maturityPMFM.getQualitativeValue(0);
- sexPMFM = referentialService.getSexCaracteristic();
- maleQualitativeValue = sexPMFM.getQualitativeValue(1);
- femaleQualitativeValue = sexPMFM.getQualitativeValue(2);
- unkQualitativeValue = sexPMFM.getQualitativeValue(3);
+ List<Caracteristic> cara = referentialService.getAllCaracteristic();
+ for (Caracteristic caracteristic : cara) {
+ if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER
+ && caracteristic.getPrecision() != null
+ && caracteristic.getPrecision() == 0.5f) {
+ frequencyPMFM = caracteristic;
+ break;
+ }
+ }
+ assertNotNull("no numerical PMFM with a precision has been found. Could not define a PMFM for batch frequencies.", frequencyPMFM);
- List<Caracteristic> cara = referentialService.getAllCaracteristic();
- for (Caracteristic caracteristic : cara) {
- if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER
- && caracteristic.getPrecision() != null
- && caracteristic.getPrecision() == 0.5f) {
- frequencyPMFM = caracteristic;
- break;
- }
- }
- assertNotNull("no numerical PMFM with a precision has been found. Could not define a PMFM for batch frequencies.", frequencyPMFM);
+ }
- }
+ @Test
+ public void createAndSaveCatchBatch() throws Exception {
+ CatchBatch catchBatch;
- @Test
- public void createAndSaveCatchBatch() throws Exception {
- CatchBatch catchBatch;
+ catchBatch = new CatchBatch();
+ catchBatch.setFishingOperation(fishingOperationNoCatchBatch);
- catchBatch = new CatchBatch();
- catchBatch.setFishingOperation(fishingOperationNoCatchBatch);
+ // -----------------------------------------------------------------------------
+ // 1. Test with only mandatory properties
+ // -----------------------------------------------------------------------------
- // -----------------------------------------------------------------------------
- // 1. Test with only mandatory properties
- // -----------------------------------------------------------------------------
+ // Create and reload (test round trip)
+ assertCreateAndReloadCatchBatch(catchBatch, fishingOperationNoCatchBatch.getId());
- // Create and reload (test round trip)
- assertCreateAndReloadCatchBatch(catchBatch, fishingOperationNoCatchBatch.getId());
+ // -----------------------------------------------------------------------------
+ // 2. Test with all properties
+ // -----------------------------------------------------------------------------
+ catchBatch.setId(null);
+ // total weight : 100kg
+ catchBatch.setCatchTotalWeight(75f);
+ // Vrac :
+ {
+ // note : poids trie par la balance tremis (thalassa) (init par pupitri)
+ catchBatch.setCatchTotalSortedTremisWeight(50f);
+ // note : poids vrac caroussel (thalassa) (init par pupitri) (vrac trie) ou bien "poids trié fournie par la
+ // table de tri (Sum(Si)
+ catchBatch.setCatchTotalSortedCarousselWeight(45f);
- // -----------------------------------------------------------------------------
- // 2. Test with all properties
- // -----------------------------------------------------------------------------
- catchBatch.setId(null);
- // total weight : 100kg
- catchBatch.setCatchTotalWeight(75f);
- // Vrac :
- {
- // note : poids trie par la balance tremis (thalassa) (init par pupitri)
- catchBatch.setCatchTotalSortedTremisWeight(50f);
- // note : poids vrac caroussel (thalassa) (init par pupitri) (vrac trie) ou bien "poids trié fournie par la table de tri (Sum(Si)
- catchBatch.setCatchTotalSortedCarousselWeight(45f);
+ // Species
+ {
+ catchBatch.setSpeciesTotalSortedWeight(12f);
+ catchBatch.setSpeciesTotalSampleSortedWeight(8f);
+ catchBatch.setSpeciesTotalLivingNotItemizedWeight(0.2f);
+ catchBatch.setSpeciesTotalInertWeight(0.1f);
+ }
+ }
+ // Hors Vrac : 10kg
+ {
+ catchBatch.setCatchTotalUnsortedWeight(10f);
- // Species
- {
- catchBatch.setSpeciesTotalSortedWeight(12f);
- catchBatch.setSpeciesTotalSampleSortedWeight(8f);
- catchBatch.setSpeciesTotalLivingNotItemizedWeight(0.2f);
- catchBatch.setSpeciesTotalInertWeight(0.1f);
- }
- }
- // Hors Vrac : 10kg
- {
- catchBatch.setCatchTotalUnsortedWeight(10f);
+ // Species
+ {
+ catchBatch.setSpeciesTotalUnsortedWeight(10f);
+ }
+ }
+ // Rejet : 15kg
+ catchBatch.setCatchTotalRejectedWeight(15f);
- // Species
- {
- catchBatch.setSpeciesTotalUnsortedWeight(10f);
- }
- }
- // Rejet : 15kg
- catchBatch.setCatchTotalRejectedWeight(15f);
+ // Create and reload (test round trip)
+ assertCreateAndReloadCatchBatch(catchBatch, fishingOperationNoCatchBatch.getId());
- // Create and reload (test round trip)
- assertCreateAndReloadCatchBatch(catchBatch, fishingOperationNoCatchBatch.getId());
+ // -----------------------------------------------------------------------------
+ // 2. Test save after modification
+ // -----------------------------------------------------------------------------
+ catchBatch.setCatchTotalSortedTremisWeight(null);
+ catchBatch.setCatchTotalSortedCarousselWeight(null);
+ catchBatch.setSpeciesTotalSortedWeight(null);
+ catchBatch.setSpeciesTotalSampleSortedWeight(null);
+ catchBatch.setCatchTotalUnsortedWeight(null);
+ catchBatch.setSpeciesTotalUnsortedWeight(null);
- // -----------------------------------------------------------------------------
- // 2. Test save after modification
- // -----------------------------------------------------------------------------
- catchBatch.setCatchTotalSortedTremisWeight(null);
- catchBatch.setCatchTotalSortedCarousselWeight(null);
- catchBatch.setSpeciesTotalSortedWeight(null);
- catchBatch.setSpeciesTotalSampleSortedWeight(null);
- catchBatch.setCatchTotalUnsortedWeight(null);
- catchBatch.setSpeciesTotalUnsortedWeight(null);
+ assertSaveAndReloadCatchBatch(catchBatch, fishingOperationNoCatchBatch.getId());
+ }
- assertSaveAndReloadCatchBatch(catchBatch, fishingOperationNoCatchBatch.getId());
- }
+ @Test
+ public void createAndSaveSpeciesBatchAndFrequencies() {
+ SpeciesBatch esp1Batch = null;
+ SpeciesBatch esp2Batch = null;
+ SpeciesBatch frequenciesParentBatch = null;
+ SpeciesBatch batch = null;
+ Species taxon1 = species.get(0);
+ Species taxon2 = species.get(1);
- @Test
- public void createAndSaveSpeciesBatchAndFrequencies() {
- SpeciesBatch esp1Batch = null;
- SpeciesBatch esp2Batch = null;
- SpeciesBatch frequenciesParentBatch = null;
- SpeciesBatch batch = null;
- Species taxon1 = species.get(0);
- Species taxon2 = species.get(1);
+ // -----------------------------------------------------------------------------
+ // 1. Test with only mandatory properties
+ // -----------------------------------------------------------------------------
+ // batch : "ESP1 - Vrac/5"
+ batch = new SpeciesBatch();
+ batch.setParentBatch(null);
+ batch.setFishingOperation(fishingOperationNoCatchBatch);
+ batch.setSpecies(taxon1);
+ batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
+ batch.setSampleCategoryValue(vracQualitativeValue);
+ batch.setSampleCategoryWeight(5f);
- // -----------------------------------------------------------------------------
- // 1. Test with only mandatory properties
- // -----------------------------------------------------------------------------
- // batch : "ESP1 - Vrac/5"
- batch = new SpeciesBatch();
- batch.setParentBatch(null);
- batch.setFishingOperation(fishingOperationNoCatchBatch);
- batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
- batch.setSampleCategoryValue(vracQualitativeValue);
- batch.setSampleCategoryWeight(5f);
+ assertCreateAndReloadSpeciesBatch(batch, null);
- assertCreateAndReloadSpeciesBatch(batch, null);
+ // Save ESP1 batch
+ esp1Batch = batch;
- // Save ESP1 batch
- esp1Batch = batch;
+ // -----------------------------------------------------------------------------
+ // 2. Test child "Male/2"
+ // -----------------------------------------------------------------------------
+ // Batch : ESP1 - Vrac/5 Male/2 ss-ech/1 Nombre/7
+ batch = new SpeciesBatch();
+ batch.setId(null);
+ batch.setParentBatch(esp1Batch);
+ batch.setSpecies(taxon1);
+ batch.setComment("ESP1 - Vrac/5 Male/2 ss-ech/1 Nombre/7");
+ batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryValue(maleQualitativeValue);
+ batch.setSampleCategoryWeight(2f);
+ batch.setWeight(1f);
+ batch.setNumber(7);
- // -----------------------------------------------------------------------------
- // 2. Test child "Male/2"
- // -----------------------------------------------------------------------------
- // Batch : ESP1 - Vrac/5 Male/2 ss-ech/1 Nombre/7
- batch = new SpeciesBatch();
- batch.setId(null);
- batch.setParentBatch(esp1Batch);
- batch.setSpecies(taxon1);
- batch.setComment("ESP1 - Vrac/5 Male/2 ss-ech/1 Nombre/7");
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
- batch.setSampleCategoryValue(maleQualitativeValue);
- batch.setSampleCategoryWeight(2f);
- batch.setWeight(1f);
- batch.setNumber(7);
+ assertCreateAndReloadSpeciesBatch(batch, batch.getParentBatch().getId());
- assertCreateAndReloadSpeciesBatch(batch, batch.getParentBatch().getId());
+ // -----------------------------------------------------------------------------
+ // 3. Test child "Female/2"
+ // -----------------------------------------------------------------------------
+ // Batch : ESP1 - Vrac/5 Female/3 Nombre/14
+ batch = new SpeciesBatch();
+ batch.setId(null);
+ batch.setParentBatch(esp1Batch);
+ batch.setSpecies(taxon1);
+ batch.setComment("ESP1 - Vrac/5 Female/3 Nombre/14");
+ batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryValue(femaleQualitativeValue);
+ batch.setSampleCategoryWeight(3f);
+ batch.setWeight(null);
+ batch.setNumber(14);
- // -----------------------------------------------------------------------------
- // 3. Test child "Female/2"
- // -----------------------------------------------------------------------------
- // Batch : ESP1 - Vrac/5 Female/3 Nombre/14
- batch = new SpeciesBatch();
- batch.setId(null);
- batch.setParentBatch(esp1Batch);
- batch.setSpecies(taxon1);
- batch.setComment("ESP1 - Vrac/5 Female/3 Nombre/14");
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
- batch.setSampleCategoryValue(femaleQualitativeValue);
- batch.setSampleCategoryWeight(3f);
- batch.setWeight(null);
- batch.setNumber(14);
+ assertCreateAndReloadSpeciesBatch(batch, batch.getParentBatch().getId());
- assertCreateAndReloadSpeciesBatch(batch, batch.getParentBatch().getId());
+ // -----------------------------------------------------------------------------
+ // 4. Test : ESP2 - Vrac/7
+ // \- ESP2 - Vrac/7 UNK/2 ss-ech/1 Nombre/11
+ // -----------------------------------------------------------------------------
+ // batch : "ESP2 - Vrac/7 "
+ batch = new SpeciesBatch();
+ batch.setParentBatch(null);
+ batch.setSpecies(taxon2);
+ batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
+ batch.setSampleCategoryValue(vracQualitativeValue);
+ batch.setSampleCategoryWeight(7f);
- // -----------------------------------------------------------------------------
- // 4. Test : ESP2 - Vrac/7
- // \- ESP2 - Vrac/7 UNK/2 ss-ech/1 Nombre/11
- // -----------------------------------------------------------------------------
- // batch : "ESP2 - Vrac/7 "
- batch = new SpeciesBatch();
- batch.setParentBatch(null);
- batch.setSpecies(taxon2);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
- batch.setSampleCategoryValue(vracQualitativeValue);
- batch.setSampleCategoryWeight(7f);
+ assertCreateAndReloadSpeciesBatch(batch, null);
+ esp2Batch = batch;
- assertCreateAndReloadSpeciesBatch(batch, null);
- esp2Batch = batch;
+ // Batch : ESP2 - Vrac/7 UNK/2 ss-ech/1 Nombre/11
+ batch = new SpeciesBatch();
+ batch.setId(null);
+ batch.setParentBatch(esp2Batch);
+ batch.setSpecies(taxon2);
+ batch.setComment("ESP2 - Vrac/7 UNK/2 ss-ech/1 Nombre/11");
+ batch.setSampleCategoryType(SampleCategoryEnum.maturity);
+ batch.setSampleCategoryValue(firstMaturityQualitativeValue);
+ batch.setSampleCategoryWeight(2f);
+ batch.setWeight(1f);
+ batch.setNumber(11);
- // Batch : ESP2 - Vrac/7 UNK/2 ss-ech/1 Nombre/11
- batch = new SpeciesBatch();
- batch.setId(null);
- batch.setParentBatch(esp2Batch);
- batch.setSpecies(taxon2);
- batch.setComment("ESP2 - Vrac/7 UNK/2 ss-ech/1 Nombre/11");
- batch.setSampleCategoryType(SampleCategoryEnum.maturity);
- batch.setSampleCategoryValue(firstMaturityQualitativeValue);
- batch.setSampleCategoryWeight(2f);
- batch.setWeight(1f);
- batch.setNumber(11);
+ assertCreateAndReloadSpeciesBatch(batch, batch.getParentBatch().getId());
- assertCreateAndReloadSpeciesBatch(batch, batch.getParentBatch().getId());
+ // -----------------------------------------------------------------------------
+ // 5. Test save after modifications
+ // -----------------------------------------------------------------------------
+ // Batch : ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99
+ batch.setComment("ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99");
+ batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryValue(unkQualitativeValue);
+ batch.setSampleCategoryWeight(1.75f);
+ batch.setWeight(1.11f);
+ batch.setFishingOperation(fishingOperationWithEmptyBatch);
+ batch.setNumber(99);
- // -----------------------------------------------------------------------------
- // 5. Test save after modifications
- // -----------------------------------------------------------------------------
- // Batch : ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99
- batch.setComment("ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99");
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
- batch.setSampleCategoryValue(unkQualitativeValue);
- batch.setSampleCategoryWeight(1.75f);
- batch.setWeight(1.11f);
- batch.setFishingOperation(fishingOperationWithEmptyBatch);
- batch.setNumber(99);
+ // Save and reload, then check
+ SpeciesBatch savedBatch = service.saveSpeciesBatch(batch);
+ assertSpeciesBatch(savedBatch, batch, false);
+ SpeciesBatch reloadedBatch = getSpeciesBatch(fishingOperationWithEmptyBatch.getId(), savedBatch.getId());
+ assertSpeciesBatch(savedBatch, reloadedBatch, true);
- // Save and reload, then check
- SpeciesBatch savedBatch = service.saveSpeciesBatch(batch);
- assertSpeciesBatch(savedBatch, batch, false);
- SpeciesBatch reloadedBatch = getSpeciesBatch(fishingOperationWithEmptyBatch.getId(), savedBatch.getId());
- assertSpeciesBatch(savedBatch, reloadedBatch, true);
+ // Save batch for later
+ frequenciesParentBatch = batch;
- // Save batch for later
- frequenciesParentBatch = batch;
+ // -----------------------------------------------------------------------------
+ // 6. Test change species
+ // -----------------------------------------------------------------------------
+ esp2Batch.setSpecies(taxon1);
+ service.changeSpeciesBatchSpecies(esp2Batch.getId(), taxon1);
+ assertSpeciesBatch(savedBatch, batch, false);
+ reloadedBatch = getSpeciesBatch(fishingOperationWithEmptyBatch.getId(), esp2Batch.getId());
+ assertSpeciesBatch(esp2Batch, reloadedBatch, true);
- // -----------------------------------------------------------------------------
- // 6. Test change species
- // -----------------------------------------------------------------------------
- esp2Batch.setSpecies(taxon1);
- service.changeSpeciesBatchSpecies(esp2Batch.getId(), taxon1);
- assertSpeciesBatch(savedBatch, batch, false);
- reloadedBatch = getSpeciesBatch(fishingOperationWithEmptyBatch.getId(), esp2Batch.getId());
- assertSpeciesBatch(esp2Batch, reloadedBatch, true);
+ // -----------------------------------------------------------------------------
+ // 7. Test get all root species
+ // -----------------------------------------------------------------------------
+ List<SpeciesBatch> rootSpeciesBatch = service.getAllRootSpeciesBatch(fishingOperationWithEmptyBatch.getId());
+ assertNotNull(rootSpeciesBatch);
+ assertEquals(2, rootSpeciesBatch.size());
+ assertNotNull(rootSpeciesBatch.get(0).getChildBatchs());
+ assertTrue(rootSpeciesBatch.get(0).getChildBatchs().size() > 0);
+ assertNotNull(rootSpeciesBatch.get(1).getChildBatchs());
+ assertTrue(rootSpeciesBatch.get(1).getChildBatchs().size() > 0);
- // -----------------------------------------------------------------------------
- // 7. Test get all root species
- // -----------------------------------------------------------------------------
- List<SpeciesBatch> rootSpeciesBatch = service.getAllRootSpeciesBatch(fishingOperationWithEmptyBatch.getId());
- assertNotNull(rootSpeciesBatch);
- assertEquals(2, rootSpeciesBatch.size());
- assertNotNull(rootSpeciesBatch.get(0).getChildBatchs());
- assertTrue(rootSpeciesBatch.get(0).getChildBatchs().size() > 0);
- assertNotNull(rootSpeciesBatch.get(1).getChildBatchs());
- assertTrue(rootSpeciesBatch.get(1).getChildBatchs().size() > 0);
+ // -----------------------------------------------------------------------------
+ // 8. Test batch frequency creation
+ // -----------------------------------------------------------------------------
- // -----------------------------------------------------------------------------
- // 8. Test batch frequency creation
- // -----------------------------------------------------------------------------
+ List<SpeciesBatchFrequency> frequencies = Lists.newArrayList();
+ float lengthStep = 0.5f;
+ for (float length = lengthStep; length < lengthStep * 20; length += lengthStep) {
+ SpeciesBatchFrequency frequency = new SpeciesBatchFrequency();
+ frequency.setLengthStep(length);
+ frequency.setNumber((int) (length * 2));
+ frequency.setWeight(0.01f * length * 2);
+ frequency.setLengthStepCaracteristic(frequencyPMFM);
+ frequency.setBatch(frequenciesParentBatch);
+ frequency.setComment("comments");
+ frequencies.add(frequency);
+ }
+ List<SpeciesBatchFrequency> createdFrequencies = assertCreateAndReloadSpeciesBatchFrequency(frequencies, frequenciesParentBatch.getId());
- List<SpeciesBatchFrequency> frequencies = Lists.newArrayList();
- float lengthStep = 0.5f;
- for (float length = lengthStep; length < lengthStep * 20; length += lengthStep) {
- SpeciesBatchFrequency frequency = new SpeciesBatchFrequency();
- frequency.setLengthStep(length);
- frequency.setNumber((int) (length * 2));
- frequency.setWeight(0.01f * length * 2);
- frequency.setLengthStepCaracteristic(frequencyPMFM);
- frequency.setBatch(frequenciesParentBatch);
- frequency.setComment("comments");
- frequencies.add(frequency);
- }
- List<SpeciesBatchFrequency> createdFrequencies = assertCreateAndReloadSpeciesBatchFrequency(frequencies, frequenciesParentBatch.getId());
+ // -----------------------------------------------------------------------------
+ // 9. Test batch frequency update
+ // -----------------------------------------------------------------------------
+ // Update some batchs (1cm, 2cm, etc)
+ for (SpeciesBatchFrequency speciesBatchFrequency : createdFrequencies) {
+ float length = speciesBatchFrequency.getLengthStep();
+ if ((float) (int) length == length) {
+ speciesBatchFrequency.setNumber(12);
+ speciesBatchFrequency.setComment(null);
+ }
+ }
+ // And remove the last item (should be deleted in DB)
+ createdFrequencies.remove(createdFrequencies.size() - 1);
+ List<SpeciesBatchFrequency> savedFrequencies = service.saveSpeciesBatchFrequency(frequenciesParentBatch.getId(), frequencies);
+ assertBatchFrequencies(createdFrequencies, savedFrequencies, true);
+ }
- // -----------------------------------------------------------------------------
- // 9. Test batch frequency update
- // -----------------------------------------------------------------------------
- // Update some batchs (1cm, 2cm, etc)
- for (SpeciesBatchFrequency speciesBatchFrequency : createdFrequencies) {
- float length = speciesBatchFrequency.getLengthStep();
- if ((float) (int) length == length) {
- speciesBatchFrequency.setNumber(12);
- speciesBatchFrequency.setComment(null);
- }
- }
- // And remove the last item (should be deleted in DB)
- createdFrequencies.remove(createdFrequencies.size() - 1);
- List<SpeciesBatchFrequency> savedFrequencies = service.saveSpeciesBatchFrequency(frequenciesParentBatch.getId(), frequencies);
- assertBatchFrequencies(createdFrequencies, savedFrequencies, true);
- }
+ @Test
+ public void deleteSpeciesBatch(/* String id */) {
+ SpeciesBatch esp1Batch;
+ SpeciesBatch batch;
+ Species taxon1 = species.get(0);
- @Test
- public void deleteSpeciesBatch(/*String id*/) {
- SpeciesBatch esp1Batch;
- SpeciesBatch batch;
- Species taxon1 = species.get(0);
+ // -----------------------------------------------------------------------------
+ // 1. Create two batchs (parent + child), then remove the parent batch
+ // -----------------------------------------------------------------------------
+ // batch : ESP1 Vrac/5
+ batch = new SpeciesBatch();
+ batch.setParentBatch(null);
+ batch.setFishingOperation(fishingOperationWithEmptyBatch);
+ batch.setSpecies(taxon1);
+ batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
+ batch.setSampleCategoryValue(vracQualitativeValue);
+ batch.setSampleCategoryWeight(5f);
+ assertCreateAndReloadSpeciesBatch(batch, null);
+ esp1Batch = batch;
- // -----------------------------------------------------------------------------
- // 1. Create two batchs (parent + child), then remove the parent batch
- // -----------------------------------------------------------------------------
- // batch : ESP1 Vrac/5
- batch = new SpeciesBatch();
- batch.setParentBatch(null);
- batch.setFishingOperation(fishingOperationWithEmptyBatch);
- batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
- batch.setSampleCategoryValue(vracQualitativeValue);
- batch.setSampleCategoryWeight(5f);
- assertCreateAndReloadSpeciesBatch(batch, null);
- esp1Batch = batch;
+ // batch : ESP1 Vrac/5 Male/2
+ batch = new SpeciesBatch();
+ batch.setParentBatch(esp1Batch);
+ batch.setFishingOperation(fishingOperationWithEmptyBatch);
+ batch.setSpecies(taxon1);
+ batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryValue(maleQualitativeValue);
+ batch.setSampleCategoryWeight(2f);
+ assertCreateAndReloadSpeciesBatch(batch, esp1Batch.getId());
- // batch : ESP1 Vrac/5 Male/2
- batch = new SpeciesBatch();
- batch.setParentBatch(esp1Batch);
- batch.setFishingOperation(fishingOperationWithEmptyBatch);
- batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
- batch.setSampleCategoryValue(maleQualitativeValue);
- batch.setSampleCategoryWeight(2f);
- assertCreateAndReloadSpeciesBatch(batch, esp1Batch.getId());
+ // Try to remove
+ service.deleteSpeciesBatch(esp1Batch.getId());
- // Try to remove
- service.deleteSpeciesBatch(esp1Batch.getId());
+ // Check if remove
+ try {
+ batch = getSpeciesBatch(fishingOperationWithEmptyBatch.getId(), esp1Batch.getId());
+ assertNull(batch);
+ } catch (DataRetrievalFailureException drfe) {
+ assertNotNull(drfe);
+ }
+ }
- // Check if remove
- try {
- batch = getSpeciesBatch(fishingOperationWithEmptyBatch.getId(), esp1Batch.getId());
- assertNull(batch);
- } catch (DataRetrievalFailureException drfe) {
- assertNotNull(drfe);
- }
- }
+ protected void assertCreateAndReloadSpeciesBatch(SpeciesBatch batch, String parentBatchId) {
+ batch.setFishingOperation(fishingOperationWithEmptyBatch);
- protected void assertCreateAndReloadSpeciesBatch(SpeciesBatch batch, String parentBatchId) {
- batch.setFishingOperation(fishingOperationWithEmptyBatch);
+ // Create batch
+ SpeciesBatch createdBatch = service.createSpeciesBatch(batch, parentBatchId);
+ assertSpeciesBatch(batch, createdBatch, false);
- // Create batch
- SpeciesBatch createdBatch = service.createSpeciesBatch(batch, parentBatchId);
- assertSpeciesBatch(batch, createdBatch, false);
+ // then reload (for round trip check)
+ SpeciesBatch reloadedBatch = getSpeciesBatch(fishingOperationWithEmptyBatch.getId(), createdBatch.getId());
+ if (parentBatchId == null) {
+ assertNull(reloadedBatch.getParentBatch());
+ } else {
+ assertNotNull(reloadedBatch.getParentBatch());
+ assertEquals(parentBatchId, reloadedBatch.getParentBatch().getId());
+ }
+ assertSpeciesBatch(createdBatch, reloadedBatch, false);
- // then reload (for round trip check)
- SpeciesBatch reloadedBatch = getSpeciesBatch(fishingOperationWithEmptyBatch.getId(), createdBatch.getId());
- if (parentBatchId == null) {
- assertNull(reloadedBatch.getParentBatch());
- } else {
- assertNotNull(reloadedBatch.getParentBatch());
- assertEquals(parentBatchId, reloadedBatch.getParentBatch().getId());
- }
- assertSpeciesBatch(createdBatch, reloadedBatch, false);
+ batch.setId(createdBatch.getId());
+ }
- batch.setId(createdBatch.getId());
- }
+ protected void assertCreateAndReloadCatchBatch(CatchBatch catchBatch, String fishingOperationId) {
+ CatchBatch createdCatchBatch = service.createCatchBatch(catchBatch);
+ assertNotNull(createdCatchBatch);
+ assertNotNull(createdCatchBatch.getId());
+ assertCatchBatch(catchBatch, createdCatchBatch, false);
- protected void assertCreateAndReloadCatchBatch(CatchBatch catchBatch, String fishingOperationId) {
- CatchBatch createdCatchBatch = service.createCatchBatch(catchBatch);
- assertNotNull(createdCatchBatch);
- assertNotNull(createdCatchBatch.getId());
- assertCatchBatch(catchBatch, createdCatchBatch, false);
+ CatchBatch reloadedCatchBatch = null;
+ try {
+ reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
+ } catch (CatchBatchValidationException e) {
+ Assert.fail(e.getMessage());
+ }
+ assertCatchBatch(createdCatchBatch, reloadedCatchBatch, true);
- CatchBatch reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
- assertCatchBatch(createdCatchBatch, reloadedCatchBatch, true);
+ catchBatch.setId(createdCatchBatch.getId());
+ }
- catchBatch.setId(createdCatchBatch.getId());
- }
+ protected void assertSaveAndReloadCatchBatch(CatchBatch catchBatch, String fishingOperationId) {
+ CatchBatch savedCatchBatch = service.saveCatchBatch(catchBatch);
+ assertNotNull(savedCatchBatch);
+ assertNotNull(savedCatchBatch.getId());
+ assertCatchBatch(catchBatch, savedCatchBatch, false);
- protected void assertSaveAndReloadCatchBatch(CatchBatch catchBatch, String fishingOperationId) {
- CatchBatch savedCatchBatch = service.saveCatchBatch(catchBatch);
- assertNotNull(savedCatchBatch);
- assertNotNull(savedCatchBatch.getId());
- assertCatchBatch(catchBatch, savedCatchBatch, false);
+ CatchBatch reloadedCatchBatch = null;
+ try {
+ reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
+ } catch (CatchBatchValidationException e) {
+ Assert.fail(e.getMessage());
+ }
+ assertCatchBatch(savedCatchBatch, reloadedCatchBatch, true);
+ }
- CatchBatch reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
- assertCatchBatch(savedCatchBatch, reloadedCatchBatch, true);
- }
+ protected void assertCatchBatch(CatchBatch expectedCatchBatch, CatchBatch actualCatchBatch, boolean assertIdEquals) {
+ if (expectedCatchBatch == null) {
+ assertNull(actualCatchBatch);
+ return;
+ }
- protected void assertCatchBatch(CatchBatch expectedCatchBatch, CatchBatch actualCatchBatch, boolean assertIdEquals) {
- if (expectedCatchBatch == null) {
- assertNull(actualCatchBatch);
- return;
- }
+ assertNotNull(actualCatchBatch);
+ if (assertIdEquals) {
+ assertEquals(expectedCatchBatch.getId(), actualCatchBatch.getId());
+ }
+ assertEquals(expectedCatchBatch.getCatchTotalWeight(), actualCatchBatch.getCatchTotalWeight());
+ assertEquals(expectedCatchBatch.getCatchTotalSortedCarousselWeight(), actualCatchBatch.getCatchTotalSortedCarousselWeight());
+ assertEquals(expectedCatchBatch.getCatchTotalSortedTremisWeight(), actualCatchBatch.getCatchTotalSortedTremisWeight());
+ assertEquals(expectedCatchBatch.getCatchTotalUnsortedWeight(), actualCatchBatch.getCatchTotalUnsortedWeight());
- assertNotNull(actualCatchBatch);
- if (assertIdEquals) {
- assertEquals(expectedCatchBatch.getId(), actualCatchBatch.getId());
- }
- assertEquals(expectedCatchBatch.getCatchTotalWeight(), actualCatchBatch.getCatchTotalWeight());
- assertEquals(expectedCatchBatch.getCatchTotalSortedCarousselWeight(), actualCatchBatch.getCatchTotalSortedCarousselWeight());
- assertEquals(expectedCatchBatch.getCatchTotalSortedTremisWeight(), actualCatchBatch.getCatchTotalSortedTremisWeight());
- assertEquals(expectedCatchBatch.getCatchTotalUnsortedWeight(), actualCatchBatch.getCatchTotalUnsortedWeight());
+ assertEquals(expectedCatchBatch.getSpeciesTotalSampleSortedWeight(), actualCatchBatch.getSpeciesTotalSampleSortedWeight());
+ assertEquals(expectedCatchBatch.getSpeciesTotalSortedWeight(), actualCatchBatch.getSpeciesTotalSortedWeight());
+ assertEquals(expectedCatchBatch.getSpeciesTotalUnsortedWeight(), actualCatchBatch.getSpeciesTotalUnsortedWeight());
+ assertEquals(expectedCatchBatch.getSpeciesTotalInertWeight(), actualCatchBatch.getSpeciesTotalInertWeight());
+ assertEquals(expectedCatchBatch.getSpeciesTotalLivingNotItemizedWeight(), actualCatchBatch.getSpeciesTotalLivingNotItemizedWeight());
+ }
- assertEquals(expectedCatchBatch.getSpeciesTotalSampleSortedWeight(), actualCatchBatch.getSpeciesTotalSampleSortedWeight());
- assertEquals(expectedCatchBatch.getSpeciesTotalSortedWeight(), actualCatchBatch.getSpeciesTotalSortedWeight());
- assertEquals(expectedCatchBatch.getSpeciesTotalUnsortedWeight(), actualCatchBatch.getSpeciesTotalUnsortedWeight());
- assertEquals(expectedCatchBatch.getSpeciesTotalInertWeight(), actualCatchBatch.getSpeciesTotalInertWeight());
- assertEquals(expectedCatchBatch.getSpeciesTotalLivingNotItemizedWeight(), actualCatchBatch.getSpeciesTotalLivingNotItemizedWeight());
- }
+ protected void assertSpeciesBatch(SpeciesBatch expectedBatch, SpeciesBatch actualBatch, boolean assertIdEquals) {
+ assertNotNull(actualBatch);
+ assertNotNull(actualBatch.getId());
+ if (assertIdEquals && expectedBatch.getId() != null) {
+ assertEquals(expectedBatch.getId(), actualBatch.getId());
+ }
+ assertEquals(expectedBatch.getWeight(), actualBatch.getWeight());
+ assertEquals(expectedBatch.getSampleCategoryType(), actualBatch.getSampleCategoryType());
+ if (expectedBatch.getSampleCategoryValue() != null && expectedBatch.getSampleCategoryValue() instanceof CaracteristicQualitativeValue) {
+ assertNotNull("Bad sampleCategoryValue : expected <" + ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId()
+ + "> but was <null>",
+ actualBatch.getSampleCategoryValue());
+ assertEquals(
+ ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId(),
+ ((CaracteristicQualitativeValue) actualBatch.getSampleCategoryValue()).getId());
+ } else {
+ assertEquals(expectedBatch.getSampleCategoryValue(), actualBatch.getSampleCategoryValue());
+ }
+ assertEquals(expectedBatch.getSampleCategoryWeight(), actualBatch.getSampleCategoryWeight());
+ assertEquals(expectedBatch.getNumber(), actualBatch.getNumber());
+ assertEquals(expectedBatch.getComment(), actualBatch.getComment());
- protected void assertSpeciesBatch(SpeciesBatch expectedBatch, SpeciesBatch actualBatch, boolean assertIdEquals) {
- assertNotNull(actualBatch);
- assertNotNull(actualBatch.getId());
- if (assertIdEquals && expectedBatch.getId() != null) {
- assertEquals(expectedBatch.getId(), actualBatch.getId());
- }
- assertEquals(expectedBatch.getWeight(), actualBatch.getWeight());
- assertEquals(expectedBatch.getSampleCategoryType(), actualBatch.getSampleCategoryType());
- if (expectedBatch.getSampleCategoryValue() != null && expectedBatch.getSampleCategoryValue() instanceof CaracteristicQualitativeValue) {
- assertNotNull("Bad sampleCategoryValue : expected <" + ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId() + "> but was <null>",
- actualBatch.getSampleCategoryValue());
- assertEquals(
- ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId(),
- ((CaracteristicQualitativeValue) actualBatch.getSampleCategoryValue()).getId());
- } else {
- assertEquals(expectedBatch.getSampleCategoryValue(), actualBatch.getSampleCategoryValue());
- }
- assertEquals(expectedBatch.getSampleCategoryWeight(), actualBatch.getSampleCategoryWeight());
- assertEquals(expectedBatch.getNumber(), actualBatch.getNumber());
- assertEquals(expectedBatch.getComment(), actualBatch.getComment());
+ // Check species only if Vrac/HorsVrac or if batch has been load throw getAllxxx method
+ // (Because getSpeciesBatch(id) could not always retrieve the species)
+ if (expectedBatch.getSpecies() != null && (
+ expectedBatch.getSampleCategoryType() == SampleCategoryEnum.sortedUnsorted
+ || actualBatch.getSpecies() != null)) {
+ assertNotNull(actualBatch.getSpecies());
+ assertEquals(expectedBatch.getSpecies().getId(), actualBatch.getSpecies().getId());
+ }
+ }
- // Check species only if Vrac/HorsVrac or if batch has been load throw getAllxxx method
- // (Because getSpeciesBatch(id) could not always retrieve the species)
- if (expectedBatch.getSpecies() != null && (
- expectedBatch.getSampleCategoryType() == SampleCategoryEnum.sortedUnsorted
- || actualBatch.getSpecies() != null)) {
- assertNotNull(actualBatch.getSpecies());
- assertEquals(expectedBatch.getSpecies().getId(), actualBatch.getSpecies().getId());
- }
- }
+ protected List<SpeciesBatchFrequency> assertCreateAndReloadSpeciesBatchFrequency(List<SpeciesBatchFrequency> frequencies, String parentBatchId) {
- protected List<SpeciesBatchFrequency> assertCreateAndReloadSpeciesBatchFrequency(List<SpeciesBatchFrequency> frequencies, String parentBatchId) {
+ // Create batch
+ List<SpeciesBatchFrequency> createdFrequencies = service.saveSpeciesBatchFrequency(parentBatchId, frequencies);
+ assertBatchFrequencies(frequencies, createdFrequencies, false);
- // Create batch
- List<SpeciesBatchFrequency> createdFrequencies = service.saveSpeciesBatchFrequency(parentBatchId, frequencies);
- assertBatchFrequencies(frequencies, createdFrequencies, false);
+ // then reload (for round trip check)
+ List<SpeciesBatchFrequency> reloadedFrequencies = service.getAllSpeciesBatchFrequency(parentBatchId);
+ assertBatchFrequencies(createdFrequencies, reloadedFrequencies, true);
- // then reload (for round trip check)
- List<SpeciesBatchFrequency> reloadedFrequencies = service.getAllSpeciesBatchFrequency(parentBatchId);
- assertBatchFrequencies(createdFrequencies, reloadedFrequencies, true);
+ return createdFrequencies;
+ }
- return createdFrequencies;
- }
+ protected void assertBatchFrequencies(List<SpeciesBatchFrequency> expectedFrequencies, List<SpeciesBatchFrequency> actualFrequencies,
+ boolean assertIdEquals) {
+ assertNotNull(actualFrequencies);
+ assertEquals(expectedFrequencies.size(), actualFrequencies.size());
- protected void assertBatchFrequencies(List<SpeciesBatchFrequency> expectedFrequencies, List<SpeciesBatchFrequency> actualFrequencies, boolean assertIdEquals) {
- assertNotNull(actualFrequencies);
- assertEquals(expectedFrequencies.size(), actualFrequencies.size());
+ // Store actual batches into a map, using the length as key
+ Map<Float, SpeciesBatchFrequency> expectedLengthMap = Maps.newHashMap();
+ for (SpeciesBatchFrequency speciesBatchFrequency : expectedFrequencies) {
+ expectedLengthMap.put(speciesBatchFrequency.getLengthStep(), speciesBatchFrequency);
+ }
- // Store actual batches into a map, using the length as key
- Map<Float, SpeciesBatchFrequency> expectedLengthMap = Maps.newHashMap();
- for (SpeciesBatchFrequency speciesBatchFrequency : expectedFrequencies) {
- expectedLengthMap.put(speciesBatchFrequency.getLengthStep(), speciesBatchFrequency);
- }
+ // Store expected batches into a map, using the length as key
+ Map<Float, SpeciesBatchFrequency> actualLengthMap = Maps.newHashMap();
+ for (SpeciesBatchFrequency speciesBatchFrequency : actualFrequencies) {
+ assertFalse("Duplicate lengthStep found in batchFrequencies, for length=" + speciesBatchFrequency.getLengthStep(),
+ actualLengthMap.containsKey(speciesBatchFrequency.getLengthStep()));
+ actualLengthMap.put(speciesBatchFrequency.getLengthStep(), speciesBatchFrequency);
+ assertNotNull(speciesBatchFrequency.getId());
+ }
- // Store expected batches into a map, using the length as key
- Map<Float, SpeciesBatchFrequency> actualLengthMap = Maps.newHashMap();
- for (SpeciesBatchFrequency speciesBatchFrequency : actualFrequencies) {
- assertFalse("Duplicate lengthStep found in batchFrequencies, for length=" + speciesBatchFrequency.getLengthStep(), actualLengthMap.containsKey(speciesBatchFrequency.getLengthStep()));
- actualLengthMap.put(speciesBatchFrequency.getLengthStep(), speciesBatchFrequency);
- assertNotNull(speciesBatchFrequency.getId());
- }
+ for (Float lengthStep : expectedLengthMap.keySet()) {
+ SpeciesBatchFrequency expectedBatchFrequency = expectedLengthMap.get(lengthStep);
+ SpeciesBatchFrequency actualBatchFrequency = actualLengthMap.get(lengthStep);
+ if (assertIdEquals) {
+ assertEquals(expectedBatchFrequency.getId(), actualBatchFrequency.getId());
+ }
+ assertNotNull(expectedBatchFrequency.getLengthStepCaracteristic());
+ assertEquals(expectedBatchFrequency.getLengthStepCaracteristic().getId(), actualBatchFrequency.getLengthStepCaracteristic().getId());
+ assertEquals(expectedBatchFrequency.getNumber(), actualBatchFrequency.getNumber());
+ assertEquals(expectedBatchFrequency.getWeight(), actualBatchFrequency.getWeight());
+ assertEquals(expectedBatchFrequency.getComment(), actualBatchFrequency.getComment());
+ // assertNotNull(expectedBatchFrequency.getBatch());
+ // assertEquals(expectedBatchFrequency.getBatch().getId(), actualBatchFrequency.getBatch().getId());
+ }
+ }
- for (Float lengthStep : expectedLengthMap.keySet()) {
- SpeciesBatchFrequency expectedBatchFrequency = expectedLengthMap.get(lengthStep);
- SpeciesBatchFrequency actualBatchFrequency = actualLengthMap.get(lengthStep);
- if (assertIdEquals) {
- assertEquals(expectedBatchFrequency.getId(), actualBatchFrequency.getId());
- }
- assertNotNull(expectedBatchFrequency.getLengthStepCaracteristic());
- assertEquals(expectedBatchFrequency.getLengthStepCaracteristic().getId(), actualBatchFrequency.getLengthStepCaracteristic().getId());
- assertEquals(expectedBatchFrequency.getNumber(), actualBatchFrequency.getNumber());
- assertEquals(expectedBatchFrequency.getWeight(), actualBatchFrequency.getWeight());
- assertEquals(expectedBatchFrequency.getComment(), actualBatchFrequency.getComment());
- //assertNotNull(expectedBatchFrequency.getBatch());
- //assertEquals(expectedBatchFrequency.getBatch().getId(), actualBatchFrequency.getBatch().getId());
- }
- }
+ protected SpeciesBatch getSpeciesBatch(String fishingOperationId, String speciesBatchId) {
+ return getSpeciesBatch(speciesBatchId, service.getAllRootSpeciesBatch(fishingOperationId));
+ }
- protected SpeciesBatch getSpeciesBatch(String fishingOperationId, String speciesBatchId) {
- return getSpeciesBatch(speciesBatchId, service.getAllRootSpeciesBatch(fishingOperationId));
- }
-
- protected SpeciesBatch getSpeciesBatch(String speciesBatchId, List<SpeciesBatch> speciesBatchs) {
- if (speciesBatchs == null) {
- return null;
- }
- for (SpeciesBatch speciesBatch : speciesBatchs) {
- if (speciesBatchId.equals(speciesBatch.getId())) {
- return speciesBatch;
- }
- if (speciesBatch.getChildBatchs() != null) {
- speciesBatch = getSpeciesBatch(speciesBatchId, speciesBatch.getChildBatchs());
- if (speciesBatch != null) {
- return speciesBatch;
- }
- }
- }
- return null;
- }
+ protected SpeciesBatch getSpeciesBatch(String speciesBatchId, List<SpeciesBatch> speciesBatchs) {
+ if (speciesBatchs == null) {
+ return null;
+ }
+ for (SpeciesBatch speciesBatch : speciesBatchs) {
+ if (speciesBatchId.equals(speciesBatch.getId())) {
+ return speciesBatch;
+ }
+ if (speciesBatch.getChildBatchs() != null) {
+ speciesBatch = getSpeciesBatch(speciesBatchId, speciesBatch.getChildBatchs());
+ if (speciesBatch != null) {
+ return speciesBatch;
+ }
+ }
+ }
+ return null;
+ }
}
Added: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java (rev 0)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -0,0 +1,118 @@
+package fr.ifremer.tutti.persistence.service.batch;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.api.Invocation;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.jmock.lib.action.CustomAction;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
+import fr.ifremer.adagio.core.service.ServiceLocator;
+import fr.ifremer.tutti.persistence.DatabaseResource;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.service.BatchPersistenceService;
+import fr.ifremer.tutti.persistence.service.CatchBatchPersistenceService;
+import fr.ifremer.tutti.persistence.service.CruisePersistenceService;
+import fr.ifremer.tutti.persistence.service.FishingOperationPersistenceService;
+import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService;
+import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator;
+
+public class CatchBatchValidatorReadTest {
+
+ @ClassRule
+ public static final DatabaseResource dbResource = DatabaseResource.writeDb();
+
+ protected BatchPersistenceService service;
+
+ protected CruisePersistenceService cruiseService;
+
+ protected FishingOperationPersistenceService fishingOperationService;
+
+ protected CatchBatchPersistenceService catchBatchService;
+
+ protected ReferentialPersistenceService referentialService;
+
+ Mockery context ;
+
+ CatchBatchExtendDao catchBatchExtendDaoMock;
+
+ String fishingOperationId = null;
+
+ CatchBatchExtendDao catchBatchDao;
+
+ @Before
+ public void setUp() throws Exception {
+ context = new JUnit4Mockery();
+ catchBatchExtendDaoMock = context.mock(CatchBatchExtendDao.class);
+ catchBatchDao=ServiceLocator.instance().getService("catchBatchDao", CatchBatchExtendDao.class);
+
+ service = TuttiPersistenceServiceLocator.getBatchPersistenceService();
+ cruiseService = TuttiPersistenceServiceLocator.getCruisePersistenceService();
+ fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
+ catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
+ referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
+
+ List<FishingOperation> fishingOperations = fishingOperationService.getAllFishingOperation(dbResource.getFixtures().cruiseId());
+ assertNotNull(fishingOperations);
+ assertTrue(fishingOperations.size() > 0);
+ fishingOperationId = fishingOperations.get(0).getId();
+ }
+
+ @Test
+ public void getInvalidCatchBatch() {
+
+ // Full load operation
+ try {
+ CatchBatch catchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
+ Assert.fail("Historical batch tree must not be valid");
+ } catch (CatchBatchValidationException e) {
+ assertNotNull(e);
+ }
+ }
+
+ @Test
+ public void getInvalidCatchBatchButTryRepair() throws CatchBatchValidationException {
+
+ // Replace catchBatchDao with a mock :
+ //service.setCatchBatchDao(catchBatchExtendDaoMock);
+
+ context.checking(new Expectations() {{
+ // Assert update() is call once
+ //oneOf (catchBatchExtendDaoMock).update(with(any(fr.ifremer.adagio.core.dao.data.batch.CatchBatch.class)));
+
+ // Delegate other methods to the real DAO
+ allowing(catchBatchExtendDaoMock);
+ will(new CustomAction("call delegated catchBatchDao") {
+ @Override
+ public Object invoke(Invocation invocation) throws Throwable {
+ return invocation.applyTo(catchBatchDao);
+ }
+ });
+ }});
+
+ CatchBatch catchBatch = null;
+ try {
+ catchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId, true/*tryToRepair*/);
+ assertNotNull(catchBatch);
+ } catch (CatchBatchValidationException e) {
+ Assert.fail("Historical batch tree must have been repaired");
+ }
+ context.assertIsSatisfied();
+
+ // Restore original dao
+ //service.setCatchBatchDao(catchBatchDao);
+ }
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2013-02-25 13:39:39 UTC (rev 460)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2013-02-25 14:11:54 UTC (rev 461)
@@ -476,7 +476,9 @@
Cruise cruise;
cruise = persistenceService.getCruise(cruiseId);
- title += _("tutti.title.selectedCruise", cruise.getName());
+ if (cruise != null) {
+ title += _("tutti.title.selectedCruise", cruise.getName());
+ }
}
title += " / ";
1
0