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
See <http://ci.nuiton.org/jenkins/job/tutti/412/changes>
Changes:
[blavenier] Add :
- some caches
- remove HQL on changeSpeciesBatchSpecies (move in 'adagio-core')
Fix :
- move come cache declaration into Interface
------------------------------------------
[...truncated 28 lines...]
projectStarted fr.ifremer:tutti:1.0.2-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti 1.0.2-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
main:
mojoSucceeded org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir) [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.0.2-SNAPSHOT/tutti-1.0.2-SNAPSHOT.pom
[INFO] Installing <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/tutti-1.0.2-SNAPSHOT…> to /var/local/maven/data/repository/fr/ifremer/tutti/1.0.2-SNAPSHOT/tutti-1.0.2-SNAPSHOT-site_fr.xml
mojoSucceeded org.apache.maven.plugins:maven-install-plugin:2.4(default-install)
projectSucceeded fr.ifremer:tutti:1.0.2-SNAPSHOT
projectStarted fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti :: Persistence 1.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (2 KB at 1.8 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (2 KB at 1.8 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (823 B at 6.0 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (823 B at 5.6 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 958.786ms.
[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 23.27s.
[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
mojoSucceeded org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
[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}]}}
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.0.2-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.0.2-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)
[WARNING] bundle fr_FR contains 7/28 empty entries! (use -Di18n.showEmpty to see these entries)
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 10 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 79 source files to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/cl…>
[INFO] -------------------------------------------------------------
mojoFailed org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)[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/…>:[29,22] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[41,52] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[27,22] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[28,22] [deprecation] ApplicationConfigProvider in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[40,55] [deprecation] ApplicationConfigProvider in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[35,9] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[68,20] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[70,34] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[177,11] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[256,46] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[277,46] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[390,53] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[404,52] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[415,53] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[449,42] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[656,34] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[53,11] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[58,11] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[59,19] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[208,25] error: method removeWithChildren in interface CatchBatchExtendDao cannot be applied to given types;
[ERROR] required: Integer
found: Integer,CatchBatch
reason: actual and formal argument lists differ in length
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[346,29] error: cannot find symbol
[ERROR] symbol: method createSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[372,21] error: cannot find symbol
[ERROR] symbol: method updateSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[400,21] error: cannot find symbol
[ERROR] symbol: method setSortingBatchReferenceTaxon(String,Integer)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[482,29] error: cannot find symbol
[ERROR] symbol: method createSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[488,38] error: cannot find symbol
[ERROR] symbol: method loadSortingBatch(Integer,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[502,22] error: cannot find symbol
[ERROR] symbol: method updateSortingBatch(List<SortingBatch>,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[507,29] error: method removeWithChildren in interface CatchBatchExtendDao cannot be applied to given types;
[ERROR] required: Integer
found: Integer,CatchBatch
reason: actual and formal argument lists differ in length
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[581,29] error: cannot find symbol
[ERROR] symbol: method createSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[607,21] error: cannot find symbol
[ERROR] symbol: method updateSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[723,29] error: cannot find symbol
[ERROR] symbol: method createSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[743,25] error: cannot find symbol
[ERROR] symbol: method updateSortingBatch(List<SortingBatch>,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[748,29] error: method removeWithChildren in interface CatchBatchExtendDao cannot be applied to given types;
[INFO] 32 errors
[INFO] -------------------------------------------------------------
projectFailed fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
sessionEnded
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Tutti ............................................. SUCCESS [1:28.144s]
[INFO] Tutti :: Persistence .............................. FAILURE [1:13.347s]
[INFO] Tutti :: Service .................................. SKIPPED
[INFO] Tutti :: UI ....................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:49.095s
[INFO] Finished at: Thu Feb 28 20:35:29 CET 2013
[INFO] Final Memory: 27M/74M
[INFO] ------------------------------------------------------------------------
Projects to build: [MavenProject: fr.ifremer:tutti:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-service:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-service/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-ui-swing:1.0.2-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-28_20-32-19/archive/fr.ifremer.tutti/tutti-service/1.0.2-SNAPSHOT/tutti-service-1.0.2-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-28_20-32-19/archive/fr.ifremer.tutti/tutti-ui-swing/1.0.2-SNAPSHOT/tutti-ui-swing-1.0.2-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-28_20-32-19/archive/fr.ifremer/tutti/1.0.2-SNAPSHOT/tutti-1.0.2-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/tutti-1.0.2-SNAPSHOT…> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer$tutti/builds/2013-02-28_20-32-19/archive/fr.ifremer/tutti/1.0.2-SNAPSHOT/tutti-1.0.2-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-28_20-32-19/archive/fr.ifremer.tutti/tutti-persistence/1.0.2-SNAPSHOT/tutti-persistence-1.0.2-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
2
01 Mar '13
See <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/4…>
Changes:
[blavenier] Add :
- some caches
- remove HQL on changeSpeciesBatchSpecies (move in 'adagio-core')
Fix :
- move come cache declaration into Interface
------------------------------------------
projectStarted fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti :: Persistence 1.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (2 KB at 1.8 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (2 KB at 1.8 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (823 B at 6.0 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (823 B at 5.6 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 958.786ms.
[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 23.27s.
[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
mojoSucceeded org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
[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}]}}
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.0.2-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.0.2-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)
[WARNING] bundle fr_FR contains 7/28 empty entries! (use -Di18n.showEmpty to see these entries)
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 10 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 79 source files to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] -------------------------------------------------------------
mojoFailed org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)[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…>:[29,22] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[41,52] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[27,22] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[28,22] [deprecation] ApplicationConfigProvider in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[40,55] [deprecation] ApplicationConfigProvider in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[35,9] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[68,20] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[70,34] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[177,11] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[256,46] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[277,46] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[390,53] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[404,52] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[415,53] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[449,42] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[656,34] error: cannot find symbol
[ERROR] symbol: method getCache(String)
location: variable cacheService of type CacheService
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[53,11] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[58,11] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[59,19] [deprecation] ApplicationConfig in org.nuiton.util has been deprecated
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[208,25] error: method removeWithChildren in interface CatchBatchExtendDao cannot be applied to given types;
[ERROR] required: Integer
found: Integer,CatchBatch
reason: actual and formal argument lists differ in length
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[346,29] error: cannot find symbol
[ERROR] symbol: method createSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[372,21] error: cannot find symbol
[ERROR] symbol: method updateSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[400,21] error: cannot find symbol
[ERROR] symbol: method setSortingBatchReferenceTaxon(String,Integer)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[482,29] error: cannot find symbol
[ERROR] symbol: method createSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[488,38] error: cannot find symbol
[ERROR] symbol: method loadSortingBatch(Integer,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[502,22] error: cannot find symbol
[ERROR] symbol: method updateSortingBatch(List<SortingBatch>,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[507,29] error: method removeWithChildren in interface CatchBatchExtendDao cannot be applied to given types;
[ERROR] required: Integer
found: Integer,CatchBatch
reason: actual and formal argument lists differ in length
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[581,29] error: cannot find symbol
[ERROR] symbol: method createSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[607,21] error: cannot find symbol
[ERROR] symbol: method updateSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[723,29] error: cannot find symbol
[ERROR] symbol: method createSortingBatch(SortingBatch,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[743,25] error: cannot find symbol
[ERROR] symbol: method updateSortingBatch(List<SortingBatch>,CatchBatch)
location: variable catchBatchDao of type CatchBatchExtendDao
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[748,29] error: method removeWithChildren in interface CatchBatchExtendDao cannot be applied to given types;
[INFO] 32 errors
[INFO] -------------------------------------------------------------
projectFailed fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
1
2
r504 - in trunk/tutti-persistence/src: main/java/fr/ifremer/tutti/persistence/service main/resources test/java/fr/ifremer/tutti/persistence/service
by blavenier@users.forge.codelutin.com 28 Feb '13
by blavenier@users.forge.codelutin.com 28 Feb '13
28 Feb '13
Author: blavenier
Date: 2013-02-28 20:20:19 +0100 (Thu, 28 Feb 2013)
New Revision: 504
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/504
Log:
Add :
- some caches
- remove HQL on changeSpeciesBatchSpecies (move in 'adagio-core')
Fix :
- move come cache declaration into Interface
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/ProgramPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/resources/applicationContext-service-tutti.xml
trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.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-28 11:59:26 UTC (rev 503)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-02-28 19:20:19 UTC (rev 504)
@@ -31,6 +31,7 @@
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.SortingBatchImpl;
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;
@@ -82,9 +83,6 @@
@Resource(name = "referentialPersistenceService")
protected ReferentialPersistenceService referentialService;
- @Resource(name = "sortingBatchDao")
- protected SortingBatchDao sortingBatchDao;
-
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
@@ -157,10 +155,11 @@
// Benthos
SortingBatch benthosBatch = catchBatchDao.getSortingBatch(vracBatch.getChildBatchs(),
"pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ if (benthosBatch != null) {
+ result.setBenthosTotalSampleSortedWeight(benthosBatch.getWeight());
+ result.setBenthosTotalSortedWeight(benthosBatch.getWeightBeforeSampling());
+ }
- result.setBenthosTotalSampleSortedWeight(benthosBatch.getWeight());
- result.setBenthosTotalSortedWeight(benthosBatch.getWeightBeforeSampling());
-
// TODO : Plancton...
}
@@ -173,15 +172,17 @@
// Species
SortingBatch speciesBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(),
"pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ if (speciesBatch != null) {
+ result.setSpeciesTotalUnsortedWeight(speciesBatch.getWeight());
+ }
- result.setSpeciesTotalUnsortedWeight(speciesBatch.getWeight());
-
SortingBatch benthosBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(),
"pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ if (benthosBatch == null) {
+ result.setBenthosTotalUnsortedWeight(benthosBatch.getWeight());
+ }
- result.setBenthosTotalUnsortedWeight(benthosBatch.getWeight());
-
// TODO : Plancton...
}
}
@@ -204,7 +205,7 @@
Preconditions.checkNotNull(catchBatch.getChildBatchs());
for (Batch batch : catchBatch.getChildBatchs()) {
- catchBatchDao.removeWithChildren(batch.getId());
+ catchBatchDao.removeWithChildren(batch.getId(), catchBatch);
}
catchBatch.getChildBatchs().clear();
@@ -257,7 +258,6 @@
}
@Override
- @CacheEvict(value = "batchTree", key = "#bean.fishingOperation.id")
public CatchBatch saveCatchBatch(CatchBatch bean) {
Preconditions.checkNotNull(bean);
@@ -343,7 +343,7 @@
SortingBatch batch = SortingBatch.Factory.newInstance();
beanToEntity(bean, batch, parentBatchId, catchBatch, true);
- batch = sortingBatchDao.create(batch);
+ batch = catchBatchDao.createSortingBatch(batch, catchBatch);
bean.setId(String.valueOf(batch.getId()));
@@ -369,7 +369,7 @@
parentBatchId = bean.getParentBatch().getId();
}
beanToEntity(bean, batch, parentBatchId, catchBatch, true);
- sortingBatchDao.update(batch);
+ catchBatchDao.updateSortingBatch(batch, catchBatch);
getCurrentSession().flush();
return bean;
@@ -397,14 +397,7 @@
Preconditions.checkNotNull(species);
Preconditions.checkNotNull(species.getReferenceTaxonId());
- if (log.isDebugEnabled()) {
- log.debug("Changing species for batch id=" + batchId);
- }
-
- int rowUpdated = queryUpdate("updateBatchSpecies",
- "batchId", IntegerType.INSTANCE, Integer.valueOf(batchId),
- "referenceTaxonId", IntegerType.INSTANCE, species.getReferenceTaxonId());
- Preconditions.checkArgument(rowUpdated == 1, "Unable to update operation, to be linked with catch batch.");
+ catchBatchDao.setSortingBatchReferenceTaxon(batchId, species.getReferenceTaxonId());
}
//------------------------------------------------------------------------//
@@ -486,13 +479,13 @@
beanToEntity(source, target, parentBatch, rankOrder, true);
// Create the targeted batch, then update the source id
- sortingBatchDao.create(target);
+ catchBatchDao.createSortingBatch(target, catchBatch);
source.setId(target.getId().toString());
}
// Existing batch
else {
- target = sortingBatchDao.load(Integer.valueOf(source.getId()));
+ target = catchBatchDao.loadSortingBatch(Integer.valueOf(source.getId()), catchBatch);
// Fill the sorting batch from the source
beanToEntity(source, target, parentBatch, rankOrder, true);
@@ -506,12 +499,12 @@
// If some batchs need to be update, do it
if (batchsToUpdate.size() > 0) {
- sortingBatchDao.update(batchsToUpdate);
+ catchBatchDao.updateSortingBatch(batchsToUpdate, catchBatch);
}
if (notUpdatedChildIds.size() > 0) {
for (Integer batchId : notUpdatedChildIds) {
- catchBatchDao.removeWithChildren(batchId);
+ catchBatchDao.removeWithChildren(batchId, catchBatch);
}
}
@@ -585,7 +578,7 @@
SortingBatch batch = SortingBatch.Factory.newInstance();
beanToEntity(bean, batch, parentBatchId, catchBatch, true);
- batch = sortingBatchDao.create(batch);
+ batch = catchBatchDao.createSortingBatch(batch, catchBatch);
bean.setId(String.valueOf(batch.getId()));
@@ -611,7 +604,7 @@
parentBatchId = bean.getParentBatch().getId();
}
beanToEntity(bean, batch, parentBatchId, catchBatch, true);
- sortingBatchDao.update(batch);
+ catchBatchDao.updateSortingBatch(batch, catchBatch);
getCurrentSession().flush();
return bean;
@@ -727,13 +720,13 @@
beanToEntity(source, target, parentBatch, rankOrder, true);
// Create the targeted batch, then update the source id
- sortingBatchDao.create(target);
+ catchBatchDao.createSortingBatch(target, catchBatch);
source.setId(target.getId().toString());
}
// Existing batch
else {
- target = sortingBatchDao.load(Integer.valueOf(source.getId()));
+ target = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(source.getId()));
// Fill the sorting batch from the source
beanToEntity(source, target, parentBatch, rankOrder, true);
@@ -747,12 +740,12 @@
// If some batchs need to be update, do it
if (batchsToUpdate.size() > 0) {
- sortingBatchDao.update(batchsToUpdate);
+ catchBatchDao.updateSortingBatch(batchsToUpdate, catchBatch);
}
if (notUpdatedChildIds.size() > 0) {
for (Integer batchId : notUpdatedChildIds) {
- catchBatchDao.removeWithChildren(batchId);
+ catchBatchDao.removeWithChildren(batchId, catchBatch);
}
}
@@ -1257,7 +1250,6 @@
speciesBatch.setRankOrder((short) 1);
{
-
// -----------------------------------------------------------------------------
// Sorted Vrac / Species / Alive not itemized
// -----------------------------------------------------------------------------
@@ -1290,8 +1282,25 @@
copyIfNull);
inertBatch.setRankOrder((short) 2);
}
- }
- // TODO BL : benthos, plancton, macro déchet...
+
+ // -----------------------------------------------------------------------------
+ // Sorted Vrac > Benthos
+ // -----------------------------------------------------------------------------
+ {
+ SortingBatch benthosBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ if (benthosBatch == null) {
+ benthosBatch = SortingBatch.Factory.newInstance();
+ batch.getChildBatchs().add(benthosBatch);
+ }
+ beanToEntitySortingBatch(target, batch, benthosBatch, recorderDepartmentId,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
+ source.getBenthosTotalSampleSortedWeight(), source.getBenthosTotalSortedWeight(),
+ copyIfNull);
+ benthosBatch.setRankOrder((short) 2);
+ }
+
+ // TODO plancton, macro déchet...
+ }
}
// -----------------------------------------------------------------------------
@@ -1313,24 +1322,45 @@
{
Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
- // Species :
- SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- if (speciesBatch == null) {
- speciesBatch = SortingBatch.Factory.newInstance();
- if (batch.getChildBatchs() == null) {
- batch.setChildBatchs(Lists.newArrayList((Batch) speciesBatch));
- } else {
- batch.getChildBatchs().add(speciesBatch);
- }
+ // -----------------------------------------------------------------------------
+ // Hors Vrac > Species :
+ // -----------------------------------------------------------------------------
+ {
+ SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ if (speciesBatch == null) {
+ speciesBatch = SortingBatch.Factory.newInstance();
+ if (batch.getChildBatchs() == null) {
+ batch.setChildBatchs(Lists.newArrayList((Batch) speciesBatch));
+ } else {
+ batch.getChildBatchs().add(speciesBatch);
+ }
+ }
+ beanToEntitySortingBatch(target, batch, speciesBatch, recorderDepartmentId,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ source.getSpeciesTotalUnsortedWeight(), null,
+ copyIfNull);
+ speciesBatch.setRankOrder((short) 1);
}
- beanToEntitySortingBatch(target, batch, speciesBatch, recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- source.getSpeciesTotalUnsortedWeight(), null,
- copyIfNull);
- speciesBatch.setRankOrder((short) 1);
+
+ // -----------------------------------------------------------------------------
+ // Hors Vrac > Benthos :
+ // -----------------------------------------------------------------------------
+ {
+ SortingBatch benthosBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ if (benthosBatch == null) {
+ benthosBatch = SortingBatch.Factory.newInstance();
+ batch.getChildBatchs().add(benthosBatch);
+ }
+ beanToEntitySortingBatch(target, batch, benthosBatch, recorderDepartmentId,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
+ source.getBenthosTotalUnsortedWeight(), null,
+ copyIfNull);
+ benthosBatch.setRankOrder((short) 2);
+ }
+
+ // TODO : plancton, macro déchet...
}
- // TODO BL : benthos, plancton, macro déchet...
}
// -----------------------------------------------------------------------------
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-28 11:59:26 UTC (rev 503)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceService.java 2013-02-28 19:20:19 UTC (rev 504)
@@ -26,6 +26,9 @@
import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
import fr.ifremer.tutti.persistence.entities.data.Program;
+
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -46,6 +49,7 @@
*
* @return the list of programs found in db.
*/
+ @Cacheable(value = "programs")
List<Program> getAllProgram();
/**
@@ -59,8 +63,10 @@
Program getProgram(String id);
@Transactional(readOnly = false)
+ @CacheEvict(value = {"programs", "programZones"}, allEntries = true)
Program createProgram(Program bean);
@Transactional(readOnly = false)
+ @CacheEvict(value = {"programs", "programZones"}, allEntries = true)
Program saveProgram(Program bean);
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-02-28 11:59:26 UTC (rev 503)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-02-28 19:20:19 UTC (rev 504)
@@ -37,6 +37,9 @@
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.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -60,6 +63,7 @@
* @see Program#setZone(Zone)
* @since 0.3
*/
+ @Cacheable(value = "programZones")
List<Zone> getAllProgramZone();
/**
@@ -126,6 +130,7 @@
* @see Cruise#setVessel(List)
* @since 0.3
*/
+ @Cacheable(value = "fishingVessels")
List<Vessel> getAllFishingVessel();
/**
@@ -133,18 +138,21 @@
* @return the vessel
* @since 0.3
*/
+ @Cacheable(value = "vesselByCode", key="#vesselCode")
Vessel getVessel(String vesselCode);
/**
* @return all referent species
* @since 0.3
*/
+ @Cacheable(value = "referentSpecies")
List<Species> getAllReferentSpecies();
/**
* @return all species
* @since 0.3
*/
+ @Cacheable(value = "species")
List<Species> getAllSpecies();
/**
@@ -155,12 +163,14 @@
* @see Species#getReferenceTaxonId()
* @since 0.3
*/
+ @Cacheable(value = "referentSpeciesById", key = "#referenceTaxonId", condition = "#referenceTaxonId != null")
Species getSpeciesByReferenceTaxonId(Integer referenceTaxonId);
/**
* @return all caracteristics of the system.
* @since 1.0
*/
+ @Cacheable(value = "pmfms")
List<Caracteristic> getAllCaracteristic();
/**
@@ -185,12 +195,15 @@
List<Gear> getAllFishingGear();
+ @Cacheable(value = "persons")
List<Person> getAllPerson();
+ @Cacheable(value = "personById", key = "#personId")
Person getPerson(Integer personId);
Gear getGear(Integer gearId);
+ @Cacheable(value = "pmfmById", key = "#pmfmId")
Caracteristic getCaracteristic(Integer pmfmId);
boolean isSortedQualitativeValue(CaracteristicQualitativeValue value);
@@ -204,6 +217,7 @@
* @since 1.0
*/
@Transactional(readOnly = false)
+ @CacheEvict(value = {"species", "referentSpecies", "referentSpeciesById"}, allEntries = true)
List<Species> importTemporarySpecies(List<Species> species);
/**
@@ -213,6 +227,7 @@
* @since 1.0
*/
@Transactional(readOnly = false)
+ @CacheEvict(value = {"fishingVessels", "vesselByCode"}, allEntries = true)
List<Vessel> importTemporaryVessel(List<Vessel> vessels);
/**
@@ -222,6 +237,7 @@
* @since 1.0
*/
@Transactional(readOnly = false)
+ @CacheEvict(value = {"persons", "personById"}, allEntries = true)
List<Person> importTemporaryPerson(List<Person> persons);
/**
@@ -231,6 +247,7 @@
* @since 1.0
*/
@Transactional(readOnly = false)
+ @CacheEvict(value = "gears", allEntries = true)
List<Gear> importTemporaryGear(List<Gear> gears);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-28 11:59:26 UTC (rev 503)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-28 19:20:19 UTC (rev 504)
@@ -33,6 +33,7 @@
import fr.ifremer.adagio.core.dao.referential.location.LocationExtendDao;
import fr.ifremer.adagio.core.dao.referential.taxon.TaxonNameExtendDao;
import fr.ifremer.adagio.core.dao.referential.taxon.TaxonRefTaxVO;
+import fr.ifremer.adagio.core.service.technical.CacheService;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.referential.AbstractTuttiReferentialEntity;
@@ -47,15 +48,19 @@
import fr.ifremer.tutti.persistence.entities.referential.Status;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.persistence.entities.referential.Zone;
+import net.sf.ehcache.Element;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.type.DateType;
import org.hibernate.type.IntegerType;
import org.hibernate.type.StringType;
+import org.springframework.cache.Cache;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
+import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.stereotype.Service;
@@ -97,6 +102,12 @@
@Resource(name = "locationDao")
protected LocationExtendDao locationDao;
+ @Resource(name = "cacheService")
+ protected CacheService cacheService;
+
+ @Resource(name = "referentialPersistenceService")
+ protected ReferentialPersistenceService thisService;
+
//------------------------------------------------------------------------//
//-- ReferentialPersistenceService implentation --//
//------------------------------------------------------------------------//
@@ -242,17 +253,19 @@
"vesselTypeId", IntegerType.INSTANCE, enumeration.VESSEL_TYPE_ID_SCIENTIFIC);
List<Vessel> result = Lists.newArrayList();
+ Cache vesselByCodeCache = cacheService.getCache("vesselByCode");
+
while (list.hasNext()) {
Object[] source = list.next();
- Vessel target = loadVessel(source, true);
-
- result.add(target);
+ Vessel target = loadVessel(source, true);
+ result.add(target);
+ // Add to cache
+ vesselByCodeCache.put(target.getId(), target);
}
return result;
}
@Override
- @Cacheable(value = "fishingVessels")
public List<Vessel> getAllFishingVessel() {
Iterator<Object[]> list = queryListWithStatus(
"allVessels",
@@ -261,11 +274,16 @@
);
List<Vessel> result = Lists.newArrayList();
+ Cache vesselByCodeCache = cacheService.getCache("vesselByCode");
+
while (list.hasNext()) {
Object[] source = list.next();
- Vessel target = loadVessel(source, false);
+ Vessel target = loadVessel(source, true);
target.setScientificVessel(false);
- result.add(target);
+ result.add(target);
+
+ // Add to cache
+ vesselByCodeCache.put(target.getId(), target);
}
return result;
}
@@ -363,37 +381,38 @@
}
@Override
- @Cacheable(value = "species")
public List<Species> getAllSpecies() {
TaxonRefTaxVO[] sources = taxonNameDao.getAllTaxonNames(true);
List<Species> result = Lists.newArrayListWithCapacity(sources.length);
List<Species> referenceTaxonsOnly = Lists.newArrayList();
+ Cache referentSpeciesByIdCache = cacheService.getCache("referentSpeciesById");
for (TaxonRefTaxVO source : sources) {
Species target = loadSpecies(source);
if (target.isReferenceTaxon()) {
// Add to cache :
- putToSpeciesReferentCache(target.getReferenceTaxonId(), target);
+ referentSpeciesByIdCache.put(target.getReferenceTaxonId(), target);
+
referenceTaxonsOnly.add(target);
}
result.add(target);
}
// Add to cache :
- putToSpeciesReferentCache(referenceTaxonsOnly);
+ Cache allReferentSpeciesCache = cacheService.getCache("referentSpecies");
+ allReferentSpeciesCache.put("", referenceTaxonsOnly);
return result;
}
@Override
- @Cacheable(value = "referentSpecies")
public List<Species> getAllReferentSpecies() {
TaxonRefTaxVO[] sources = taxonNameDao.getAllTaxonNames(false);
-
List<Species> result = Lists.newArrayListWithCapacity(sources.length);
+ Cache referentSpeciesByIdCache = cacheService.getCache("referentSpeciesById");
for (TaxonRefTaxVO source : sources) {
if (36403 == source.getTaxonNameId() || 34539 == source.getTaxonNameId()) {
continue;
@@ -401,7 +420,7 @@
Species target = loadSpecies(source);
// Add to cache :
- putToSpeciesReferentCache(target.getReferenceTaxonId(), target);
+ referentSpeciesByIdCache.put(target.getReferenceTaxonId(), target);
result.add(target);
}
@@ -409,7 +428,6 @@
}
@Override
- @Cacheable(value = "referentSpecies", key = "#speciesId")
public Species getSpeciesByReferenceTaxonId(Integer speciesId) {
Species target;
try {
@@ -423,26 +441,21 @@
}
@Override
- @Cacheable(value = "pmfms")
public List<Caracteristic> getAllCaracteristic() {
Iterator<Object[]> sources = queryListWithStatus(
"allPmfm",
"unitIdNone", IntegerType.INSTANCE, enumeration.UNIT_ID_NONE);
List<Caracteristic> result = Lists.newArrayList();
+ Cache pmfmByIdCache = cacheService.getCache("pmfmById");
while (sources.hasNext()) {
Object[] source = sources.next();
Integer pmfmId = (Integer) source[0];
+ Caracteristic target = loadCaracteristic(source);
// Skip some protected PSFM
- if (!isProtectedCaracteristic(pmfmId)) {
- Caracteristic target = loadCaracteristic(source);
- putToCaracteristicCache(pmfmId, target);
-
+ if (!isProtectedCaracteristic(pmfmId)) {
result.add(target);
}
- // If protected, load anyway just for the cache
- else {
- putToCaracteristicCache(pmfmId, loadCaracteristic(source));
- }
+ pmfmByIdCache.put(pmfmId, target);
}
return result;
}
@@ -476,7 +489,7 @@
@Override
public Caracteristic getSortedUnsortedCaracteristic() {
Integer pmfmId = enumeration.PMFM_ID_SORTED_UNSORTED;
- Caracteristic result = getCaracteristic(pmfmId);
+ Caracteristic result = thisService.getCaracteristic(pmfmId);
// Search the qualitative value to skip
for (CaracteristicQualitativeValue qv : result.getQualitativeValue()) {
@@ -492,26 +505,25 @@
@Override
public Caracteristic getMaturityCaracteristic() {
Integer pmfmId = enumeration.PMFM_ID_MATURITY;
- Caracteristic result = getCaracteristic(pmfmId);
+ Caracteristic result = thisService.getCaracteristic(pmfmId);
return result;
}
@Override
public Caracteristic getMacroWasteCategoryCaracteristic() {
Integer pmfmId = enumeration.PMFM_ID_MARINE_LITTER_TYPE;
- Caracteristic result = getCaracteristic(pmfmId);
+ Caracteristic result = thisService.getCaracteristic(pmfmId);
return result;
}
@Override
public Caracteristic getMacroWasteSizeCategoryCaracteristic() {
Integer pmfmId = enumeration.PMFM_ID_MARINE_LITTER_SIZE_CATEGORY;
- Caracteristic result = getCaracteristic(pmfmId);
+ Caracteristic result = thisService.getCaracteristic(pmfmId);
return result;
}
@Override
- @Cacheable(value = "pmfms", key = "#pmfmId")
public Caracteristic getCaracteristic(Integer pmfmId) {
Object[] source = queryUniqueWithStatus("pmfmById",
"pmfmId", IntegerType.INSTANCE, pmfmId,
@@ -521,7 +533,6 @@
}
@Override
- @CacheEvict(value = {"species", "referentSpecies"}, allEntries = true)
public List<Species> importTemporarySpecies(List<Species> species) {
List<Species> result = Lists.newArrayList();
for (Species source : species) {
@@ -532,7 +543,6 @@
}
@Override
- @CacheEvict(value = "fishingVessels", allEntries = true)
public List<Vessel> importTemporaryVessel(List<Vessel> vessels) {
List<Vessel> result = Lists.newArrayList();
@@ -554,7 +564,6 @@
}
@Override
- @CacheEvict(value = "persons", allEntries = true)
public List<Person> importTemporaryPerson(List<Person> persons) {
List<Person> result = Lists.newArrayList();
@@ -568,7 +577,6 @@
}
@Override
- @CacheEvict(value = "gears", allEntries = true)
public List<Gear> importTemporaryGear(List<Gear> gears) {
List<Gear> result = Lists.newArrayList();
@@ -645,7 +653,8 @@
Species result = loadSpecies(taxonName);
// Add to cache
- putToSpeciesReferentCache(Integer.valueOf(result.getId()), result);
+ Cache cache = cacheService.getCache("referentSpeciesById");
+ cache.put(Integer.valueOf(result.getId()), result);
return result;
}
@@ -878,22 +887,4 @@
}
return sampleCategory;
}
-
- @Cacheable(value = "pmfms", key = "#pmfmId")
- protected Caracteristic putToCaracteristicCache(Integer pmfmId, Caracteristic caracteristic) {
- return caracteristic;
- }
-
- @CachePut(value = "referentSpecies")
- protected List<Species> putToSpeciesReferentCache(List<Species> species) {
-
-
- return species;
- }
-
- @CachePut(value = "referentSpecies", key = "#speciesId")
- protected Species putToSpeciesReferentCache(Integer speciesId, Species species) {
- return species;
- }
-
}
Modified: trunk/tutti-persistence/src/main/resources/applicationContext-service-tutti.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/applicationContext-service-tutti.xml 2013-02-28 11:59:26 UTC (rev 503)
+++ trunk/tutti-persistence/src/main/resources/applicationContext-service-tutti.xml 2013-02-28 19:20:19 UTC (rev 504)
@@ -52,46 +52,83 @@
<property name="diskPersistent" value="false"/>
<property name="diskExpiryThreadIntervalSeconds" value="300"/>
</bean>
-
- <bean id="tuttiBatchTreeCache" parent="tuttiAbstractCache">
- <property name="cacheName" value="batchTree" />
- </bean>
-
+
<!-- Eternal caches : -->
<bean id="tuttiAbstractEternalCache" abstract="true" parent="tuttiAbstractCache">
<property name="eternal" value="true"/>
<property name="overflowToDisk" value="true"/>
+ <property name="maxElementsOnDisk" value="5000"/>
<property name="diskPersistent" value="true"/>
<!-- removed inherited properties -->
<property name="timeToLive" value="0"/>
<property name="timeToIdle" value="0"/>
+ <property name="diskExpiryThreadIntervalSeconds" value="0"/>
</bean>
+ <bean id="tuttiProgramsCache" parent="tuttiAbstractEternalCache">
+ <property name="cacheName" value="programs" />
+ <property name="maxElementsInMemory" value="1"/>
+ <property name="maxElementsOnDisk" value="1"/>
+ </bean>
+
+ <bean id="tuttiProgramZonesCache" parent="tuttiAbstractEternalCache">
+ <property name="cacheName" value="programZones" />
+ <property name="maxElementsInMemory" value="1"/>
+ <property name="maxElementsOnDisk" value="1"/>
+ </bean>
+
<bean id="tuttiPmfmsCache" parent="tuttiAbstractEternalCache">
<property name="cacheName" value="pmfms" />
</bean>
+ <bean id="tuttiPmfmByIdCache" parent="tuttiAbstractEternalCache">
+ <property name="cacheName" value="pmfmById" />
+ </bean>
<bean id="tuttiFishingVesselsCache" parent="tuttiAbstractEternalCache">
<property name="cacheName" value="fishingVessels" />
+ <property name="maxElementsInMemory" value="1"/>
+ <property name="maxElementsOnDisk" value="1"/>
</bean>
+ <bean id="tuttiFishingVesselByCodeCache" parent="tuttiAbstractEternalCache">
+ <property name="cacheName" value="vesselByCode" />
+ <property name="maxElementsInMemory" value="40000"/>
+ <property name="maxElementsOnDisk" value="40000"/>
+ </bean>
<bean id="tuttiSpeciesCache" parent="tuttiAbstractEternalCache">
<property name="cacheName" value="species" />
- <property name="maxElementsInMemory" value="20000"/>
+ <property name="maxElementsInMemory" value="1"/>
+ <property name="maxElementsOnDisk" value="1"/>
</bean>
<bean id="tuttiReferentSpeciesCache" parent="tuttiAbstractEternalCache">
<property name="cacheName" value="referentSpecies" />
- <property name="maxElementsInMemory" value="10000"/>
+ <property name="maxElementsInMemory" value="1"/>
+ <property name="maxElementsOnDisk" value="1"/>
</bean>
+ <bean id="tuttiReferentSpeciesByIdCache" parent="tuttiAbstractEternalCache">
+ <property name="cacheName" value="referentSpeciesById" />
+ <property name="maxElementsInMemory" value="20000"/>
+ <property name="maxElementsOnDisk" value="20000"/>
+ </bean>
<bean id="tuttiGearsCache" parent="tuttiAbstractEternalCache">
<property name="cacheName" value="gears" />
+ <property name="maxElementsInMemory" value="1"/>
+ <property name="maxElementsOnDisk" value="1"/>
</bean>
<bean id="tuttiPersonsCache" parent="tuttiAbstractEternalCache">
<property name="cacheName" value="persons" />
+ <property name="maxElementsInMemory" value="1"/>
+ <property name="maxElementsOnDisk" value="1"/>
</bean>
+
+ <bean id="tuttiPersonByIdCache" parent="tuttiAbstractEternalCache">
+ <property name="cacheName" value="personById" />
+ <property name="maxElementsInMemory" value="1000"/>
+ <property name="maxElementsOnDisk" value="1000"/>
+ </bean>
<!-- Example to use to create a new cache area :
<bean id="tuttiOtherCache" parent="tuttiPersistenceDefaultCache">
Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-28 11:59:26 UTC (rev 503)
+++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-28 19:20:19 UTC (rev 504)
@@ -328,16 +328,6 @@
<query-param name="pmfmIdSortingType" type="java.lang.Integer"/>
</query>
- <query name="updateBatchSpecies">
- <![CDATA[
- UPDATE SortingBatchImpl b
- SET b.referenceTaxon.id=:referenceTaxonId
- WHERE
- b.id=:batchId
- ]]>
- <query-param name="referenceTaxonId" type="java.lang.Integer"/>
- <query-param name="batchId" type="java.lang.Integer"/>
- </query>
<query name="allSpeciesBatchFrequency">
<![CDATA[
@@ -566,11 +556,10 @@
WHERE
v.vesselType.id = :vesselTypeId
AND v.status.code IN (:statusValidCode, :statusTemporaryCode)
- AND NOT(coalesce(vrp.endDateTime, '2999-12-31 00:00:00') < coalesce(:refDate,sysdate)
- OR vrp.vesselRegistrationPeriodPk.startDateTime > coalesce(:refDate,sysdate)
- )
- AND NOT(coalesce(vf.endDateTime, '2999-12-31 00:00:00') < coalesce(:refDate,sysdate)
- OR vf.startDateTime > coalesce(:refDate,sysdate)
+ AND vrp.vesselRegistrationPeriodPk.startDateTime <= :refDate
+ AND vf.startDateTime <= :refDate
+ AND coalesce(vrp.endDateTime, :refDate) >= :refDate
+ AND coalesce(vf.endDateTime, :refDate) >= :refDate
)
]]>
<query-param name="vesselTypeId" type="java.lang.Integer"/>
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-28 11:59:26 UTC (rev 503)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java 2013-02-28 19:20:19 UTC (rev 504)
@@ -156,6 +156,7 @@
long delta1 = System.currentTimeMillis() - time;
assertResultList(result, fixtures.refNbFishingVessel());
+ log.debug("Load fishing vessels (without cache) in: " + delta1 + "ms");
// try again, to check cache is enable
time = System.currentTimeMillis();
@@ -163,6 +164,7 @@
assertResultList(result, fixtures.refNbFishingVessel());
long delta2 = System.currentTimeMillis() - time;
+ log.debug("Load fishing vessels (with cache enable) in: " + delta2 + "ms");
//TODO-tc We should not test cache performance like this, depends to much of the computer usage,...
// float reduceFactor = delta2 * 100 / delta1;
1
0
r503 - in trunk/tutti-persistence/src/main/resources: . META-INF/services
by tchemit@users.forge.codelutin.com 28 Feb '13
by tchemit@users.forge.codelutin.com 28 Feb '13
28 Feb '13
Author: tchemit
Date: 2013-02-28 12:59:26 +0100 (Thu, 28 Feb 2013)
New Revision: 503
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/503
Log:
fix query + remove no more use IdAware service file
Removed:
trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware
Modified:
trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
Deleted: trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware
===================================================================
--- trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware 2013-02-28 11:31:03 UTC (rev 502)
+++ trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware 2013-02-28 11:59:26 UTC (rev 503)
@@ -1,20 +0,0 @@
-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.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
-fr.ifremer.tutti.persistence.entities.referential.Gear
-fr.ifremer.tutti.persistence.entities.referential.Caracteristic
-fr.ifremer.tutti.persistence.entities.referential.Person
-fr.ifremer.tutti.persistence.entities.referential.Species
-fr.ifremer.tutti.persistence.entities.referential.Vessel
-fr.ifremer.tutti.persistence.entities.referential.Zone
\ No newline at end of file
Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-28 11:31:03 UTC (rev 502)
+++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-28 11:59:26 UTC (rev 503)
@@ -78,7 +78,7 @@
<!-- [DAT-03] Get a detail program -->
<query name="program">
<![CDATA[
- SELECT
+ SELECT
p.code,
p.name,
p.description,
@@ -119,7 +119,10 @@
mp.id AS managerId,
sc.comments AS scientificCruiseComments,
ft.comments AS fishingTripComments,
- (select sm.alphanumericalValue from SurveyMeasurementImpl sm where sm.fishingTrip.id=ft.id and sm.pmfm.id= :pmfmIdSurveyPart) AS surveyPart,
+ (SELECT sm.alphanumericalValue
+ FROM SurveyMeasurementImpl sm
+ WHERE sm.fishingTrip.id=ft.id AND sm.pmfm.id= :pmfmIdSurveyPart
+ ) AS surveyPart
FROM
ScientificCruiseImpl sc
LEFT OUTER JOIN sc.fishingTrips ft
1
0
Author: tchemit
Date: 2013-02-28 12:31:03 +0100 (Thu, 28 Feb 2013)
New Revision: 502
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/502
Log:
remove tutti.config from svn
Removed:
trunk/tutti-ui-swing/tutti.config
Deleted: trunk/tutti-ui-swing/tutti.config
===================================================================
--- trunk/tutti-ui-swing/tutti.config 2013-02-28 09:10:46 UTC (rev 501)
+++ trunk/tutti-ui-swing/tutti.config 2013-02-28 11:31:03 UTC (rev 502)
@@ -1,6 +0,0 @@
-#Last saved Mon Feb 11 18:03:07 CET 2013
-#Mon Feb 11 18:03:07 CET 2013
-tutti.cruiseId=100001
-tutti.programId=CAM-PELGAS
-tutti.protocolId=15cf939f-cf87-42d2-9999-25222d1d823f
-tutti.ui.coordinateEditorType=DD
1
0
r501 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation
by tchemit@users.forge.codelutin.com 28 Feb '13
by tchemit@users.forge.codelutin.com 28 Feb '13
28 Feb '13
Author: tchemit
Date: 2013-02-28 10:10:46 +0100 (Thu, 28 Feb 2013)
New Revision: 501
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/501
Log:
fix batch model (for the moment)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-02-28 09:08:07 UTC (rev 500)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-02-28 09:10:46 UTC (rev 501)
@@ -505,7 +505,7 @@
getService(PersistenceService.class);
batch = persistenceService.getCatchBatchFromFishingOperation(
- operationId);
+ operationId, true);
batch.setFishingOperation(bean);
}
1
0
28 Feb '13
Author: tchemit
Date: 2013-02-28 10:08:07 +0100 (Thu, 28 Feb 2013)
New Revision: 500
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/500
Log:
- remove BenthosBatch (use now speciesBatch api) (refs #1863)
- remove SpeciesBatchPersistenceService, BenthosBatchPersistenceService, CatchBatchPersistenceService (refs #1863, ...)
- rename some queries
- refs #2025 (try with new highlighter; but still not working...)
Added:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/InvalidBatchModelException.java
Removed:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
trunk/tutti-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/CruisePersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
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/measure/MeasurementPersistenceHelper.java
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeHelperTest.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
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-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -24,8 +24,8 @@
* #L%
*/
+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;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
@@ -330,11 +330,13 @@
/**
* Get the catchBatch from the fishing Operation id.
*
- * @param id id of the fihsing operation
+ * @param id id of the fihsing operation
+ * @param canRepair flag to try to repair the batch model in not in Tutti-awre format.
* @return found catchbatch
*/
@Transactional(readOnly = false)
- CatchBatch getCatchBatchFromFishingOperation(String id);
+ CatchBatch getCatchBatchFromFishingOperation(String id,
+ boolean canRepair) throws CatchBatchValidationException;
/**
* Create the given CatchBatch and return it.
@@ -412,19 +414,47 @@
//-- Benthos Batch methods --//
//------------------------------------------------------------------------//
- List<BenthosBatch> getAllBenthosBatch(String fishingOperationId);
+ List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId);
- BenthosBatch getBenthosBatch(String id);
-
@Transactional(readOnly = false)
- BenthosBatch createBenthosBatch(BenthosBatch bean);
+ SpeciesBatch createBenthosBatch(SpeciesBatch bean, String parentBatchId);
@Transactional(readOnly = false)
- BenthosBatch saveBenthosBatch(BenthosBatch bean);
+ SpeciesBatch saveBenthosBatch(SpeciesBatch bean);
@Transactional(readOnly = false)
void deleteBenthosBatch(String id);
+ @Transactional(readOnly = false)
+ void deleteBenthosSubBatch(String id);
+
+ @Transactional(readOnly = false)
+ void changeBenthosBatchSpecies(String batchId, Species species);
+
+ /**
+ * Get all frequencies for the given species batch.
+ *
+ * @param benthosBatchId the id of the species batch to seek.
+ * @return the list of frequencies for the given specues batch id
+ * @since 1.0
+ */
+ List<SpeciesBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId);
+
+ /**
+ * Save all given {@link SpeciesBatchFrequency} into the given
+ * {@code benthosBatchId}. If some are not existing then creates them.
+ * <p/>
+ * <strong>Note:</strong> This will as a side effect remove all previous frequency for this species batch.
+ *
+ * @param benthosBatchId id of the {@link SpeciesBatch} to use
+ * @param frequencies list of frequencies to create or update
+ * @return the persisted list of frequencies
+ * @since 1.0
+ */
+ @Transactional(readOnly = false)
+ List<SpeciesBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId,
+ List<SpeciesBatchFrequency> frequencies);
+
//------------------------------------------------------------------------//
//-- Plancton Batch methods --//
//------------------------------------------------------------------------//
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-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -25,11 +25,9 @@
*/
import com.google.common.collect.Maps;
-
import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.adagio.core.service.technical.CacheService;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
-import fr.ifremer.tutti.persistence.entities.data.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;
@@ -50,8 +48,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.persistence.entities.referential.Zone;
import fr.ifremer.tutti.persistence.service.AccidentalBatchPersistenceService;
-import fr.ifremer.tutti.persistence.service.BenthosBatchPersistenceService;
-import fr.ifremer.tutti.persistence.service.CatchBatchPersistenceService;
+import fr.ifremer.tutti.persistence.service.BatchPersistenceService;
import fr.ifremer.tutti.persistence.service.CruisePersistenceService;
import fr.ifremer.tutti.persistence.service.FishingOperationPersistenceService;
import fr.ifremer.tutti.persistence.service.MacroWasteBatchPersistenceService;
@@ -59,7 +56,6 @@
import fr.ifremer.tutti.persistence.service.ProgramPersistenceService;
import fr.ifremer.tutti.persistence.service.ProtocolPersistenceService;
import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService;
-import fr.ifremer.tutti.persistence.service.SpeciesBatchPersistenceService;
import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -93,15 +89,9 @@
protected FishingOperationPersistenceService fishingOperationService;
@Autowired
- protected CatchBatchPersistenceService catchBatchService;
+ protected BatchPersistenceService batchService;
@Autowired
- protected SpeciesBatchPersistenceService speciesBatchService;
-
- @Autowired
- protected BenthosBatchPersistenceService benthosBatchService;
-
- @Autowired
protected PlanktonBatchPersistenceService planktonBatchService;
@Autowired
@@ -135,10 +125,7 @@
programService.init();
cruiseService.init();
fishingOperationService.init();
- catchBatchService.init();
- speciesBatchService.init();
- benthosBatchService.init();
- benthosBatchService.init();
+ batchService.init();
planktonBatchService.init();
macroWasteBatchService.init();
accidentalBatchService.init();
@@ -155,10 +142,7 @@
programService.close();
cruiseService.close();
fishingOperationService.close();
- catchBatchService.close();
- speciesBatchService.close();
- benthosBatchService.close();
- benthosBatchService.close();
+ batchService.close();
planktonBatchService.close();
macroWasteBatchService.close();
accidentalBatchService.close();
@@ -457,24 +441,19 @@
//------------------------------------------------------------------------//
@Override
- public CatchBatch getCatchBatchFromFishingOperation(String id) {
- try {
- return catchBatchService.getCatchBatchFromFishingOperation(id, true);
- } catch (CatchBatchValidationException e) {
- // TODO Code lutin : throw exception and ask user : "Voulez convertir les donnees d'echantillonnage dans un format compatible tutti ?"
- e.printStackTrace();
- return null;
- }
+ public CatchBatch getCatchBatchFromFishingOperation(String id,
+ boolean canRepair) throws CatchBatchValidationException {
+ return batchService.getCatchBatchFromFishingOperation(id, canRepair);
}
@Override
public CatchBatch createCatchBatch(CatchBatch bean) {
- return catchBatchService.createCatchBatch(bean);
+ return batchService.createCatchBatch(bean);
}
@Override
public CatchBatch saveCatchBatch(CatchBatch bean) {
- return catchBatchService.saveCatchBatch(bean);
+ return batchService.saveCatchBatch(bean);
}
//------------------------------------------------------------------------//
@@ -483,52 +462,42 @@
@Override
public List<SpeciesBatch> getAllRootSpeciesBatch(String fishingOperationId) {
- return speciesBatchService.getAllRootSpeciesBatch(fishingOperationId);
+ return batchService.getAllRootSpeciesBatch(fishingOperationId);
}
-// @Override
-// public List<SpeciesBatch> getAllSpeciesBatch(String fishingOperationId) {
-// return speciesBatchService.getAllSpeciesBatch(fishingOperationId);
-// }
-
-// @Override
-// public SpeciesBatch getSpeciesBatch(String id) {
-// return speciesBatchService.getSpeciesBatch(id);
-// }
-
@Override
public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId) {
- return speciesBatchService.createSpeciesBatch(bean, parentBatchId);
+ return batchService.createSpeciesBatch(bean, parentBatchId);
}
@Override
public SpeciesBatch saveSpeciesBatch(SpeciesBatch bean) {
- return speciesBatchService.saveSpeciesBatch(bean);
+ return batchService.saveSpeciesBatch(bean);
}
@Override
public void deleteSpeciesBatch(String id) {
- speciesBatchService.deleteSpeciesBatch(id);
+ batchService.deleteSpeciesBatch(id);
}
@Override
public void deleteSpeciesSubBatch(String id) {
- speciesBatchService.deleteSpeciesSubBatch(id);
+ batchService.deleteSpeciesSubBatch(id);
}
@Override
public void changeSpeciesBatchSpecies(String batchId, Species species) {
- speciesBatchService.changeSpeciesBatchSpecies(batchId, species);
+ batchService.changeSpeciesBatchSpecies(batchId, species);
}
@Override
public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String speciesBatchId) {
- return speciesBatchService.getAllSpeciesBatchFrequency(speciesBatchId);
+ return batchService.getAllSpeciesBatchFrequency(speciesBatchId);
}
@Override
public List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(String speciesBatchId, List<SpeciesBatchFrequency> frequencies) {
- return speciesBatchService.saveSpeciesBatchFrequency(speciesBatchId, frequencies);
+ return batchService.saveSpeciesBatchFrequency(speciesBatchId, frequencies);
}
//------------------------------------------------------------------------//
@@ -536,30 +505,46 @@
//------------------------------------------------------------------------//
@Override
- public List<BenthosBatch> getAllBenthosBatch(String fishingOperationId) {
- return benthosBatchService.getAllBenthosBatch(fishingOperationId);
+ public List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId) {
+ return batchService.getAllRootBenthosBatch(fishingOperationId);
}
@Override
- public BenthosBatch getBenthosBatch(String id) {
- return benthosBatchService.getBenthosBatch(id);
+ public SpeciesBatch createBenthosBatch(SpeciesBatch bean, String parentBatchId) {
+ return batchService.createBenthosBatch(bean, parentBatchId);
}
@Override
- public BenthosBatch createBenthosBatch(BenthosBatch bean) {
- return benthosBatchService.createBenthosBatch(bean);
+ public SpeciesBatch saveBenthosBatch(SpeciesBatch bean) {
+ return batchService.saveBenthosBatch(bean);
}
@Override
- public BenthosBatch saveBenthosBatch(BenthosBatch bean) {
- return benthosBatchService.saveBenthosBatch(bean);
+ public void deleteBenthosBatch(String id) {
+ batchService.deleteBenthosBatch(id);
}
@Override
- public void deleteBenthosBatch(String id) {
- benthosBatchService.deleteBenthosBatch(id);
+ public void deleteBenthosSubBatch(String id) {
+ batchService.deleteBenthosSubBatch(id);
}
+ @Override
+ public void changeBenthosBatchSpecies(String batchId, Species species) {
+ batchService.changeBenthosBatchSpecies(batchId, species);
+ }
+
+ @Override
+ public List<SpeciesBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) {
+ return batchService.getAllBenthosBatchFrequency(benthosBatchId);
+ }
+
+ @Override
+ public List<SpeciesBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId,
+ List<SpeciesBatchFrequency> frequencies) {
+ return batchService.saveBenthosBatchFrequency(benthosBatchId, frequencies);
+ }
+
//------------------------------------------------------------------------//
//-- Plancton Batch methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -25,7 +25,6 @@
*/
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;
@@ -307,7 +306,7 @@
}
@Override
- public CatchBatch getCatchBatchFromFishingOperation(String id) {
+ public CatchBatch getCatchBatchFromFishingOperation(String id, boolean canRepair) {
throw new RuntimeException("method not implemented");
}
@@ -362,31 +361,46 @@
}
@Override
- public List<BenthosBatch> getAllBenthosBatch(String fishingOperationId) {
+ public List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId) {
throw new RuntimeException("method not implemented");
}
@Override
- public BenthosBatch getBenthosBatch(String id) {
+ public SpeciesBatch createBenthosBatch(SpeciesBatch bean, String parentBatchId) {
throw new RuntimeException("method not implemented");
}
@Override
- public BenthosBatch createBenthosBatch(BenthosBatch bean) {
+ public SpeciesBatch saveBenthosBatch(SpeciesBatch bean) {
throw new RuntimeException("method not implemented");
}
@Override
- public BenthosBatch saveBenthosBatch(BenthosBatch bean) {
+ public void deleteBenthosBatch(String id) {
throw new RuntimeException("method not implemented");
}
@Override
- public void deleteBenthosBatch(String id) {
+ public void deleteBenthosSubBatch(String id) {
throw new RuntimeException("method not implemented");
}
@Override
+ public void changeBenthosBatchSpecies(String batchId, Species species) {
+ throw new RuntimeException("method not implemented");
+ }
+
+ @Override
+ public List<SpeciesBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) {
+ throw new RuntimeException("method not implemented");
+ }
+
+ @Override
+ public List<SpeciesBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId, List<SpeciesBatchFrequency> frequencies) {
+ throw new RuntimeException("method not implemented");
+ }
+
+ @Override
public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
throw new RuntimeException("method not implemented");
}
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-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -25,15 +25,210 @@
*/
+import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
+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 fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
import org.springframework.transaction.annotation.Transactional;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
+import java.util.List;
@Transactional(readOnly = true)
-public interface BatchPersistenceService extends CatchBatchPersistenceService, SpeciesBatchPersistenceService {
+public interface
+ BatchPersistenceService extends TuttiPersistenceServiceImplementor {
- void cleanEntity(CatchBatch catchBatch, boolean keepTotalWeight);
+ //------------------------------------------------------------------------//
+ //-- CatchBatch methods --//
+ //------------------------------------------------------------------------//
- void setCatchBatchDao(CatchBatchExtendDao dao);
+ /**
+ * Used to initialize a catch when fixing it.
+ *
+ * @param catchBatch (original batch to fix)
+ * @param keepTotalWeight flag to keep weight assigned on catch batch
+ */
+ void cleanEntity(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
+ boolean keepTotalWeight);
+
+ /**
+ * Used to mock dao in unit tests.
+ *
+ * @param dao dao to use
+ */
+ void setCatchBatchDao(CatchBatchExtendDao dao);
+
+ /**
+ * Get the catchBatch from the fishing Operation id.
+ *
+ * @param fishingOperationId id of the fihsing operation
+ * @return found catchbatch
+ * @throws CatchBatchValidationException
+ */
+ CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException;
+
+ /**
+ * Get the catchBatch from the fishing Operation id.
+ *
+ * @param fishingOperationId 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
+ * @return created catchBatch
+ */
+ @Transactional(readOnly = false)
+ CatchBatch createCatchBatch(CatchBatch bean);
+
+ /**
+ * Save the given catchBatch and return it.
+ *
+ * @param bean batch to save
+ * @return the saved catchBatch
+ */
+ @Transactional(readOnly = false)
+ CatchBatch saveCatchBatch(CatchBatch bean);
+
+ //------------------------------------------------------------------------//
+ //-- SpeciesBatch methods --//
+ //------------------------------------------------------------------------//
+
+ /**
+ * Get all root {@link SpeciesBatch} for the given fishing operation.
+ * <p/>
+ * <strong>Note:</strong> All childs of the batch should be loaded here.
+ *
+ * @param fishingOperationId if of the fishing operation to seek
+ * @return the list of root {@link SpeciesBatch}
+ * @since 1.0
+ */
+ List<SpeciesBatch> getAllRootSpeciesBatch(String fishingOperationId);
+
+ @Transactional(readOnly = false)
+ SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId);
+
+ @Transactional(readOnly = false)
+ SpeciesBatch saveSpeciesBatch(SpeciesBatch bean);
+
+ @Transactional(readOnly = false)
+ void deleteSpeciesBatch(String id);
+
+ @Transactional(readOnly = false)
+ void deleteSpeciesSubBatch(String id);
+
+ /**
+ * Change the species in the given {@code batchId} and in all his
+ * sub batches.
+ *
+ * @param batchId id of the root species batch to treat
+ * @param species species to affect to all batches
+ */
+ @Transactional(readOnly = false)
+ void changeSpeciesBatchSpecies(String batchId, Species species);
+
+ //------------------------------------------------------------------------//
+ //-- SpeciesBatchFrequency methods (for species) --//
+ //------------------------------------------------------------------------//
+
+ /**
+ * Get all frequencies for the given species batch.
+ *
+ * @param speciesBatchId the id of the species batch to seek.
+ * @return the list of frequencies for the given specues batch id
+ * @since 1.0
+ */
+ List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String speciesBatchId);
+
+ /**
+ * Save all given {@link SpeciesBatchFrequency} into the given
+ * {@code speciesBatchId}. If some are not existing then creates them.
+ * <p/>
+ * <strong>Note:</strong> This will as a side effect remove all previous frequency for this species batch.
+ *
+ * @param speciesBatchId id of the {@link SpeciesBatch} to use
+ * @param frequencies list of frequencies to create or update
+ * @return the persisted list of frequencies
+ * @since 1.0
+ */
+ @Transactional(readOnly = false)
+ List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(String speciesBatchId,
+ List<SpeciesBatchFrequency> frequencies);
+
+
+ //------------------------------------------------------------------------//
+ //-- Benthos Batch methods --//
+ //------------------------------------------------------------------------//
+
+ /**
+ * Get all root {@link SpeciesBatch} for the given fishing operation.
+ * <p/>
+ * <strong>Note:</strong> All childs of the batch should be loaded here.
+ *
+ * @param fishingOperationId if of the fishing operation to seek
+ * @return the list of root {@link SpeciesBatch}
+ * @since 1.0
+ */
+ List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId);
+
+ @Transactional(readOnly = false)
+ SpeciesBatch createBenthosBatch(SpeciesBatch bean, String parentBatchId);
+
+ @Transactional(readOnly = false)
+ SpeciesBatch saveBenthosBatch(SpeciesBatch bean);
+
+ @Transactional(readOnly = false)
+ void deleteBenthosBatch(String id);
+
+ @Transactional(readOnly = false)
+ void deleteBenthosSubBatch(String id);
+
+ /**
+ * Change the species in the given {@code batchId} and in all his
+ * sub batches.
+ *
+ * @param batchId id of the root Benthos batch to treat
+ * @param species species to affect to all batches
+ */
+ @Transactional(readOnly = false)
+ void changeBenthosBatchSpecies(String batchId, Species species);
+
+ //------------------------------------------------------------------------//
+ //-- SpeciesBatchFrequency methods (for benthos) --//
+ //------------------------------------------------------------------------//
+
+ /**
+ * Get all frequencies for the given species batch.
+ *
+ * @param benthosBatchId the id of the species batch to seek.
+ * @return the list of frequencies for the given benthos batch id
+ * @since 1.0
+ */
+ List<SpeciesBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId);
+
+ /**
+ * Save all given {@link SpeciesBatchFrequency} into the given
+ * {@code benthosBatchId}. If some are not existing then creates them.
+ * <p/>
+ * <strong>Note:</strong> This will as a side effect remove all previous
+ * frequency for this benthos batch.
+ *
+ * @param benthosBatchId id of the {@link SpeciesBatch} to use
+ * @param frequencies list of frequencies to create or update
+ * @return the persisted list of frequencies
+ * @since 1.0
+ */
+ @Transactional(readOnly = false)
+ List<SpeciesBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId,
+ List<SpeciesBatchFrequency> frequencies);
+
+
}
\ 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-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -25,35 +25,12 @@
*/
-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.CatchBatchValidationException;
import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidator;
import fr.ifremer.adagio.core.dao.data.measure.Measurement;
@@ -75,10 +52,28 @@
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.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.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
@Service("batchPersistenceService")
public class BatchPersistenceServiceImpl
- extends AbstractPersistenceService implements BatchPersistenceService {
+ extends AbstractPersistenceService implements BatchPersistenceService {
/** Logger. */
private static final Log log =
@@ -87,9 +82,6 @@
@Resource(name = "referentialPersistenceService")
protected ReferentialPersistenceService referentialService;
- @Resource(name = "denormalizedBatchDao")
- protected DenormalizedBatchDao denormalizedBatchDao;
-
@Resource(name = "sortingBatchDao")
protected SortingBatchDao sortingBatchDao;
@@ -98,7 +90,7 @@
@Resource(name = "scientificCruiseCatchBatchValidator")
protected CatchBatchValidator catchBatchValidator;
-
+
@Override
public void init() {
super.init();
@@ -111,9 +103,13 @@
super.close();
}
+ //------------------------------------------------------------------------//
+ //-- CatchBatch methods --//
+ //------------------------------------------------------------------------//
+
@Override
public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException {
- return getCatchBatchFromFishingOperation(fishingOperationId, false);
+ return getCatchBatchFromFishingOperation(fishingOperationId, false);
}
@Override
@@ -147,76 +143,95 @@
SortingBatch inertBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(),
"referenceTaxonId", enumeration.REFERENCE_TAXON_ID_INERT);
if (inertBatch != null) {
- result.setSpeciesTotalInertWeight(inertBatch.getWeight());
+ result.setSpeciesTotalInertWeight(inertBatch.getWeight());
}
// Alive no itemized
SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(),
"referenceTaxonId", enumeration.REFERENCE_TAXON_ID_LIFE);
if (livingNotItemizedBatch != null) {
- result.setSpeciesTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight());
+ result.setSpeciesTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight());
}
}
- // TODO : Benthos, Plancton...
+ // Benthos
+ SortingBatch benthosBatch = catchBatchDao.getSortingBatch(vracBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+
+ result.setBenthosTotalSampleSortedWeight(benthosBatch.getWeight());
+ result.setBenthosTotalSortedWeight(benthosBatch.getWeightBeforeSampling());
+
+ // TODO : Plancton...
}
// Hors Vrac
SortingBatch horsVracBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(),
"pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID);
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...
- }
+ 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());
+
+ SortingBatch benthosBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+
+ result.setBenthosTotalUnsortedWeight(benthosBatch.getWeight());
+
+
+ // TODO : Plancton...
+ }
}
// Non trié
SortingBatch unsortedBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(),
"pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_UNSORTED_ID);
if (unsortedBatch != null) {
- result.setCatchTotalRejectedWeight(unsortedBatch.getWeight());
+ 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()
+ public void cleanEntity(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
+ boolean keepTotalWeight) {
+
+ Preconditions.checkNotNull(catchBatch);
+ Preconditions.checkNotNull(catchBatch.getChildBatchs());
+
+ for (Batch batch : catchBatch.getChildBatchs()) {
+ 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);
+ bean.setId(catchBatch.getId().toString());
- // If need, copy the total weight, to be sure beanToEntity() will restore it
- if (keepTotalWeight) {
- bean.setCatchTotalWeight(catchBatch.getWeight());
- }
-
+ // 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 void setCatchBatchDao(CatchBatchExtendDao catchBatchDao) {
+ this.catchBatchDao = catchBatchDao;
+ }
+
+
+ @Override
public CatchBatch createCatchBatch(CatchBatch bean) {
Preconditions.checkNotNull(bean);
Preconditions.checkArgument(bean.getId() == null);
@@ -240,7 +255,7 @@
return bean;
}
-
+
@Override
@CacheEvict(value = "batchTree", key = "#bean.fishingOperation.id")
public CatchBatch saveCatchBatch(CatchBatch bean) {
@@ -262,6 +277,10 @@
return bean;
}
+ //------------------------------------------------------------------------//
+ //-- SpeciesBatch methods --//
+ //------------------------------------------------------------------------//
+
@Override
public List<SpeciesBatch> getAllRootSpeciesBatch(String fishingOperationId) {
@@ -275,13 +294,13 @@
SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
"pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
"pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- for (Iterator<Batch> iterator = vracSpeciesBatch.getChildBatchs().iterator(); iterator.hasNext(); ) {
- SortingBatch source = (SortingBatch) iterator.next();
+ for (Batch batch1 : vracSpeciesBatch.getChildBatchs()) {
+ SortingBatch source = (SortingBatch) batch1;
// evict some special batches : Life (or Biota) and Inert
if (source.getReferenceTaxon() != null
- && enumeration.REFERENCE_TAXON_ID_LIFE.equals(source.getReferenceTaxon().getId()) == false
- && enumeration.REFERENCE_TAXON_ID_INERT.equals(source.getReferenceTaxon().getId()) == false) {
+ && !enumeration.REFERENCE_TAXON_ID_LIFE.equals(source.getReferenceTaxon().getId())
+ && !enumeration.REFERENCE_TAXON_ID_INERT.equals(source.getReferenceTaxon().getId())) {
SpeciesBatch target = new SpeciesBatch();
entityToBean(source, target);
@@ -294,77 +313,16 @@
"pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
"pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
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);
- }
- }
+ for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) {
+ SortingBatch source = (SortingBatch) batch;
- return result;
- }
+ SpeciesBatch target = new SpeciesBatch();
- protected SpeciesBatch entityToBean(SortingBatch source, SpeciesBatch target) {
-
- target.setId(source.getId().toString());
-
- // Individual count
- target.setNumber(source.getIndividualCount());
-
- // Convert database weight (and sampling ratio) into UI weight and sampleCategoryWeight
- if (source.getWeight() != null && source.getWeightBeforeSampling() == null) {
- target.setSampleCategoryWeight(source.getWeight());
- } else {
- target.setWeight(source.getWeight());
- target.setSampleCategoryWeight(source.getWeightBeforeSampling());
- }
-
- // Comments
- target.setComment(source.getComments());
-
- // Sample category type (only one is applied)
- SortingMeasurement sm = null;
- if (source.getSortingMeasurements().size() == 1) {
- sm = source.getSortingMeasurements().iterator().next();
- } else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) {
- sm = catchBatchDao.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
- }
- if (sm != null) {
- SampleCategoryEnum sampleCategory = referentialService.getSampleCategoryByPmfmId(sm.getPmfm().getId());
- if (sampleCategory != null) {
- setSampleCategoryQualitative(target, sm.getPmfm().getId(), sm.getNumericalValue(), sm.getAlphanumericalValue(), sm.getQualitativeValue().getId());
+ entityToBean(source, target);
+ result.add(target);
}
}
-
- // Species
- Integer referenceTaxonId = source.getInheritedReferenceTaxonId();
- if (referenceTaxonId == null && source.getReferenceTaxon() != null) {
- referenceTaxonId = source.getReferenceTaxon().getId();
- }
- if (referenceTaxonId != null) {
- // TODO : add cache on getSpeciesByReferenceTaxonId
- Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxonId);
- target.setSpecies(species);
- }
-
- if (target.getSampleCategoryType() != null && source.getChildBatchs().size() > 0) {
- List<SpeciesBatch> targetChilds = Lists.newArrayList();
- for (Iterator<Batch> iterator = source.getChildBatchs().iterator(); iterator.hasNext(); ) {
- SortingBatch sourceChild = (SortingBatch) iterator.next();
- SpeciesBatch targetChild = new SpeciesBatch();
- entityToBean(sourceChild, targetChild);
- if (targetChild.getSampleCategoryValue() != null) {
- targetChilds.add(targetChild);
- targetChild.setParentBatch(target);
- }
- }
- target.setChildBatchs(targetChilds);
- }
-
- return target;
+ return result;
}
@Override
@@ -428,10 +386,12 @@
getCurrentSession().flush();
}
+ @Override
public void deleteSpeciesSubBatch(String id) {
deleteSpeciesBatch(id);
}
+ @Override
public void changeSpeciesBatchSpecies(String batchId, Species species) {
Preconditions.checkNotNull(batchId);
Preconditions.checkNotNull(species);
@@ -447,6 +407,11 @@
Preconditions.checkArgument(rowUpdated == 1, "Unable to update operation, to be linked with catch batch.");
}
+ //------------------------------------------------------------------------//
+ //-- SpeciesBatchFrequency methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(
String speciesBatchId) {
List<SpeciesBatchFrequency> results = Lists.newArrayList();
@@ -460,8 +425,8 @@
SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(speciesBatchId));
- for (Iterator<Batch> iterator = sortingBatch.getChildBatchs().iterator(); iterator.hasNext(); ) {
- SortingBatch source = (SortingBatch) iterator.next();
+ for (Batch batch : sortingBatch.getChildBatchs()) {
+ SortingBatch source = (SortingBatch) batch;
SpeciesBatchFrequency target = new SpeciesBatchFrequency();
entityToBean(source, target);
@@ -470,35 +435,24 @@
return results;
}
- protected void entityToBean(SortingBatch source, SpeciesBatchFrequency target) {
+ @Override
+ public List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(
+ String speciesBatchId,
+ List<SpeciesBatchFrequency> frequencies) {
+ Preconditions.checkNotNull(speciesBatchId);
+ Preconditions.checkNotNull(frequencies);
- target.setId(source.getId().toString());
+ // Check that all frequencies have the same length PMFM (before doing any db call)
+ String pmfmId = null;
+ for (SpeciesBatchFrequency source : frequencies) {
- target.setNumber(source.getIndividualCount());
- target.setWeight(source.getWeight());
- target.setComment(source.getComments());
-
- // Length step category
- if (source.getSortingMeasurements().size() == 1) {
- SortingMeasurement sm = source.getSortingMeasurements().iterator().next();
- if (sm.getPmfm() != null && sm.getPmfm().getId() != null) {
- Caracteristic lengthStepCaracteristic = referentialService.getCaracteristic(sm.getPmfm().getId());
- target.setLengthStepCaracteristic(lengthStepCaracteristic);
+ if (pmfmId == null) {
+ pmfmId = source.getLengthStepCaracteristic().getId();
+ } else if (!pmfmId.equals(source.getLengthStepCaracteristic().getId())) {
+ throw new DataIntegrityViolationException("Batch frequencies under one Speciesbatch must have all the same lengthStepCaracteristic");
}
-
- // Length
- target.setLengthStep(sm.getNumericalValue());
}
- }
- public List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(
- String speciesBatchId, List<SpeciesBatchFrequency> frequencies) {
- Preconditions.checkNotNull(speciesBatchId);
- Preconditions.checkNotNull(frequencies);
-
- if (frequencies.size() == 0) {
- return frequencies;
- }
getCurrentSession().setFlushMode(FlushMode.COMMIT);
Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(speciesBatchId));
@@ -513,26 +467,259 @@
// Remember child ids, to remove unchanged item (see at bottom in this method)
List<Integer> notUpdatedChildIds = Lists.newArrayList();
- for (Iterator<Batch> iterator = parentBatch.getChildBatchs().iterator(); iterator.hasNext(); ) {
- SortingBatch sortingBatch = (SortingBatch) iterator.next();
+ for (Batch batch : parentBatch.getChildBatchs()) {
+ SortingBatch sortingBatch = (SortingBatch) batch;
notUpdatedChildIds.add(sortingBatch.getId());
}
short rankOrder = 0;
- String pmfmId = null;
List<SortingBatch> batchsToUpdate = Lists.newArrayList();
for (SpeciesBatchFrequency source : frequencies) {
rankOrder++;
- // Check that all frequencies have the same length PMFM
+ // Not existing batch
+ SortingBatch target;
+ if (source.getId() == null) {
+ target = SortingBatch.Factory.newInstance();
+
+ // Fill the sorting batch from the source
+ beanToEntity(source, target, parentBatch, rankOrder, true);
+
+ // Create the targeted batch, then update the source id
+ sortingBatchDao.create(target);
+ source.setId(target.getId().toString());
+ }
+
+ // Existing batch
+ else {
+ target = sortingBatchDao.load(Integer.valueOf(source.getId()));
+
+ // Fill the sorting batch from the source
+ beanToEntity(source, target, parentBatch, rankOrder, true);
+
+ // Add the batch into a list (will be update later, using this list)
+ batchsToUpdate.add(target);
+
+ notUpdatedChildIds.remove(target.getId());
+ }
+ }
+
+ // If some batchs need to be update, do it
+ if (batchsToUpdate.size() > 0) {
+ sortingBatchDao.update(batchsToUpdate);
+ }
+
+ if (notUpdatedChildIds.size() > 0) {
+ for (Integer batchId : notUpdatedChildIds) {
+ catchBatchDao.removeWithChildren(batchId);
+ }
+ }
+
+ getCurrentSession().flush();
+
+ return frequencies;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Benthos Batch methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId) {
+ // Load batch tree
+ Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+
+ List<SpeciesBatch> result = new ArrayList<SpeciesBatch>();
+
+ // Vrac / Benthos
+ SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
+ "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ for (Batch batch1 : vracSpeciesBatch.getChildBatchs()) {
+ SortingBatch source = (SortingBatch) batch1;
+
+ // evict some special batches : Life (or Biota) and Inert
+ if (source.getReferenceTaxon() != null
+ && !enumeration.REFERENCE_TAXON_ID_LIFE.equals(source.getReferenceTaxon().getId())
+ && !enumeration.REFERENCE_TAXON_ID_INERT.equals(source.getReferenceTaxon().getId())) {
+ SpeciesBatch target = new SpeciesBatch();
+
+ entityToBean(source, target);
+ result.add(target);
+ }
+ }
+
+ // Hors-Vrac / Benthos
+ 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_BENTHOS);
+ if (horsVracSpeciesBatch != null) {
+ for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) {
+ SortingBatch source = (SortingBatch) batch;
+
+ SpeciesBatch target = new SpeciesBatch();
+
+ entityToBean(source, target);
+ result.add(target);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public SpeciesBatch createBenthosBatch(SpeciesBatch bean,
+ String parentBatchId) {
+ Preconditions.checkNotNull(bean);
+ Preconditions.checkArgument(bean.getId() == null);
+ Preconditions.checkNotNull(bean.getSpecies());
+ Preconditions.checkNotNull(bean.getSpecies().getId());
+ Preconditions.checkNotNull(bean.getFishingOperation());
+ Preconditions.checkNotNull(bean.getFishingOperation().getId());
+
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
+
+ // Load full batch tree
+ Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(bean.getFishingOperation().getId()));
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+
+ SortingBatch batch = SortingBatch.Factory.newInstance();
+ beanToEntity(bean, batch, parentBatchId, catchBatch, true);
+ batch = sortingBatchDao.create(batch);
+
+ bean.setId(String.valueOf(batch.getId()));
+
+ getCurrentSession().flush();
+
+ return bean;
+ }
+
+ @Override
+ public SpeciesBatch saveBenthosBatch(SpeciesBatch bean) {
+ Preconditions.checkNotNull(bean);
+ Preconditions.checkNotNull(bean.getId());
+
+ // Load full batch tree
+ Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(bean.getId()));
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
+
+ SortingBatch batch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(bean.getId()));
+ String parentBatchId = null;
+ if (bean.getParentBatch() != null) {
+ parentBatchId = bean.getParentBatch().getId();
+ }
+ beanToEntity(bean, batch, parentBatchId, catchBatch, true);
+ sortingBatchDao.update(batch);
+ getCurrentSession().flush();
+
+ return bean;
+ }
+
+ @Override
+ public void deleteBenthosBatch(String id) {
+ Preconditions.checkNotNull(id);
+
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
+
+ catchBatchDao.removeWithChildren(Integer.valueOf(id));
+
+ getCurrentSession().flush();
+ }
+
+ @Override
+ public void deleteBenthosSubBatch(String id) {
+ deleteBenthosBatch(id);
+ }
+
+ @Override
+ public void changeBenthosBatchSpecies(String batchId, Species species) {
+
+ Preconditions.checkNotNull(batchId);
+ Preconditions.checkNotNull(species);
+ Preconditions.checkNotNull(species.getReferenceTaxonId());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Changing species for batch id=" + batchId);
+ }
+
+ int rowUpdated = queryUpdate("updateBatchSpecies",
+ "batchId", IntegerType.INSTANCE, Integer.valueOf(batchId),
+ "referenceTaxonId", IntegerType.INSTANCE, species.getReferenceTaxonId());
+ Preconditions.checkArgument(rowUpdated == 1, "Unable to update operation, to be linked with catch batch.");
+ }
+
+ //------------------------------------------------------------------------//
+ //-- SpeciesBatchFrequency methods (for benthos) --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public List<SpeciesBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) {
+ List<SpeciesBatchFrequency> results = Lists.newArrayList();
+
+ Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(benthosBatchId));
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+
+ if (catchBatchId == null) {
+ return results;
+ }
+
+ SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(benthosBatchId));
+
+ for (Batch batch : sortingBatch.getChildBatchs()) {
+ SortingBatch source = (SortingBatch) batch;
+ SpeciesBatchFrequency target = new SpeciesBatchFrequency();
+
+ entityToBean(source, target);
+ results.add(target);
+ }
+ return results;
+ }
+
+ @Override
+ public List<SpeciesBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId,
+ List<SpeciesBatchFrequency> frequencies) {
+ Preconditions.checkNotNull(benthosBatchId);
+ Preconditions.checkNotNull(frequencies);
+
+ // Check that all frequencies have the same length PMFM (before doing any db call)
+ String pmfmId = null;
+ for (SpeciesBatchFrequency source : frequencies) {
+
if (pmfmId == null) {
- source.getLengthStepCaracteristic().getId();
+ pmfmId = source.getLengthStepCaracteristic().getId();
} else if (!pmfmId.equals(source.getLengthStepCaracteristic().getId())) {
throw new DataIntegrityViolationException("Batch frequencies under one Speciesbatch must have all the same lengthStepCaracteristic");
}
+ }
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
+
+ Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(benthosBatchId));
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+
+ if (catchBatch == null) {
+ return frequencies;
+ }
+
+ // Retrieve parent
+ SortingBatch parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(benthosBatchId));
+
+ // Remember child ids, to remove unchanged item (see at bottom in this method)
+ List<Integer> notUpdatedChildIds = Lists.newArrayList();
+ for (Batch batch : parentBatch.getChildBatchs()) {
+ SortingBatch sortingBatch = (SortingBatch) batch;
+ notUpdatedChildIds.add(sortingBatch.getId());
+ }
+
+ short rankOrder = 0;
+ List<SortingBatch> batchsToUpdate = Lists.newArrayList();
+ for (SpeciesBatchFrequency source : frequencies) {
+ rankOrder++;
+
// Not existing batch
- SortingBatch target = null;
+ SortingBatch target;
if (source.getId() == null) {
target = SortingBatch.Factory.newInstance();
@@ -564,8 +751,7 @@
}
if (notUpdatedChildIds.size() > 0) {
- for (Iterator<Integer> iterator = notUpdatedChildIds.iterator(); iterator.hasNext(); ) {
- Integer batchId = iterator.next();
+ for (Integer batchId : notUpdatedChildIds) {
catchBatchDao.removeWithChildren(batchId);
}
}
@@ -575,10 +761,94 @@
return frequencies;
}
- // ------------------------------------------------------------------------//
- // -- Internal methods --//
- // ------------------------------------------------------------------------//
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected SpeciesBatch entityToBean(SortingBatch source,
+ SpeciesBatch target) {
+
+ target.setId(source.getId().toString());
+
+ // Individual count
+ target.setNumber(source.getIndividualCount());
+
+ // Convert database weight (and sampling ratio) into UI weight and sampleCategoryWeight
+ if (source.getWeight() != null && source.getWeightBeforeSampling() == null) {
+ target.setSampleCategoryWeight(source.getWeight());
+ } else {
+ target.setWeight(source.getWeight());
+ target.setSampleCategoryWeight(source.getWeightBeforeSampling());
+ }
+
+ // Comments
+ target.setComment(source.getComments());
+
+ // Sample category type (only one is applied)
+ SortingMeasurement sm = null;
+ if (source.getSortingMeasurements().size() == 1) {
+ sm = source.getSortingMeasurements().iterator().next();
+ } else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) {
+ sm = catchBatchDao.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
+ }
+ if (sm != null) {
+ SampleCategoryEnum sampleCategory = referentialService.getSampleCategoryByPmfmId(sm.getPmfm().getId());
+ if (sampleCategory != null) {
+ setSampleCategoryQualitative(target, sm.getPmfm().getId(), sm.getNumericalValue(), sm.getAlphanumericalValue(), sm.getQualitativeValue().getId());
+ }
+ }
+
+ // Species
+ Integer referenceTaxonId = source.getInheritedReferenceTaxonId();
+ if (referenceTaxonId == null && source.getReferenceTaxon() != null) {
+ referenceTaxonId = source.getReferenceTaxon().getId();
+ }
+ if (referenceTaxonId != null) {
+ // TODO : add cache on getSpeciesByReferenceTaxonId
+ Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxonId);
+ target.setSpecies(species);
+ }
+
+ if (target.getSampleCategoryType() != null && source.getChildBatchs().size() > 0) {
+ List<SpeciesBatch> targetChilds = Lists.newArrayList();
+ for (Batch batch : source.getChildBatchs()) {
+ SortingBatch sourceChild = (SortingBatch) batch;
+ SpeciesBatch targetChild = new SpeciesBatch();
+ entityToBean(sourceChild, targetChild);
+ if (targetChild.getSampleCategoryValue() != null) {
+ targetChilds.add(targetChild);
+ targetChild.setParentBatch(target);
+ }
+ }
+ target.setChildBatchs(targetChilds);
+ }
+
+ return target;
+ }
+
+ protected void entityToBean(SortingBatch source,
+ SpeciesBatchFrequency target) {
+
+ target.setId(source.getId().toString());
+
+ target.setNumber(source.getIndividualCount());
+ target.setWeight(source.getWeight());
+ target.setComment(source.getComments());
+
+ // Length step category
+ if (source.getSortingMeasurements().size() == 1) {
+ SortingMeasurement sm = source.getSortingMeasurements().iterator().next();
+ if (sm.getPmfm() != null && sm.getPmfm().getId() != null) {
+ Caracteristic lengthStepCaracteristic = referentialService.getCaracteristic(sm.getPmfm().getId());
+ target.setLengthStepCaracteristic(lengthStepCaracteristic);
+ }
+
+ // Length
+ target.setLengthStep(sm.getNumericalValue());
+ }
+ }
+
protected void beanToEntity(SpeciesBatch source,
SortingBatch target,
String parentBatchId,
@@ -612,10 +882,8 @@
// Start rank order at 3, because of special batches 'Biota' and 'Inert'
short rankOrder = (short) 3;
if (source.getParentBatch() != null && source.getParentBatch().getChildBatchs() != null) {
- // TODO BL : vérifier cela (est-ce que l'item est ajouté à son père AVANT d'être passé au service ?)
rankOrder += (short) source.getParentBatch().getChildBatchs().size();
- }
- else if (target.getParentBatch() != null && target.getParentBatch().getChildBatchs() != null){
+ } else if (target.getParentBatch() != null && target.getParentBatch().getChildBatchs() != null) {
rankOrder += (short) target.getParentBatch().getChildBatchs().size();
}
target.setRankOrder(rankOrder);
@@ -629,11 +897,11 @@
// Nothing to do : will be removed later, using notChangedSortingMeasurements
} else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
} else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -647,7 +915,7 @@
target.setSamplingRatioText(samplingRatioText);
target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight());
QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -659,7 +927,7 @@
// Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
SortingMeasurement sortingMeasurement = setSortingMeasurement(target, recorderDepartmentId,
- source.getSampleCategoryType(), source.getSampleCategoryValue());
+ source.getSampleCategoryType(), source.getSampleCategoryValue());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
}
@@ -709,15 +977,15 @@
}
}
- public void setBatchParents(SpeciesBatch source, SortingBatch target, String parentBatchIdStr,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
+ protected void setBatchParents(SpeciesBatch source, SortingBatch target, String parentBatchIdStr,
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
Preconditions.checkNotNull(target);
Preconditions.checkNotNull(source.getFishingOperation());
Preconditions.checkNotNull(source.getFishingOperation().getId());
// Load existing parent and root
- SortingBatch parentBatch = null;
+ SortingBatch parentBatch;
if (parentBatchIdStr != null) {
parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
}
@@ -753,7 +1021,7 @@
target.setRootBatch(catchBatch);
}
- Integer convertSampleCategoryValueIntoQualitativeId(Serializable value) {
+ protected Integer convertSampleCategoryValueIntoQualitativeId(Serializable value) {
if (value == null)
return null;
Integer qualitativeValueId = null;
@@ -834,7 +1102,7 @@
// Nothing to do : will be removed later, using notChangedSortingMeasurements
} else if (source.getWeight() != null) {
QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -844,7 +1112,7 @@
} else if (source.getLengthStepCaracteristic() != null && source.getLengthStep() != null) {
Integer pmfmId = Integer.valueOf(source.getLengthStepCaracteristic().getId());
SortingMeasurement sortingMeasurement = setSortingMeasurement(target, recorderDepartmentId, pmfmId,
- source.getLengthStep());
+ source.getLengthStep());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
@@ -939,7 +1207,7 @@
// Nothing to do : will be removed later, using notChangedQuantificationMeasurements
} else if (source.getCatchTotalWeight() != null) {
QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getCatchTotalWeight(), true);
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getCatchTotalWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -1181,7 +1449,7 @@
batchReferenceWeight = sampleWeight;
}
QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -1248,7 +1516,7 @@
batchReferenceWeight = sampleWeight;
}
QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
+ enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -1269,14 +1537,14 @@
// 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) {
+
+ protected 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;
+ Integer qvId;
if (value instanceof CaracteristicQualitativeValue) {
qvId = Integer.valueOf(((CaracteristicQualitativeValue) value).getId());
} else if (value instanceof Integer) {
@@ -1291,7 +1559,7 @@
}
}
- public SortingMeasurement setSortingMeasurement(
+ protected SortingMeasurement setSortingMeasurement(
SortingBatch sortingBatch, Integer recorderDepartmentId,
SampleCategoryEnum sampleCategory, Serializable value) {
Preconditions.checkNotNull(sampleCategory);
@@ -1306,7 +1574,7 @@
return sortingMeasurement;
}
- public SortingMeasurement setSortingMeasurement(
+ protected SortingMeasurement setSortingMeasurement(
SortingBatch sortingBatch, Integer recorderDepartmentId,
Integer pmfmId, Serializable value) {
Preconditions.checkNotNull(pmfmId);
@@ -1319,7 +1587,7 @@
return sortingMeasurement;
}
- public Integer sampleCategory2PmfmId(SampleCategoryEnum sampleCategory) {
+ protected Integer sampleCategory2PmfmId(SampleCategoryEnum sampleCategory) {
Integer pmfmId = null;
if (sampleCategory == SampleCategoryEnum.sortedUnsorted) {
pmfmId = enumeration.PMFM_ID_SORTED_UNSORTED;
@@ -1338,11 +1606,4 @@
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
Deleted: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,54 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-
-/**
- * CRUD of {@link BenthosBatch} entity.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-@Transactional(readOnly = true)
-public interface BenthosBatchPersistenceService extends TuttiPersistenceServiceImplementor {
-
- List<BenthosBatch> getAllBenthosBatch(String fishingOperationId);
-
- BenthosBatch getBenthosBatch(String id);
-
- @Transactional(readOnly = false)
- BenthosBatch createBenthosBatch(BenthosBatch bean);
-
- @Transactional(readOnly = false)
- BenthosBatch saveBenthosBatch(BenthosBatch bean);
-
- @Transactional(readOnly = false)
- void deleteBenthosBatch(String id);
-}
Deleted: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,72 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-@Service("benthosBatchPersistenceService")
-public class BenthosBatchPersistenceServiceImpl extends AbstractPersistenceService implements BenthosBatchPersistenceService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(BenthosBatchPersistenceServiceImpl.class);
-
- @Override
- public List<BenthosBatch> getAllBenthosBatch(String fishingOperationId) {
- List<BenthosBatch> result = Lists.newArrayList();
-
- // TODO
- return result;
- }
-
- @Override
- public BenthosBatch getBenthosBatch(String id) {
- return null;
- }
-
- @Override
- public BenthosBatch createBenthosBatch(BenthosBatch bean) {
- return null;
- }
-
- @Override
- public BenthosBatch saveBenthosBatch(BenthosBatch bean) {
- return null;
- }
-
- @Override
- public void deleteBenthosBatch(String id) {
- }
-}
Deleted: 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-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,77 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.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;
-
-/**
- * CRUD of {@link CatchBatch} entity.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-@Transactional(readOnly = true)
-public interface CatchBatchPersistenceService extends TuttiPersistenceServiceImplementor {
-
- /**
- * Get the catchBatch from the fishing Operation id.
- *
- * @param id id of the fihsing operation
- * @return found catchbatch
- * @throws CatchBatchValidationException
- */
- 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
- * @return created catchBatch
- */
- @Transactional(readOnly = false)
- CatchBatch createCatchBatch(CatchBatch bean);
-
- /**
- * Save the given catchBatch and return it.
- *
- * @param bean batch to save
- * @return the saved catchBatch
- */
- @Transactional(readOnly = false)
- CatchBatch saveCatchBatch(CatchBatch bean);
-}
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-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -24,32 +24,13 @@
* #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 com.google.common.collect.Sets;
import fr.ifremer.adagio.core.dao.administration.programStrategy.ProgramDao;
import fr.ifremer.adagio.core.dao.administration.user.PersonDao;
+import fr.ifremer.adagio.core.dao.administration.user.PersonImpl;
+import fr.ifremer.adagio.core.dao.data.measure.SurveyMeasurement;
import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip;
import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.ObservedFishingTrip;
import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise;
@@ -58,11 +39,15 @@
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.QualityFlagImpl;
import fr.ifremer.adagio.core.dao.referential.gear.GearDao;
import fr.ifremer.adagio.core.dao.referential.location.Location;
import fr.ifremer.adagio.core.dao.referential.location.LocationDao;
+import fr.ifremer.adagio.core.dao.referential.pmfm.Pmfm;
import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmDao;
+import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmImpl;
import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueDao;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl;
import fr.ifremer.adagio.core.dao.referential.vessel.VesselDao;
import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
@@ -71,7 +56,26 @@
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 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
@@ -150,7 +154,8 @@
Object[] source = queryUnique(
"cruise",
"cruiseId", IntegerType.INSTANCE, Integer.valueOf(id),
- "countryLocationLevelId", IntegerType.INSTANCE, enumeration.LOCATION_LEVEL_ID_COUNTRY);
+ "countryLocationLevelId", IntegerType.INSTANCE, enumeration.LOCATION_LEVEL_ID_COUNTRY,
+ "pmfmIdSurveyPart", IntegerType.INSTANCE, enumeration.PMFM_ID_SURVEY_PART);
if (source == null) {
return null;
@@ -253,6 +258,9 @@
}
}
+ // load surverPart
+ result.setSurveyPart((String)source[12]);
+
// get secondary gears from fishingOperation (first load from Allegro DB only)
if (result.getGear() == null) {
Iterator<Object[]> list = queryList(
@@ -315,10 +323,11 @@
protected void cruiseToEntity(Cruise source, ScientificCruise target, boolean copyIfNull) {
StringBuilder miscDataBuffer = new StringBuilder();
- QualityFlag qualityFlagNotQualified = qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED);
+ QualityFlag qualityFlagNotQualified = load(
+ QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED);
// Retrieve entities : FishingTrip
- ObservedFishingTrip fishingTrip = null;
+ ObservedFishingTrip fishingTrip;
if (target.getFishingTrips() == null || target.getFishingTrips().size() == 0) {
fishingTrip = ObservedFishingTrip.Factory.newInstance();
if (target.getFishingTrips() == null) {
@@ -438,14 +447,15 @@
if (source.getHeadOfMission().size() > 0) {
Person managerPerson = source.getHeadOfMission().get(0);
if (managerPerson.getId() != null) {
- target.setManagerPerson(personDao.load(Integer.valueOf(managerPerson.getId())));
+ //TODO TC supprimer les xxxDAO.load par load(xxx,)
+ target.setManagerPerson(load(PersonImpl.class, Integer.valueOf(managerPerson.getId())));
}
}
}
// Optional values in UI, but mandatory in DB
if (target.getManagerPerson() == null) {
- target.setManagerPerson(personDao.load(enumeration.PERSON_ID_UNKNOWN_RECORDER_PERSON));
+ target.setManagerPerson(load(PersonImpl.class, enumeration.PERSON_ID_UNKNOWN_RECORDER_PERSON));
}
// Default values :
@@ -490,6 +500,12 @@
fishingTrip.setReturnLocation(locationCountry);
}
+ //TODO Serie partiel (ajouter SurveyMeasurement dans fishingtrip)
+
+ //TODO Creer un psfm serie partielle (voir avec vincent + benoit) (PmfmId.SURVEY_PART)
+
+ setSurveyMeasurement(fishingTrip, enumeration.PMFM_ID_SURVEY_PART, null, source.getSurveyPart(), null);
+
// Gear
if (copyIfNull && source.isGearEmpty() && fishingTrip.getGearPhysicalFeatures() != null) {
fishingTrip.getGearPhysicalFeatures().clear();
@@ -516,9 +532,9 @@
// Trawl net (store in Gear Physical features)
if (copyIfNull && source.getMultirigNumber() == null) {
- gearPhysicalFeaturesDao.removeGearPhysicalMeasurement(guf, enumeration.PMFM_ID_MULTIRIG_NUMBER);
+ gearPhysicalFeaturesDao.removeGearPhysicalMeasurement(guf, enumeration.PMFM_ID_MULTIRIG_NUMBER);
} else {
- gearPhysicalFeaturesDao.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);
}
}
@@ -554,4 +570,54 @@
return persons;
}
+
+ // adapt to surveyMeasurement
+ protected SurveyMeasurement getSurveyMeasurement(FishingTrip scientificCruise,
+ Integer pmfmId,
+ boolean createIfNotExists) {
+ SurveyMeasurement gearUseMeasurement = null;
+
+ for (SurveyMeasurement vum : scientificCruise.getSurveyMeasurements()) {
+ if (pmfmId.equals(vum.getPmfm().getId())) {
+ gearUseMeasurement = vum;
+ break;
+ }
+ }
+
+ if (gearUseMeasurement == null) {
+ if (!createIfNotExists) {
+ return null;
+ }
+ gearUseMeasurement = SurveyMeasurement.Factory.newInstance();
+ if (scientificCruise.getSurveyMeasurements() == null) {
+ scientificCruise.setSurveyMeasurements(Sets.newHashSet(gearUseMeasurement));
+ } else {
+ scientificCruise.getSurveyMeasurements().add(gearUseMeasurement);
+ }
+ gearUseMeasurement.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ gearUseMeasurement.setDepartment(scientificCruise.getRecorderDepartment());
+ Pmfm pmfm = (Pmfm) getCurrentSession().load(PmfmImpl.class, pmfmId);
+ gearUseMeasurement.setPmfm(pmfm);
+ }
+
+ return gearUseMeasurement;
+ }
+
+ protected SurveyMeasurement setSurveyMeasurement(FishingTrip scientificCruise,
+ Integer pmfmId,
+ Float numericalValue,
+ String alphanumericalValue,
+ Integer qualitativevalueId) {
+ SurveyMeasurement vesselUseMeasurement = getSurveyMeasurement(scientificCruise, pmfmId, true);
+
+ if (alphanumericalValue != null) {
+ vesselUseMeasurement.setAlphanumericalValue(alphanumericalValue);
+ } else if (numericalValue != null) {
+ vesselUseMeasurement.setNumericalValue(numericalValue);
+ } else if (qualitativevalueId != null) {
+ vesselUseMeasurement.setQualitativeValue(load(QualitativeValueImpl.class, qualitativevalueId));
+ }
+
+ return vesselUseMeasurement;
+ }
}
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-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -24,34 +24,9 @@
* #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;
@@ -92,7 +67,29 @@
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 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
@@ -104,7 +101,6 @@
private static final Log log =
LogFactory.getLog(FishingOperationPersistenceServiceImpl.class);
-
@Autowired
protected ReferentialPersistenceService referentialService;
@@ -170,7 +166,7 @@
}
if (fishingOperationNumberStr.matches("\\d+")) {
fishingOperation.setFishingOperationNumber(Integer.valueOf(fishingOperationNumberStr));
- }
+ }
}
// If not found, compute it using a counter (see "order by startDateTime" in HQL query)
@@ -189,7 +185,7 @@
}
// Multirig Aggregation
- String multirigAggregation = (String) source[colIndex++];
+ String multirigAggregation = (String) source[colIndex];
if (multirigAggregation != null) {
fishingOperation.setMultirigAggregation(multirigAggregation);
}
@@ -333,17 +329,17 @@
}
// Vessel (the one with the catch batch)
- String vesselCode = (String) source[colIndex++];
+ String vesselCode = (String) source[colIndex];
if (vesselCode != null) {
Vessel vessel = referentialService.getVessel(vesselCode);
result.setVessel(vessel);
}
- // Retrieve environment caracteristics :
- getEnvironmentCaracteristics(id, result);
+ // Retrieve gear shooting caracteristics
+ getGearUseCaracteristics(id, result);
- // Retrieve gear shooting caracteristics :
- getGearShootingCaracteristics(id, result);
+ // TODO-TC Retrieve environment caracteristics with protocol
+ getVesselUseCaracteristics(id, result);
return result;
}
@@ -352,9 +348,17 @@
@Override
public FishingOperation createFishingOperation(FishingOperation bean) {
Preconditions.checkNotNull(bean);
+ Preconditions.checkArgument(bean.getId() == null);
Preconditions.checkNotNull(bean.getCruise());
Preconditions.checkNotNull(bean.getCruise().getId());
+ //TODO-TC Voir si il n'y a pas d'autre données obligatoires
+ if (bean.getGearShootingStartDate() != null && bean.getGearShootingEndDate() != null) {
+
+ //make sure not same date
+ Preconditions.checkArgument(!bean.getGearShootingStartDate().equals(bean.getGearShootingEndDate()));
+ }
+
getCurrentSession().setFlushMode(FlushMode.COMMIT);
fr.ifremer.adagio.core.dao.data.operation.FishingOperation fishingOperation = fr.ifremer.adagio.core.dao.data.operation.FishingOperation.Factory.newInstance();
beanToEntity(bean, fishingOperation, true);
@@ -370,9 +374,12 @@
Preconditions.checkNotNull(bean.getId());
Preconditions.checkNotNull(bean.getCruise());
Preconditions.checkNotNull(bean.getCruise().getId());
+ //TODO-TC Voir si il n'y a pas d'autre données obligatoires
if (bean.getGearShootingStartDate() != null && bean.getGearShootingEndDate() != null) {
- Preconditions.checkArgument(bean.getGearShootingStartDate().equals(bean.getGearShootingEndDate()) == false);
+
+ //make sure not same date
+ Preconditions.checkArgument(!bean.getGearShootingStartDate().equals(bean.getGearShootingEndDate()));
}
getCurrentSession().clear();
@@ -391,10 +398,10 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
- protected void getEnvironmentCaracteristics(String fishingOperationId, FishingOperation result) {
+ protected void getVesselUseCaracteristics(String fishingOperationId, FishingOperation result) {
// retrieve fishing operation caracteristics
Iterator<Object[]> list = queryList(
- "fishingOperationEnvironment",
+ "fishingOperationVesselUseFeatures",
"fishingOperationId", IntegerType.INSTANCE, Integer.valueOf(fishingOperationId)
);
@@ -419,12 +426,11 @@
// Haul valid ?
else if (enumeration.PMFM_ID_HAUL_VALID.equals(pmfmId)) {
- if (qualitativeValueId != null) {
- result.setFishingOperationValid(enumeration.QUALITATIVE_HAUL_VALID_YES.equals(qualitativeValueId));
- }
- else {
- result.setFishingOperationValid(null);
- }
+ if (qualitativeValueId != null) {
+ result.setFishingOperationValid(enumeration.QUALITATIVE_HAUL_VALID_YES.equals(qualitativeValueId));
+ } else {
+ result.setFishingOperationValid(null);
+ }
}
// Station Number :
@@ -434,6 +440,9 @@
// Environment caracteristic
else {
+
+ //TODO Split en fonction du protocole
+
Caracteristic environmentCaracteristic = referentialService.getCaracteristic(pmfmId);
Serializable value = null;
if (environmentCaracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
@@ -457,10 +466,10 @@
}
}
- protected void getGearShootingCaracteristics(String fishingOperationId, FishingOperation result) {
+ protected void getGearUseCaracteristics(String fishingOperationId, FishingOperation result) {
// retrieve fishing operation caracteristics
Iterator<Object[]> list = queryList(
- "fishingOperationGearShooting",
+ "fishingOperationGearUseFeatures",
"fishingOperationId", IntegerType.INSTANCE, Integer.valueOf(fishingOperationId)
);
@@ -489,7 +498,7 @@
} else if (gearShootingCaracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
value = alphanumericalValue;
} else if (gearShootingCaracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
- for (CaracteristicQualitativeValue qv : gearShootingCaracteristic.getQualitativeValue()) {
+ for (CaracteristicQualitativeValue qv : gearShootingCaracteristic.getQualitativeValue()) {
if (qualitativeValueId == Integer.parseInt(qv.getId())) {
value = qv;
break;
@@ -595,6 +604,8 @@
// Retrieve entities : Fishing Area
FishingArea fishingArea;
+ List<FishingArea2RegulationLocation> notChangedRegulationLocation;
+
if (CollectionUtils.isEmpty(gearUseFeatures.getFishingAreas())) {
fishingArea = FishingArea.Factory.newInstance();
if (gearUseFeatures.getFishingAreas() == null) {
@@ -604,19 +615,14 @@
gearUseFeatures.getFishingAreas().add(fishingArea);
fishingArea.setGearUseFeatures(gearUseFeatures);
}
+ notChangedRegulationLocation = Lists.newArrayList();
} else {
fishingArea = gearUseFeatures.getFishingAreas().iterator().next();
+
+ notChangedRegulationLocation = Lists.newArrayList(fishingArea.getRegulationLocation());
// Reset all other fishing areas
}
- // Retrieve entities : CatchBatch
- /*CatchBatch catchBatch = target.getCatchBatch();
- if (catchBatch == null) {
- catchBatch = CatchBatch.Factory.newInstance();
- catchBatch.setFishingOperation(target);
- target.setCatchBatch(catchBatch);
- }*/
-
// Retrieve multirig number, from Gear physical features
int cruiseMultirigCount = 1; // default value
if (gearPhysicalFeatures != null) {
@@ -852,6 +858,8 @@
}
}
+ //TODO Add also *other + hydrologic* caracteristics
+
// Recorder persons
StringBuilder miscDataBuffer = new StringBuilder();
if (copyIfNull && (source.getSaisisseur() == null || source.getSaisisseur().size() == 0)) {
@@ -878,7 +886,7 @@
// Removed unecessary *UseMeasurement : ---
// ----------------------------------------------------------------
- // Gear shooting Caracteristics
+ // Gear use Caracteristics
CaracteristicMap gearShootingCaracteristics = source.getGearShootingCaracteristics();
if (copyIfNull && gearShootingCaracteristics == null || gearShootingCaracteristics.size() == 0) {
// Nothing to do : will be removed later, using notChangedGearUseMeasurements
@@ -914,15 +922,21 @@
statisticalLocationId = locationService.getLocationIdByLatLong(source.getGearShootingEndLatitude(), source.getGearShootingEndLongitude());
}
+ //TODO Do a notchange area and remove it at then end
// Strata :
if (copyIfNull && (source.getStrata() == null || source.getStrata().getId() == null)) {
- // TODO remove from fishing Area ?
+
+ // will be removed using notChangedRegulationLocation
+
} else if (source.getStrata() != null && source.getStrata().getId() != null) {
FishingArea2RegulationLocation fa2rl = FishingArea2RegulationLocation.Factory.newInstance();
FishingArea2RegulationLocationPK fa2rlPK = new FishingArea2RegulationLocationPK();
fa2rl.setFishingArea2RegulationLocationPk(fa2rlPK);
fa2rlPK.setFishingArea(fishingArea);
fa2rlPK.setLocation(load(LocationImpl.class, Integer.valueOf(source.getStrata().getId())));
+
+ //TODO Make this work
+ notChangedRegulationLocation.remove(fa2rl);
if (fishingArea.getRegulationLocation() == null) {
fishingArea.setRegulationLocation(Sets.newHashSet(fa2rl));
} else {
@@ -935,13 +949,19 @@
// Sub-Strata :
if (copyIfNull && (source.getSubStrata() == null || source.getSubStrata().getId() == null)) {
- // TODO remove from fishing Area ?
+
+ // will be removed using notChangedRegulationLocation
+
} else if (source.getSubStrata() != null && source.getSubStrata().getId() != null) {
FishingArea2RegulationLocation fa2rl = FishingArea2RegulationLocation.Factory.newInstance();
FishingArea2RegulationLocationPK fa2rlPK = new FishingArea2RegulationLocationPK();
fa2rl.setFishingArea2RegulationLocationPk(fa2rlPK);
fa2rlPK.setFishingArea(fishingArea);
fa2rlPK.setLocation(load(LocationImpl.class, Integer.valueOf(source.getSubStrata().getId())));
+
+ //TODO Make this work
+ notChangedRegulationLocation.remove(fa2rl);
+
if (fishingArea.getRegulationLocation() == null) {
fishingArea.setRegulationLocation(Sets.newHashSet(fa2rl));
} else {
@@ -954,13 +974,18 @@
// Localite :
if (copyIfNull && (source.getLocation() == null || source.getLocation().getId() == null)) {
- // TODO remove from fishing Area ?
+
+ // will be removed using notChangedRegulationLocation
+
} else if (source.getLocation() != null && source.getLocation().getId() != null) {
FishingArea2RegulationLocation fa2rl = FishingArea2RegulationLocation.Factory.newInstance();
FishingArea2RegulationLocationPK fa2rlPK = new FishingArea2RegulationLocationPK();
fa2rl.setFishingArea2RegulationLocationPk(fa2rlPK);
fa2rlPK.setFishingArea(fishingArea);
fa2rlPK.setLocation(load(LocationImpl.class, Integer.valueOf(source.getLocation().getId())));
+
+ //TODO Make this work
+ notChangedRegulationLocation.remove(fa2rl);
if (fishingArea.getRegulationLocation() == null) {
fishingArea.setRegulationLocation(Sets.newHashSet(fa2rl));
} else {
@@ -971,6 +996,9 @@
}
}
+ //TODO Test well if not removed use fishingArea2RegulationLocationDAO...
+ fishingArea.getRegulationLocation().removeAll(notChangedRegulationLocation);
+
// Fishing Area location (should be a statistical location)
if (copyIfNull && statisticalLocationId == null) {
gearUseFeatures.getFishingAreas().remove(fishingArea);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -244,8 +244,8 @@
List<Vessel> result = Lists.newArrayList();
while (list.hasNext()) {
Object[] source = list.next();
- Vessel target = loadVessel(source);
- target.setScientificVessel(true);
+ Vessel target = loadVessel(source, true);
+
result.add(target);
}
return result;
@@ -263,7 +263,7 @@
List<Vessel> result = Lists.newArrayList();
while (list.hasNext()) {
Object[] source = list.next();
- Vessel target = loadVessel(source);
+ Vessel target = loadVessel(source, false);
target.setScientificVessel(false);
result.add(target);
}
@@ -284,7 +284,7 @@
);
Vessel result;
if (source.hasNext())
- result = loadVessel(source.next());
+ result = loadVessel(source.next(), false);
else
result = null;
return result;
@@ -299,8 +299,7 @@
List<Gear> result = Lists.newArrayList();
while (sources.hasNext()) {
Object[] source = sources.next();
- Gear target = loadGear(source);
- target.setScientificGear(true);
+ Gear target = loadGear(source, true);
result.add(target);
}
return result;
@@ -314,8 +313,7 @@
List<Gear> result = Lists.newArrayList();
while (sources.hasNext()) {
Object[] source = sources.next();
- Gear target = loadGear(source);
- target.setScientificGear(false);
+ Gear target = loadGear(source, false);
result.add(target);
}
return result;
@@ -354,7 +352,7 @@
"gear",
"gearId", IntegerType.INSTANCE, gearId);
- Gear result = source == null ? null : loadGear(source);
+ Gear result = source == null ? null : loadGear(source, true);
return result;
}
@@ -774,12 +772,13 @@
return target;
}
- protected Vessel loadVessel(Object[] source) {
+ protected Vessel loadVessel(Object[] source, boolean scientificVessel) {
Vessel target = new Vessel();
target.setId((String) source[0]);
target.setRegistrationCode((String) source[1]);
target.setInternationalRegistrationCode((String) source[2]);
target.setName((String) source[3]);
+ target.setScientificVessel(scientificVessel);
setStatus((fr.ifremer.adagio.core.dao.referential.Status) source[4], target);
return target;
}
@@ -794,11 +793,13 @@
return target;
}
- protected Gear loadGear(Object[] source) {
+ protected Gear loadGear(Object[] source, boolean scientificGear) {
Gear result = new Gear();
result.setId(String.valueOf(source[0]));
result.setLabel((String) source[1]);
result.setName((String) source[2]);
+ result.setScientificGear(scientificGear);
+
setStatus((fr.ifremer.adagio.core.dao.referential.Status) source[3], result);
return result;
}
@@ -885,6 +886,8 @@
@CachePut(value = "referentSpecies")
protected List<Species> putToSpeciesReferentCache(List<Species> species) {
+
+
return species;
}
Deleted: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,102 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-
-/**
- * CRUD of {@link SpeciesBatch} entity.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-@Transactional(readOnly = true)
-public interface SpeciesBatchPersistenceService extends TuttiPersistenceServiceImplementor {
-
- /**
- * Get all root {@link SpeciesBatch} for the given fishing operation.
- * <p/>
- * <strong>Note:</strong> All childs of the batch should be loaded here.
- *
- * @param fishingOperationId if of the fishing operation to seek
- * @return the list of root {@link SpeciesBatch}
- * @since 1.0
- */
- List<SpeciesBatch> getAllRootSpeciesBatch(String fishingOperationId);
-
- /**
- * Get all frequencies for the given species batch.
- *
- * @param speciesBatchId the id of the species batch to seek.
- * @return the list of frequencies for the given specues batch id
- * @since 1.0
- */
- List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(
- String speciesBatchId);
-
- @Transactional(readOnly = false)
- SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId);
-
- @Transactional(readOnly = false)
- SpeciesBatch saveSpeciesBatch(SpeciesBatch bean);
-
- @Transactional(readOnly = false)
- void deleteSpeciesBatch(String id);
-
- @Transactional(readOnly = false)
- void deleteSpeciesSubBatch(String id);
-
- /**
- * Change the species in the given {@code batchId} and in all his
- * sub batches.
- *
- * @param batchId id of the root species batch to treat
- * @param species species to affect to all batches
- */
- @Transactional(readOnly = false)
- void changeSpeciesBatchSpecies(String batchId, Species species);
-
- /**
- * Save all given {@link SpeciesBatchFrequency} into the given
- * {@code speciesBatchId}. If some are not existing then creates them.
- * <p/>
- * <strong>Note:</strong> This will as a side effect remove all previous frequency for this species batch.
- *
- * @param speciesBatchId id of the {@link SpeciesBatch} to use
- * @param frequencies list of frequencies to create or update
- * @return the persisted list of frequencies
- * @since 1.0
- */
- @Transactional(readOnly = false)
- List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(String speciesBatchId,
- List<SpeciesBatchFrequency> frequencies);
-
-}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -128,6 +128,9 @@
@Value("${QualitativeValueId.SORTING_TYPE_SPECIES}")
public final Integer QUALITATIVE_ID_SORTING_TYPE_SPECIES = null;
+ @Value("${QualitativeValueId.SORTING_TYPE_BENTHOS}")
+ public final Integer QUALITATIVE_ID_SORTING_TYPE_BENTHOS = null;
+
@Value("${StatusCode.ENABLE}")
public final String STATUS_VALID_CODE = null;
@@ -182,6 +185,9 @@
@Value("${PmfmId.AGE}")
public final Integer PMFM_ID_AGE = null;
+ @Value("${PmfmId.SURVEY_PART}")
+ public final Integer PMFM_ID_SURVEY_PART = null;
+
@Value("${ProgramCode.SCIENTIFIC_CRUISE_PREFIX}")
public final String PROGRAM_CODE_SCIENTIFIC_CRUISE_PREFIX = null;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -85,21 +85,6 @@
BatchPersistenceService.class);
}
- public static CatchBatchPersistenceService getCatchBatchPersistenceService() {
- return getPersistenceService("batchPersistenceService",
- CatchBatchPersistenceService.class);
- }
-
- public static SpeciesBatchPersistenceService getSpeciesBatchPersistenceService() {
- return getPersistenceService("batchPersistenceService",
- SpeciesBatchPersistenceService.class);
- }
-
- public static BenthosBatchPersistenceService getBenthosBatchPersistenceService() {
- return getPersistenceService("benthosBatchPersistenceService",
- BenthosBatchPersistenceService.class);
- }
-
public static PlanktonBatchPersistenceService getPlanktonBatchPersistenceService() {
return getPersistenceService("planktonBatchPersistenceService",
PlanktonBatchPersistenceService.class);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -26,6 +26,7 @@
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
import java.util.Collection;
import java.util.HashSet;
@@ -95,31 +96,33 @@
protected void validate(Collection<Batch> batchs, List<CatchBatchValidationError> errors, int treeLevel) {
+ //TODO finishi i18n
+
// 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);
+ addError(errors, n_("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);
+ addError(errors, n_("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");
+ addWarning(errors, n_("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");
+ addWarning(errors, n_("tutti.persistence.batch.validation.vracSpeciesLifeNotFound"));
}
}
@@ -131,14 +134,14 @@
"pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_HORS_VRAC_ID);
if (horsVracBatch == null) {
- addWarning(errors, "tutti.persistence.batch.validation.horsVracSpeciesNotFound");
+ addWarning(errors, n_("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");
+ addWarning(errors, n_("tutti.persistence.batch.validation.horsVracSpeciesNotFound"));
}
// TODO : Benthos, Plancton...
@@ -149,7 +152,7 @@
"pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_UNSORTED_ID);
if (unsortedBatch == null) {
- addWarning(errors, "tutti.persistence.batch.validation.unsortedNotFound");
+ addWarning(errors,n_( "tutti.persistence.batch.validation.unsortedNotFound"));
}
// May be, the tree is an old structure
@@ -157,31 +160,30 @@
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;
- }
- }
- }
- }
+ for (Batch batch1 : batchs) {
+ SortingBatch batch = (SortingBatch) batch1;
+ 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())
+ || sm.getQualitativeValue() == null
+ || !enumeration.QUALITATIVE_VRAC_ID.equals(sm.getQualitativeValue().getId())) {
+ allBatchHasVrac = false;
+ }
+ }
+ }
+ }
if (allBatchHasSpecies && !someBatchHasSortingMeasurement) {
errors.clear();
- addError(errors, "tutti.persistence.batch.validation.onlySpeciesBatchStructure", new CatchBatchQuickFix() {
+ addError(errors,n_( "tutti.persistence.batch.validation.onlySpeciesBatchStructure"), new CatchBatchQuickFix() {
@Override
public CatchBatch repair(CatchBatch catchBatch) {
return ScientificCruiseCatchBatchValidator.this.repairHistoricalData(catchBatch, false);
@@ -190,7 +192,7 @@
}
else if (allBatchHasSpecies && someBatchHasSortingMeasurement && allBatchHasVrac) {
errors.clear();
- addError(errors, "tutti.persistence.batch.validation.onlySpeciesBatchStructure", new CatchBatchQuickFix() {
+ addError(errors, n_("tutti.persistence.batch.validation.onlySpeciesBatchStructure"), new CatchBatchQuickFix() {
@Override
public CatchBatch repair(CatchBatch catchBatch) {
return ScientificCruiseCatchBatchValidator.this.repairHistoricalData(catchBatch, true);
@@ -228,29 +230,30 @@
}
// 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);
+ for (Batch speciesBatchChild : speciesBatchChilds) {
+ SortingBatch batch = (SortingBatch) speciesBatchChild;
+ 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);
- }
+ 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);
+ 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);
+ // 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);
- }
+ //TODO What to do with weird comments! categorie_individu
+ // Reset comments if set to "taxon"
+ if (batch.getComments() != null && "taxon".equals(batch.getComments())) {
+ batch.setComments(null);
+ }
- speciesBatch.getChildBatchs().add(batch);
- }
+ speciesBatch.getChildBatchs().add(batch);
+ }
// Save mofidifications :
catchBatchDao.update(catchBatch);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -124,7 +124,7 @@
} else if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
measurement.setNumericalValue((Float) value);
} else if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
- Integer qvId = null;
+ Integer qvId;
if (value instanceof CaracteristicQualitativeValue) {
qvId = Integer.valueOf(((CaracteristicQualitativeValue) value).getId());
} else if (value instanceof Integer) {
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-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-02-28 09:08:07 UTC (rev 500)
@@ -14,6 +14,7 @@
tutti.option.persistence.protocol.directory.description=Répertoire où sont conservés les protocoles
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.onlySpeciesBatchStructure=
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.
Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-28 09:08:07 UTC (rev 500)
@@ -118,7 +118,8 @@
sc.vessel.code AS vesselCode,
mp.id AS managerId,
sc.comments AS scientificCruiseComments,
- ft.comments AS fishingTripComments
+ ft.comments AS fishingTripComments,
+ (select sm.alphanumericalValue from SurveyMeasurementImpl sm where sm.fishingTrip.id=ft.id and sm.pmfm.id= :pmfmIdSurveyPart) AS surveyPart,
FROM
ScientificCruiseImpl sc
LEFT OUTER JOIN sc.fishingTrips ft
@@ -130,6 +131,7 @@
AND lh.locationHierarchyPk.location.id = ft.departureLocation.id
]]>
<query-param name="cruiseId" type="java.lang.Integer"/>
+ <query-param name="pmfmIdSurveyPart" type="java.lang.Integer"/>
<query-param name="countryLocationLevelId" type="java.lang.Integer"/>
</query>
@@ -210,21 +212,21 @@
max(g.id) AS gearId,
(select vp_start from VesselPositionImpl vp_start where vp_start.operation.id = o.id and vp_start.dateTime = o.startDateTime) AS startVesselPosition,
(select vp_end from VesselPositionImpl vp_end where vp_end.operation.id = o.id and vp_end.dateTime = o.endDateTime) AS endVesselPosition,
- max(case when (rl.locationLevel.id = :locationLevelIdStrata) then rl.id else null end) AS strataId,
- max(case when (rl.locationLevel.id = :locationLevelIdSubStrata) then rl.id else null end) AS subStrataId,
- max(case when (rl.locationLevel.id = :locationLevelIdLocalite) then rl.id else null end) AS localiteId,
- max(case when (va.isCatchOnOperationVessel = false) then va.id.vessel.code else o.vessel.code end) as vesselCode
- FROM
- FishingOperationImpl o
- INNER JOIN o.gearUseFeatures guf
- LEFT OUTER JOIN guf.gear g
- LEFT OUTER JOIN guf.fishingAreas fa
- LEFT OUTER JOIN fa.regulationLocation fa2rl
- LEFT OUTER JOIN fa2rl.id.location rl
- LEFT OUTER JOIN o.operationVesselAssociations va
- WHERE
- o.id=:fishingOperationId
- GROUP BY o.name
+ max(case when (rl.locationLevel.id = :locationLevelIdStrata) then rl.id else null end) AS strataId,
+ max(case when (rl.locationLevel.id = :locationLevelIdSubStrata) then rl.id else null end) AS subStrataId,
+ max(case when (rl.locationLevel.id = :locationLevelIdLocalite) then rl.id else null end) AS localiteId,
+ max(case when (va.isCatchOnOperationVessel = false) then va.id.vessel.code else o.vessel.code end) as vesselCode
+ FROM
+ FishingOperationImpl o
+ INNER JOIN o.gearUseFeatures guf
+ LEFT OUTER JOIN guf.gear g
+ LEFT OUTER JOIN guf.fishingAreas fa
+ LEFT OUTER JOIN fa.regulationLocation fa2rl
+ LEFT OUTER JOIN fa2rl.id.location rl
+ LEFT OUTER JOIN o.operationVesselAssociations va
+ WHERE
+ o.id=:fishingOperationId
+ GROUP BY o.name
]]>
<query-param name="fishingOperationId" type="java.lang.Integer"/>
<query-param name="locationLevelIdStrata" type="java.lang.Integer"/>
@@ -235,21 +237,21 @@
<query name="fishingOperationRankOrder">
<![CDATA[
SELECT
- count(o1.id)+1 as fishingOperationRankOrder
+ count(o1.id) + 1 as fishingOperationRankOrder
FROM
FishingOperationImpl o1,
FishingOperationImpl o2
WHERE
- o1.fishingTrip.id=o2.fishingTrip.id
- and o1.startDateTime < o2.startDateTime
- and o2.id = :fishingOperationId
+ o1.fishingTrip.id = o2.fishingTrip.id
+ AND o1.startDateTime < o2.startDateTime
+ AND o2.id = :fishingOperationId
]]>
<query-param name="fishingOperationId" type="java.lang.Integer"/>
</query>
- <query name="fishingOperationEnvironment">
+ <query name="fishingOperationVesselUseFeatures">
<![CDATA[
SELECT
vum.pmfm.id as pmfmId,
@@ -265,7 +267,7 @@
<query-param name="fishingOperationId" type="java.lang.Integer"/>
</query>
- <query name="fishingOperationGearShooting">
+ <query name="fishingOperationGearUseFeatures">
<![CDATA[
SELECT
gum.pmfm.id as pmfmId,
Modified: trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties 2013-02-28 09:08:07 UTC (rev 500)
@@ -315,19 +315,22 @@
# radiale
LocationLevelId.RADIALE=305
+# Catégorie Sex
PmfmId.SEX=196
+# Catégorie classe de tri
PmfmId.SIZE_CATEGORY=198
+# Catégorie Age
PmfmId.AGE=1430
-
# Catégorie maturité
PmfmId.MATURITY=174
-
# Catégorie macro-déchet
PmfmId.MARINE_LITTER_TYPE=1421
-
# Classe de taille macro-déchet
PmfmId.MARINE_LITTER_SIZE_CATEGORY=1422
+# TODO Alphanumeric = true A creer (dans les enumerations Allegro)
+PmfmId.SURVEY_PART=-192
+
# TODO A creer (dans les enumerations Allegro)
PmfmId.STATION_NUMBER=1243
# TODO A creer (dans les enumerations Allegro)
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -47,7 +47,7 @@
import static org.junit.Assert.fail;
/**
- * To test {@link CatchBatchPersistenceService} for read operation.
+ * To test {@link BatchPersistenceService} for read operation.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.0
@@ -89,13 +89,24 @@
@Test
public void getAllRootSpeciesBatch(/*String fishingOperationId*/) {
+ //TODO Do me!
}
@Test
public void getAllSpeciesBatchFrequency(/*String speciesBatchId*/) {
+ //TODO Do me!
+ }
+ @Test
+ public void getAllRootBenthosBatch(/*String fishingOperationId*/) {
+ //TODO Do me!
}
+ @Test
+ public void getAllBenthosBatchFrequency(/*String benthosBatchId*/) {
+ //TODO Do me!
+ }
+
public static void assertSpeciesBatch(SpeciesBatch expectedBatch, SpeciesBatch actualBatch, boolean assertIdEquals) {
assertNotNull(actualBatch);
assertNotNull(actualBatch.getId());
@@ -127,7 +138,9 @@
}
}
- public static void assertBatchFrequencies(List<SpeciesBatchFrequency> expectedFrequencies, List<SpeciesBatchFrequency> actualFrequencies, boolean assertIdEquals) {
+ public static void assertBatchFrequencies(List<SpeciesBatchFrequency> expectedFrequencies,
+ List<SpeciesBatchFrequency> actualFrequencies,
+ boolean assertIdEquals) {
assertNotNull(actualFrequencies);
assertEquals(expectedFrequencies.size(), actualFrequencies.size());
@@ -161,11 +174,13 @@
}
}
- public static SpeciesBatch getSpeciesBatch(String fishingOperationId, String speciesBatchId) {
+ public static SpeciesBatch getSpeciesBatch(String fishingOperationId,
+ String speciesBatchId) {
return getSpeciesBatch(speciesBatchId, TuttiPersistenceServiceLocator.getBatchPersistenceService().getAllRootSpeciesBatch(fishingOperationId));
}
- public static SpeciesBatch getSpeciesBatch(String speciesBatchId, List<SpeciesBatch> speciesBatchs) {
+ public static SpeciesBatch getSpeciesBatch(String speciesBatchId,
+ List<SpeciesBatch> speciesBatchs) {
if (speciesBatchs == null) {
return null;
}
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-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -24,27 +24,8 @@
* #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;
@@ -57,587 +38,833 @@
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.Assert;
+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.
- *
+ * To test {@link BatchPersistenceService} 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 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();
+ 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 = service.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;
+ SpeciesBatch esp2Batch;
+ SpeciesBatch frequenciesParentBatch;
+ SpeciesBatch batch;
+ 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);
- // Create batch
- SpeciesBatch createdBatch = service.createSpeciesBatch(batch, parentBatchId);
- assertSpeciesBatch(batch, createdBatch, false);
+ @Test
+ public void createAndSaveBenthosBatchAndFrequencies() {
+ SpeciesBatch esp1Batch;
+ SpeciesBatch esp2Batch;
+ SpeciesBatch frequenciesParentBatch;
+ SpeciesBatch batch;
+ Species taxon1 = species.get(0);
+ Species taxon2 = species.get(1);
- // 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);
+ // -----------------------------------------------------------------------------
+ // 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);
- batch.setId(createdBatch.getId());
- }
+ assertCreateAndReloadBenthosBatch(batch, null);
- protected void assertCreateAndReloadCatchBatch(CatchBatch catchBatch, String fishingOperationId) {
- CatchBatch createdCatchBatch = service.createCatchBatch(catchBatch);
- assertNotNull(createdCatchBatch);
- assertNotNull(createdCatchBatch.getId());
- assertCatchBatch(catchBatch, createdCatchBatch, false);
+ // Save ESP1 batch
+ esp1Batch = batch;
- CatchBatch reloadedCatchBatch = null;
- try {
- reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
- } catch (CatchBatchValidationException e) {
- Assert.fail(e.getMessage());
- }
- assertCatchBatch(createdCatchBatch, reloadedCatchBatch, true);
+ // -----------------------------------------------------------------------------
+ // 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);
- catchBatch.setId(createdCatchBatch.getId());
- }
+ assertCreateAndReloadBenthosBatch(batch, batch.getParentBatch().getId());
- protected void assertSaveAndReloadCatchBatch(CatchBatch catchBatch, String fishingOperationId) {
- CatchBatch savedCatchBatch = service.saveCatchBatch(catchBatch);
- assertNotNull(savedCatchBatch);
- assertNotNull(savedCatchBatch.getId());
- assertCatchBatch(catchBatch, savedCatchBatch, false);
+ // -----------------------------------------------------------------------------
+ // 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);
- CatchBatch reloadedCatchBatch = null;
- try {
- reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
- } catch (CatchBatchValidationException e) {
- Assert.fail(e.getMessage());
- }
- assertCatchBatch(savedCatchBatch, reloadedCatchBatch, true);
- }
+ assertCreateAndReloadBenthosBatch(batch, batch.getParentBatch().getId());
- protected void assertCatchBatch(CatchBatch expectedCatchBatch, CatchBatch actualCatchBatch, boolean assertIdEquals) {
- if (expectedCatchBatch == null) {
- assertNull(actualCatchBatch);
- return;
- }
+ // -----------------------------------------------------------------------------
+ // 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);
- 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());
+ assertCreateAndReloadBenthosBatch(batch, null);
+ esp2Batch = batch;
- 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());
- }
+ // 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);
- 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());
+ assertCreateAndReloadBenthosBatch(batch, batch.getParentBatch().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());
- }
- }
+ // -----------------------------------------------------------------------------
+ // 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);
- protected List<SpeciesBatchFrequency> assertCreateAndReloadSpeciesBatchFrequency(List<SpeciesBatchFrequency> frequencies, String parentBatchId) {
+ // Save and reload, then check
+ SpeciesBatch savedBatch = service.saveBenthosBatch(batch);
+ assertSpeciesBatch(savedBatch, batch, false);
+ SpeciesBatch reloadedBatch = getBenthosBatch(fishingOperationWithEmptyBatch.getId(), savedBatch.getId());
+ assertSpeciesBatch(savedBatch, reloadedBatch, true);
- // Create batch
- List<SpeciesBatchFrequency> createdFrequencies = service.saveSpeciesBatchFrequency(parentBatchId, frequencies);
- assertBatchFrequencies(frequencies, createdFrequencies, false);
+ // Save batch for later
+ frequenciesParentBatch = batch;
- // then reload (for round trip check)
- List<SpeciesBatchFrequency> reloadedFrequencies = service.getAllSpeciesBatchFrequency(parentBatchId);
- assertBatchFrequencies(createdFrequencies, reloadedFrequencies, 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);
- return createdFrequencies;
- }
+ // -----------------------------------------------------------------------------
+ // 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);
- protected void assertBatchFrequencies(List<SpeciesBatchFrequency> expectedFrequencies, List<SpeciesBatchFrequency> actualFrequencies,
- boolean assertIdEquals) {
- assertNotNull(actualFrequencies);
- assertEquals(expectedFrequencies.size(), actualFrequencies.size());
+ // -----------------------------------------------------------------------------
+ // 8. Test batch frequency creation
+ // -----------------------------------------------------------------------------
- // 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);
- }
+ 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());
- // 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());
- }
+ // -----------------------------------------------------------------------------
+ // 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);
+ }
- 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());
- }
- }
+ @Test
+ public void deleteBenthosBatch(/* String id */) {
+ SpeciesBatch esp1Batch;
+ SpeciesBatch batch;
+ Species taxon1 = species.get(0);
- protected SpeciesBatch getSpeciesBatch(String fishingOperationId, String speciesBatchId) {
- return getSpeciesBatch(speciesBatchId, service.getAllRootSpeciesBatch(fishingOperationId));
- }
+ // -----------------------------------------------------------------------------
+ // 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);
+ assertCreateAndReloadBenthosBatch(batch, null);
+ esp1Batch = batch;
- 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;
- }
+ // 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);
+ assertCreateAndReloadBenthosBatch(batch, esp1Batch.getId());
+
+ // Try to remove
+ service.deleteBenthosBatch(esp1Batch.getId());
+
+ // Check if remove
+ try {
+ batch = getBenthosBatch(fishingOperationWithEmptyBatch.getId(), esp1Batch.getId());
+ assertNull(batch);
+ } catch (DataRetrievalFailureException drfe) {
+ assertNotNull(drfe);
+ }
+ }
+
+ protected void assertCreateAndReloadSpeciesBatch(SpeciesBatch batch, String parentBatchId) {
+ batch.setFishingOperation(fishingOperationWithEmptyBatch);
+
+ // 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);
+
+ batch.setId(createdBatch.getId());
+ }
+
+ protected void assertCreateAndReloadBenthosBatch(SpeciesBatch batch, String parentBatchId) {
+ batch.setFishingOperation(fishingOperationWithEmptyBatch);
+
+ // Create batch
+ SpeciesBatch createdBatch = service.createBenthosBatch(batch, parentBatchId);
+ assertSpeciesBatch(batch, createdBatch, false);
+
+ // then reload (for round trip check)
+ SpeciesBatch reloadedBatch = getBenthosBatch(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());
+ }
+
+ 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.setId(createdCatchBatch.getId());
+ }
+
+ 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);
+ }
+
+ 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());
+
+ 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());
+
+ // 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) {
+
+ // 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);
+
+ return createdFrequencies;
+ }
+
+ 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 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());
+ }
+ }
+
+ protected SpeciesBatch getSpeciesBatch(String fishingOperationId, String speciesBatchId) {
+ return getSpeciesBatch(speciesBatchId, service.getAllRootSpeciesBatch(fishingOperationId));
+ }
+
+ protected SpeciesBatch getBenthosBatch(String fishingOperationId, String speciesBatchId) {
+ return getSpeciesBatch(speciesBatchId, service.getAllRootBenthosBatch(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;
+ }
}
Deleted: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,61 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.DatabaseResource;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * To test {@link BenthosBatchPersistenceService} for read operation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-@Ignore
-public class BenthosBatchPersistenceServiceReadTest {
-
- @ClassRule
- public static final DatabaseResource dbResource = DatabaseResource.readDb();
-
- protected BenthosBatchPersistenceService service;
-
- @Before
- public void setUp() throws Exception {
- service = TuttiPersistenceServiceLocator.getBenthosBatchPersistenceService();
- }
-
- @Test
- public void getAllBenthosBatch(/*String fishingOperationId*/) {
-
- }
-
- @Test
- public void getBenthosBatch(/*String id*/) {
-
- }
-}
Deleted: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,65 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.DatabaseResource;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * To test {@link BenthosBatchPersistenceService} for write operation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-@Ignore
-public class BenthosBatchPersistenceServiceWriteTest {
-
- @ClassRule
- public static final DatabaseResource dbResource = DatabaseResource.writeDb();
-
- protected BenthosBatchPersistenceService service;
-
- @Before
- public void setUp() throws Exception {
- service = TuttiPersistenceServiceLocator.getBenthosBatchPersistenceService();
- }
-
- @Test
- public void createBenthosBatch(/*BenthosBatch bean*/) {
-
- }
-
- @Test
- public void saveBenthosBatch(/*BenthosBatch bean*/) {
-
- }
-
- @Test
- public void deleteBenthosBatch(/*String id*/) {
- }
-}
Deleted: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,58 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.DatabaseResource;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * To test {@link CatchBatchPersistenceService} for read operation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-@Ignore
-public class CatchBatchPersistenceServiceReadTest {
-
- @ClassRule
- public static final DatabaseResource dbResource = DatabaseResource.readDb();
-
- protected CatchBatchPersistenceService service;
-
- @Before
- public void setUp() throws Exception {
- service = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
- }
-
- @Test
- public void getCatchBatchFromFishingOperation() throws Exception {
-
- //TODO
- }
-
-}
Deleted: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,204 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.DatabaseResource;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * To test {@link CatchBatchPersistenceService} for write operation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class CatchBatchPersistenceServiceWriteTest {
-
- @ClassRule
- public static final DatabaseResource dbResource = DatabaseResource.writeDb();
-
- protected CatchBatchPersistenceService service;
-
- protected CruisePersistenceService cruiseService;
-
- protected FishingOperationPersistenceService fishingOperationService;
-
- protected ReferentialPersistenceService referentialService;
-
- protected Cruise cruise;
-
- protected FishingOperation fishingOperation;
-
- protected List<Species> species;
-
- @Before
- public void setUp() throws Exception {
- service = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
- cruiseService = TuttiPersistenceServiceLocator.getCruisePersistenceService();
- fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
- referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
-
- 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);
-
- List<FishingOperation> fishingOperations = fishingOperationService.getAllFishingOperation(dbResource.getFixtures().cruiseId());
- assertNotNull(fishingOperations);
- assertTrue(fishingOperations.size() > 0);
- fishingOperation = fishingOperations.get(0);
- fishingOperation = fishingOperationService.getFishingOperation(fishingOperation.getId());
- fishingOperation.setId(null);
- fishingOperation.setCruise(cruise);
- calendar.setTime(new Date());
- calendar.set(Calendar.HOUR_OF_DAY, 1);
- calendar.set(Calendar.MILLISECOND, 0);
- fishingOperation.setGearShootingStartDate(calendar.getTime());
- calendar.setTime(new Date());
- calendar.set(Calendar.HOUR_OF_DAY, 10);
- calendar.set(Calendar.MILLISECOND, 0);
- fishingOperation.setGearShootingEndDate(calendar.getTime());
-
- fishingOperation = fishingOperationService.createFishingOperation(fishingOperation);
- }
-
- @Test
- public void changeSpeciesBatchSpecies() {
- //TODO
- }
-
- @Test
- public void createAndSaveCatchBatch() throws Exception {
- CatchBatch catchBatch;
- CatchBatch createdCatchBatch;
- CatchBatch reloadedCatchBatch;
-
- catchBatch = new CatchBatch();
- catchBatch.setFishingOperation(fishingOperation);
-
- // -----------------------------------------------------------------------------
- // 1. Test with only mandatory properties
- // -----------------------------------------------------------------------------
-
- // Create and reload (test round trip)
- createdCatchBatch = service.createCatchBatch(catchBatch);
- assertNotNull(createdCatchBatch);
- assertNotNull(createdCatchBatch.getId());
-
- reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperation.getId());
- assertNotNull(reloadedCatchBatch);
- assertEquals(createdCatchBatch.getId(), reloadedCatchBatch.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);
-
- // Species
- {
- catchBatch.setSpeciesTotalSortedWeight(12f);
- catchBatch.setSpeciesTotalSampleSortedWeight(8f);
- }
- }
- // Hors Vrac : 10kg
- {
- catchBatch.setCatchTotalUnsortedWeight(10f);
-
- // Species
- {
- catchBatch.setSpeciesTotalUnsortedWeight(10f);
- }
- }
- // Rejet : 15kg
- catchBatch.setCatchTotalRejectedWeight(15f);
-
- // Create and reload (test round trip)
- createdCatchBatch = service.createCatchBatch(catchBatch);
- assertNotNull(createdCatchBatch);
- assertNotNull(createdCatchBatch.getId());
-
- reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperation.getId());
- assertNotNull(reloadedCatchBatch);
- assertEquals(createdCatchBatch.getCatchTotalWeight(), reloadedCatchBatch.getCatchTotalWeight());
- assertEquals(createdCatchBatch.getCatchTotalSortedCarousselWeight(), reloadedCatchBatch.getCatchTotalSortedCarousselWeight());
- assertEquals(createdCatchBatch.getCatchTotalSortedTremisWeight(), reloadedCatchBatch.getCatchTotalSortedTremisWeight());
- assertEquals(createdCatchBatch.getCatchTotalUnsortedWeight(), reloadedCatchBatch.getCatchTotalUnsortedWeight());
-
- assertEquals(createdCatchBatch.getSpeciesTotalSampleSortedWeight(), reloadedCatchBatch.getSpeciesTotalSampleSortedWeight());
- assertEquals(createdCatchBatch.getSpeciesTotalSortedWeight(), reloadedCatchBatch.getSpeciesTotalSortedWeight());
- assertEquals(createdCatchBatch.getSpeciesTotalUnsortedWeight(), reloadedCatchBatch.getSpeciesTotalUnsortedWeight());
-
- // -----------------------------------------------------------------------------
- // 2. Test save after modification
- // -----------------------------------------------------------------------------
- catchBatch.setCatchTotalSortedTremisWeight(null);
- catchBatch.setCatchTotalSortedCarousselWeight(null);
- catchBatch.setSpeciesTotalSortedWeight(null);
- catchBatch.setSpeciesTotalSampleSortedWeight(null);
- catchBatch.setCatchTotalUnsortedWeight(null);
- catchBatch.setSpeciesTotalUnsortedWeight(null);
- CatchBatch savedCatchBatch = service.saveCatchBatch(catchBatch);
- assertNotNull(savedCatchBatch);
- assertNotNull(savedCatchBatch.getId());
-
- reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperation.getId());
- assertNotNull(reloadedCatchBatch);
- assertEquals(createdCatchBatch.getCatchTotalWeight(), reloadedCatchBatch.getCatchTotalWeight());
- assertEquals(createdCatchBatch.getCatchTotalSortedCarousselWeight(), reloadedCatchBatch.getCatchTotalSortedCarousselWeight());
- assertEquals(createdCatchBatch.getCatchTotalSortedTremisWeight(), reloadedCatchBatch.getCatchTotalSortedTremisWeight());
- assertEquals(createdCatchBatch.getCatchTotalUnsortedWeight(), reloadedCatchBatch.getCatchTotalUnsortedWeight());
-
- assertEquals(createdCatchBatch.getSpeciesTotalSampleSortedWeight(), reloadedCatchBatch.getSpeciesTotalSampleSortedWeight());
- assertEquals(createdCatchBatch.getSpeciesTotalSortedWeight(), reloadedCatchBatch.getSpeciesTotalSortedWeight());
- assertEquals(createdCatchBatch.getSpeciesTotalUnsortedWeight(), reloadedCatchBatch.getSpeciesTotalUnsortedWeight());
- }
-
-}
Deleted: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,159 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Maps;
-import fr.ifremer.tutti.persistence.DatabaseResource;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import 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;
-
-/**
- * To test {@link SpeciesBatchPersistenceService} for read operation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-@Ignore
-public class SpeciesBatchPersistenceServiceReadTest {
-
- @ClassRule
- public static final DatabaseResource dbResource = DatabaseResource.readDb();
-
- protected SpeciesBatchPersistenceService service;
-
- @Before
- public void setUp() throws Exception {
- service = TuttiPersistenceServiceLocator.getSpeciesBatchPersistenceService();
- }
-
- @Test
- public void getAllRootSpeciesBatch(/*String fishingOperationId*/) {
- }
-
- @Test
- public void getAllSpeciesBatchFrequency(/*String speciesBatchId*/) {
-
- }
-
- 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());
- }
- }
-
- 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 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());
- }
- }
-
- 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;
- }
-}
Deleted: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,507 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ifremer.tutti.persistence.DatabaseResource;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-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.Ignore;
-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 SpeciesBatchPersistenceService} for write operation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SpeciesBatchPersistenceServiceWriteTest {
-
- @ClassRule
- public static final DatabaseResource dbResource = DatabaseResource.writeDb();
-
- protected SpeciesBatchPersistenceService service;
-
- protected CruisePersistenceService cruiseService;
-
- protected FishingOperationPersistenceService fishingOperationService;
-
- protected CatchBatchPersistenceService catchBatchService;
-
- protected ReferentialPersistenceService referentialService;
-
- protected Cruise cruise;
-
- protected FishingOperation fishingOperation;
-
- protected CatchBatch catchBacth;
-
- protected List<Species> species;
-
- protected Caracteristic sortedUnsortedPMFM;
-
- protected CaracteristicQualitativeValue horsVracQualitativeValue;
-
- protected CaracteristicQualitativeValue vracQualitativeValue;
-
- protected Caracteristic maturityPMFM;
-
- protected CaracteristicQualitativeValue firstMaturityQualitativeValue;
-
- protected Caracteristic sexPMFM;
-
- protected CaracteristicQualitativeValue maleQualitativeValue;
-
- protected CaracteristicQualitativeValue femaleQualitativeValue;
-
- protected CaracteristicQualitativeValue unkQualitativeValue;
-
- protected Caracteristic frequencyPMFM;
-
- protected String speciesBacthId = null;
-
- @Before
- public void setUp() throws Exception {
- service = TuttiPersistenceServiceLocator.getSpeciesBatchPersistenceService();
- cruiseService = TuttiPersistenceServiceLocator.getCruisePersistenceService();
- fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
- referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
- catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
-
- 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);
-
- List<FishingOperation> fishingOperations = fishingOperationService.getAllFishingOperation(dbResource.getFixtures().cruiseId());
- assertNotNull(fishingOperations);
- assertTrue(fishingOperations.size() > 0);
- fishingOperation = fishingOperations.get(0);
- fishingOperation = fishingOperationService.getFishingOperation(fishingOperation.getId());
- fishingOperation.setId(null);
- fishingOperation.setCruise(cruise);
- calendar.setTime(new Date());
- calendar.set(Calendar.HOUR_OF_DAY, 1);
- calendar.set(Calendar.MILLISECOND, 0);
- fishingOperation.setGearShootingStartDate(calendar.getTime());
- calendar.setTime(new Date());
- calendar.set(Calendar.HOUR_OF_DAY, 10);
- calendar.set(Calendar.MILLISECOND, 0);
- fishingOperation.setGearShootingEndDate(calendar.getTime());
-
- fishingOperation = fishingOperationService.createFishingOperation(fishingOperation);
-
- catchBacth = new CatchBatch();
- catchBacth.setFishingOperation(fishingOperation);
- catchBacth = catchBatchService.createCatchBatch(catchBacth);
-
- species = referentialService.getAllSpecies();
- assertNotNull(species);
- assertTrue(species.size() > 2);
-
- 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);
- }
-
- @Test
- public void createSpeciesBatch(/*SpeciesBatch bean, String parentBatchId*/) {
- 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(fishingOperation);
- // TODO TC : add link between Speciesbatch and CatchBatch
- //batch.setCatchBatch(catchBatch);
- batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
- batch.setSampleCategoryValue(vracQualitativeValue);
- batch.setSampleCategoryWeight(5f);
-
- assertCreateAndReloadSpeciesBatch(batch, null);
-
- // 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);
-
- 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);
-
- 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);
- // TODO TC : add link between Speciesbatch and CatchBatch
- //batch.setCatchBatch(catchBatch);
- batch.setSpecies(taxon2);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
- batch.setSampleCategoryValue(vracQualitativeValue);
- batch.setSampleCategoryWeight(7f);
-
- 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);
-
- 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(fishingOperation);
- batch.setNumber(99);
-
- // Save and reload, then check
- SpeciesBatch savedBatch = service.saveSpeciesBatch(batch);
- assertSpeciesBatch(savedBatch, batch, false);
- SpeciesBatch reloadedBatch = getSpeciesBatch(fishingOperation.getId(), savedBatch.getId());
- assertSpeciesBatch(reloadedBatch, savedBatch, true);
-
- // Save batch for later
- frequenciesParentBatch = batch;
-
- // -----------------------------------------------------------------------------
- // 6. Test get all root species
- // -----------------------------------------------------------------------------
- List<SpeciesBatch> rootSpeciesBatch = service.getAllRootSpeciesBatch(fishingOperation.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
- // -----------------------------------------------------------------------------
-
- 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);
- }
- }
- List<SpeciesBatchFrequency> savedFrequencies = service.saveSpeciesBatchFrequency(frequenciesParentBatch.getId(), frequencies);
- assertBatchFrequencies(createdFrequencies, savedFrequencies, true);
- }
-
- @Test
- @Ignore
- public void saveSpeciesBatch(/*SpeciesBatch bean*/) {
-
- }
-
- @Test
- public void deleteSpeciesBatch(/*String id*/) {
- SpeciesBatch esp1Batch;
- SpeciesBatch childBatch = null;
- 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(fishingOperation);
- 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(fishingOperation);
- batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
- batch.setSampleCategoryValue(maleQualitativeValue);
- batch.setSampleCategoryWeight(2f);
- assertCreateAndReloadSpeciesBatch(batch, esp1Batch.getId());
-
- // Try to remove
- service.deleteSpeciesBatch(esp1Batch.getId());
-
- // Check if remove
- try {
- batch = getSpeciesBatch(fishingOperation.getId(), esp1Batch.getId());
- assertNull(batch);
- } catch (DataRetrievalFailureException drfe) {
- assertNotNull(drfe);
- }
- }
-
- @Test
- @Ignore
- public void deleteSpeciesSubBatch(/*String id*/) {
- // Idem deleteSpeciesBatch
- }
-
- protected void assertCreateAndReloadSpeciesBatch(SpeciesBatch batch, String parentBatchId) {
- batch.setFishingOperation(fishingOperation);
-
- // Create batch
- SpeciesBatch createdBatch = service.createSpeciesBatch(batch, parentBatchId);
- assertSpeciesBatch(batch, createdBatch, false);
-
- // then reload (for round trip check)
- SpeciesBatch reloadedBatch = getSpeciesBatch(fishingOperation.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());
- }
-
- 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());
- }
- }
-
- protected List<SpeciesBatchFrequency> assertCreateAndReloadSpeciesBatchFrequency(List<SpeciesBatchFrequency> frequencies, String parentBatchId) {
-
- // 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);
-
- return createdFrequencies;
- }
-
- 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 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());
- }
- }
-
- 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;
- }
-}
Modified: 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 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,23 +1,29 @@
package fr.ifremer.tutti.persistence.service.batch;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
-import 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.Ignore;
-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;
@@ -25,98 +31,109 @@
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;
+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.Ignore;
+import org.junit.Test;
+import java.util.List;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
@Ignore
public class CatchBatchValidatorReadTest {
- @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 ReferentialPersistenceService referentialService;
- protected ReferentialPersistenceService referentialService;
-
- Mockery context ;
-
+ 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();
- }
+ @Before
+ public void setUp() throws Exception {
+ context = new JUnit4Mockery();
+ catchBatchExtendDaoMock = context.mock(CatchBatchExtendDao.class);
+ catchBatchDao = ServiceLocator.instance().getService("catchBatchDao", CatchBatchExtendDao.class);
- @Test
- @Ignore
- public void getInvalidCatchBatch() {
+ service = TuttiPersistenceServiceLocator.getBatchPersistenceService();
+ cruiseService = TuttiPersistenceServiceLocator.getCruisePersistenceService();
+ fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
+ referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
- // Full load operation
- try {
- CatchBatch catchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
- Assert.fail("Historical batch tree must not be valid");
- } catch (CatchBatchValidationException e) {
- assertNotNull(e);
- }
- }
-
- @Test
- @Ignore
- public void getInvalidCatchBatchButTryRepair() throws CatchBatchValidationException {
+ List<FishingOperation> fishingOperations = fishingOperationService.getAllFishingOperation(dbResource.getFixtures().cruiseId());
+ assertNotNull(fishingOperations);
+ assertTrue(fishingOperations.size() > 0);
+ fishingOperationId = fishingOperations.get(0).getId();
+ }
- // Replace catchBatchDao with a mock :
- //service.setCatchBatchDao(catchBatchExtendDaoMock);
-
- context.checking(new Expectations() {{
- // Assert update() is call once
+ @Test
+ @Ignore
+ 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
+ @Ignore
+ 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);
- }
- });
- }});
+ 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);
- }
+ CatchBatch catchBatch;
+ 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-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeHelperTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeHelperTest.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeHelperTest.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -188,10 +188,10 @@
getLastUpdateDate(TuttiTable.GEAR, internalDb, getSqlDate(2012, 12, 18));
getLastUpdateDate(TuttiTable.LOCATION_CLASSIFICATION, internalDb, getSqlDate(2010, 10, 26));
getLastUpdateDate(TuttiTable.LOCATION_LEVEL, internalDb, getSqlDate(2013, 1, 28));
- getLastUpdateDate(TuttiTable.LOCATION, internalDb, getSqlDate(2013, 1, 29));
+ getLastUpdateDate(TuttiTable.LOCATION, internalDb, getSqlDate(2013, 2, 27));
getLastUpdateDate(TuttiTable.TAXONOMIC_LEVEL, internalDb, getSqlDate(2012, 4, 18));
getLastUpdateDate(TuttiTable.REFERENCE_TAXON, internalDb, getSqlDate(2013, 1, 21));
- getLastUpdateDate(TuttiTable.TAXON_NAME, internalDb, getSqlDate(2013, 1, 21));
+ getLastUpdateDate(TuttiTable.TAXON_NAME, internalDb, getSqlDate(2013, 2, 26));
getLastUpdateDate(TuttiTable.TAXON_GROUP_TYPE, internalDb, getSqlDate(2012, 5, 24));
getLastUpdateDate(TuttiTable.TAXON_GROUP, internalDb, getSqlDate(2013, 1, 16));
getLastUpdateDate(TuttiTable.ROUND_WEIGHT_CONVERSION, internalDb, getSqlDate(2012, 10, 4));
Added: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/InvalidBatchModelException.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/InvalidBatchModelException.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/InvalidBatchModelException.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -0,0 +1,48 @@
+package fr.ifremer.tutti.service;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * Exception when batch model is not compatible with Tutti.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0.2
+ */
+public class InvalidBatchModelException extends TuttiBusinessException {
+
+ private static final long serialVersionUID = 1L;
+
+ public InvalidBatchModelException(String message) {
+ super(message);
+ }
+
+ public InvalidBatchModelException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidBatchModelException(Throwable cause) {
+ super(cause);
+ }
+}
Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/InvalidBatchModelException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -24,11 +24,11 @@
* #L%
*/
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.TuttiPersistence;
import fr.ifremer.tutti.persistence.TuttiPersistenceNoDbImpl;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
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;
@@ -407,8 +407,14 @@
//------------------------------------------------------------------------//
@Override
- public CatchBatch getCatchBatchFromFishingOperation(String id) {
- return driver.getCatchBatchFromFishingOperation(id);
+ public CatchBatch getCatchBatchFromFishingOperation(String id,
+ boolean canRepair) throws InvalidBatchModelException {
+ try {
+ return driver.getCatchBatchFromFishingOperation(id, canRepair);
+ } catch (CatchBatchValidationException e) {
+ throw new InvalidBatchModelException(
+ "L'arbre d'échantillonage n'est pas compatible avec Tutti", e);
+ }
}
@Override
@@ -425,7 +431,6 @@
//-- Species Batch methods --//
//------------------------------------------------------------------------//
-
@Override
public List<SpeciesBatch> getAllRootSpeciesBatch(String fishingOperationId) {
return driver.getAllRootSpeciesBatch(fishingOperationId);
@@ -473,22 +478,18 @@
//------------------------------------------------------------------------//
@Override
- public List<BenthosBatch> getAllBenthosBatch(String fishingOperationId) {
- return driver.getAllBenthosBatch(fishingOperationId);
+ public List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId) {
+ return driver.getAllRootBenthosBatch(fishingOperationId);
}
@Override
- public BenthosBatch getBenthosBatch(String id) {
- return driver.getBenthosBatch(id);
+ public SpeciesBatch createBenthosBatch(SpeciesBatch bean,
+ String parentBatchId) {
+ return driver.createBenthosBatch(bean, parentBatchId);
}
@Override
- public BenthosBatch createBenthosBatch(BenthosBatch bean) {
- return driver.createBenthosBatch(bean);
- }
-
- @Override
- public BenthosBatch saveBenthosBatch(BenthosBatch bean) {
+ public SpeciesBatch saveBenthosBatch(SpeciesBatch bean) {
return driver.saveBenthosBatch(bean);
}
@@ -497,6 +498,27 @@
driver.deleteBenthosBatch(id);
}
+ @Override
+ public void deleteBenthosSubBatch(String id) {
+ driver.deleteBenthosSubBatch(id);
+ }
+
+ @Override
+ public void changeBenthosBatchSpecies(String batchId, Species species) {
+ driver.changeBenthosBatchSpecies(batchId, species);
+ }
+
+ @Override
+ public List<SpeciesBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) {
+ return driver.getAllBenthosBatchFrequency(benthosBatchId);
+ }
+
+ @Override
+ public List<SpeciesBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId,
+ List<SpeciesBatchFrequency> frequencies) {
+ return driver.saveBenthosBatchFrequency(benthosBatchId, frequencies);
+ }
+
//------------------------------------------------------------------------//
//-- Plancton Batch methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties 2013-02-28 09:08:07 UTC (rev 500)
@@ -39,7 +39,7 @@
# tutti levels
log4j.logger.fr.ifremer=INFO
log4j.logger.fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler=WARN
-log4j.logger.fr.ifremer.tutti.ui.swing.util.table=WARN
+log4j.logger.fr.ifremer.tutti.ui.swing.util.table=INFO
log4j.logger.org.nuiton.util=WARN
log4j.logger.org.nuiton.util.ApplicationConfig=INFO
log4j.logger.org.nuiton.util.ApplicationConfigHelper=INFO
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -25,9 +25,10 @@
*/
import fr.ifremer.tutti.persistence.entities.data.Attachment;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import org.apache.commons.collections.CollectionUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -39,7 +40,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, BenthosBatchRowModel> {
+public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<SpeciesBatch, BenthosBatchRowModel> {
private static final long serialVersionUID = 1L;
@@ -57,6 +58,15 @@
public static final String PROPERTY_ATTACHMENTS = "attachments";
+ public static final String PROPERTY_PARENT_BATCH = "parentBatch";
+
+ public static final String PROPERTY_CHILD_BATCH = "childBatch";
+
+ public static final String PROPERTY_BATCH_LEAF = "batchLeaf";
+
+ public static final String PROPERTY_BATCH_ROOT = "batchRoot";
+
+
/**
* Species observed.
*
@@ -107,19 +117,35 @@
*/
protected List<Attachment> attachments;
- protected static final Binder<BenthosBatch, BenthosBatchRowModel> fromBeanBinder =
- BinderFactory.newBinder(BenthosBatch.class,
+ /**
+ * Parent of this batch (can be null if batch is root).
+ *
+ * @see #isBatchRoot()
+ * @since 0.3
+ */
+ protected BenthosBatchRowModel parentBatch;
+
+ /**
+ * List of child batches (can be null or empty if batch is a leaf).
+ *
+ * @see #isBatchLeaf()
+ * @since 0.3
+ */
+ protected List<BenthosBatchRowModel> childBatch;
+
+ protected static final Binder<SpeciesBatch, BenthosBatchRowModel> fromBeanBinder =
+ BinderFactory.newBinder(SpeciesBatch.class,
BenthosBatchRowModel.class);
- protected static final Binder<BenthosBatchRowModel, BenthosBatch> toBeanBinder =
+ protected static final Binder<BenthosBatchRowModel, SpeciesBatch> toBeanBinder =
BinderFactory.newBinder(BenthosBatchRowModel.class,
- BenthosBatch.class);
+ SpeciesBatch.class);
public BenthosBatchRowModel() {
- super(BenthosBatch.class, fromBeanBinder, toBeanBinder);
+ super(SpeciesBatch.class, fromBeanBinder, toBeanBinder);
}
- public BenthosBatchRowModel(BenthosBatch aBatch) {
+ public BenthosBatchRowModel(SpeciesBatch aBatch) {
this();
fromBean(aBatch);
}
@@ -164,6 +190,40 @@
firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
}
+ //------------------------------------------------------------------------//
+ //-- Navigation properties --//
+ //------------------------------------------------------------------------//
+
+ public BenthosBatchRowModel getParentBatch() {
+ return parentBatch;
+ }
+
+ public void setParentBatch(BenthosBatchRowModel parentBatch) {
+ Object oldValue = getParentBatch();
+ this.parentBatch = parentBatch;
+ firePropertyChange(PROPERTY_PARENT_BATCH, oldValue, parentBatch);
+ firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot());
+ }
+
+ public List<BenthosBatchRowModel> getChildBatch() {
+ return childBatch;
+ }
+
+ public void setChildBatch(List<BenthosBatchRowModel> childBatch) {
+ this.childBatch = childBatch;
+ // force to propagate child changes
+ firePropertyChange(PROPERTY_CHILD_BATCH, null, childBatch);
+ firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf());
+ }
+
+ public boolean isBatchLeaf() {
+ return CollectionUtils.isEmpty(childBatch);
+ }
+
+ public boolean isBatchRoot() {
+ return parentBatch == null;
+ }
+
public Integer getNumber() {
return number;
}
@@ -194,4 +254,5 @@
firePropertyChange(PROPERTY_ATTACHMENTS, oldValue, attachments);
}
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -27,8 +27,8 @@
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.TuttiUI;
@@ -93,9 +93,9 @@
rows = Lists.newArrayList();
if (!TuttiEntities.isNew(bean)) {
- List<BenthosBatch> catches =
- persistenceService.getAllBenthosBatch(bean.getId());
- for (BenthosBatch aBatch : catches) {
+ List<SpeciesBatch> catches =
+ persistenceService.getAllRootBenthosBatch(bean.getId());
+ for (SpeciesBatch aBatch : catches) {
BenthosBatchRowModel entry =
new BenthosBatchRowModel(aBatch);
rows.add(entry);
@@ -157,7 +157,7 @@
// row is not valid can not save it
- BenthosBatch catchBean = row.toBean();
+ SpeciesBatch catchBean = row.toBean();
if (!TuttiEntities.isNew(catchBean)) {
@@ -304,7 +304,7 @@
protected void saveRow(BenthosBatchRowModel row) {
- BenthosBatch catchBean = row.toBean();
+ SpeciesBatch catchBean = row.toBean();
FishingOperation fishingOperation = getModel().getFishingOperation();
catchBean.setFishingOperation(fishingOperation);
@@ -314,7 +314,18 @@
if (TuttiEntities.isNew(catchBean)) {
- catchBean = persistenceService.createBenthosBatch(catchBean);
+ BenthosBatchRowModel batchParent = row.getParentBatch();
+ String parentBatchId = null;
+
+ if (batchParent != null) {
+ parentBatchId = batchParent.getId();
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Persist new benthos batch with parentId: " +
+ parentBatchId);
+ }
+ catchBean = persistenceService.createBenthosBatch(catchBean, parentBatchId);
row.setId(catchBean.getId());
} else {
persistenceService.saveBenthosBatch(catchBean);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java 2013-02-28 09:08:07 UTC (rev 500)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.util.table;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import org.jdesktop.swingx.decorator.ComponentAdapter;
import org.jdesktop.swingx.decorator.HighlightPredicate;
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-28 09:03:00 UTC (rev 499)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-28 09:08:07 UTC (rev 500)
@@ -543,9 +543,9 @@
tutti.validator.error.fishingOperation.trawlDistance.tooLong=La distance du trait dépasse 3 milles marin (5556 m), merci de vérifier les coordonnées
tutti.validator.error.fishingOperation.trawlNetNumber.required=Le numéro de poche est obligatoire
tutti.validator.error.fishingOperation.vessel.required=Le navire est obligatoire
+tutti.validator.error.program.comment.required=Le commentaire de la série est obligatoire
tutti.validator.error.program.existingKey=Le couple nom/zone existe déjà
tutti.validator.error.program.name.required=Le nom de la série est obligatoire
-tutti.validator.error.program.comment.required=Le commentaire de la série est obligatoire
tutti.validator.error.program.zone.required=La zone de la série est obligatoire
tutti.validator.error.protocol.name.alreadyUsed=Le nom du protocol est déjà utilisé
tutti.validator.error.protocol.name.required=Le nom du protocol est obligatoire
1
0
r499 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation/catches/species util/table
by tchemit@users.forge.codelutin.com 28 Feb '13
by tchemit@users.forge.codelutin.com 28 Feb '13
28 Feb '13
Author: tchemit
Date: 2013-02-28 10:03:00 +0100 (Thu, 28 Feb 2013)
New Revision: 499
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/499
Log:
refs #2025: change highlighter (for tests only)
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-28 08:57:24 UTC (rev 498)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-28 09:03:00 UTC (rev 499)
@@ -83,7 +83,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
-import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
@@ -392,7 +391,7 @@
List<Caracteristic> lengthCaracterics;
- TuttiProtocol protocol = null;
+ TuttiProtocol protocol;
if (context.isProtocolFilled()) {
@@ -438,7 +437,7 @@
List<SampleCategoryType> samplingOrder;
- List<Species> speciesUniverse =
+ List<Species> speciesUniverse =
SPECIES_REFERENT_CONTEXT_ENTRY.getContextValue(ui);
List<Species> allSpecies;
@@ -463,7 +462,7 @@
SampleCategoryType.sex,
SampleCategoryType.maturity,
SampleCategoryType.age);
-
+
// fill available species from protocol
allSpecies = Lists.newArrayList();
@@ -476,7 +475,7 @@
String taxonId = String.valueOf(protocolSpecy.getSpeciesReferenceTaxonId());
Species species = map.get(taxonId);
allSpecies.add(species);
-
+
speciesSampleCategories.put(species, SampleCategoryType.sortedUnsorted);
speciesSampleCategories.put(species, SampleCategoryType.size);
speciesSampleCategories.put(species, SampleCategoryType.sex);
@@ -484,7 +483,7 @@
speciesSampleCategories.put(species, SampleCategoryType.age);
}
}
-
+
} else {
// no protocol, use default values
@@ -628,7 +627,7 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
-
+
Color toConfirmColor = getConfig().getColorRowToConfirm();
// paint the cell in orange if the row is to confirm
Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
@@ -636,7 +635,7 @@
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
int rowIndex = adapter.convertRowIndexToModel(adapter.row);
- SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex);
+ SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
return row.getSpeciesToConfirm();
}
@@ -651,7 +650,7 @@
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
int rowIndex = adapter.convertRowIndexToModel(adapter.row);
- SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex);
+ SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
return row.getSpeciesToConfirm() && !adapter.isEditable();
}
@@ -674,7 +673,7 @@
getTable().setRowFilter(filter);
}
});
-
+
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-02-28 08:57:24 UTC (rev 498)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-02-28 09:03:00 UTC (rev 499)
@@ -291,22 +291,26 @@
// by default do not authorize to change column orders
table.getTableHeader().setReorderingAllowed(false);
- // paint in a special color read only cells
+ // paint in a special color for read only cells
Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
HighlightPredicate.READ_ONLY, getConfig().getColorRowReadOnly());
table.addHighlighter(readOnlyHighlighter);
+ // paint in a special color for comment cell (with not null value)
Color cellWithValueColor = getConfig().getColorCellWithValue();
Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
new HighlightPredicate.AndHighlightPredicate(
- new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.COMMENT),
+ new MyIdentifierHighlightPredicate(SpeciesBatchTableModel.COMMENT),
+ // for not null value
new HighlightPredicate.NotHighlightPredicate(new HighlightPredicate.EqualsHighlightPredicate())
), cellWithValueColor);
table.addHighlighter(commentHighlighter);
+ // paint in a special color for attachment cell (with not null value)
Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
new HighlightPredicate.AndHighlightPredicate(
- new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENTS),
+ new MyIdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENTS),
+ // for not null value
new HighlightPredicate.NotHighlightPredicate(new HighlightPredicate.EqualsHighlightPredicate())
), cellWithValueColor);
table.addHighlighter(attachmentHighlighter);
@@ -319,8 +323,7 @@
boolean result = false;
if (adapter.isEditable()) {
- int rowIndex = adapter.convertRowIndexToModel(adapter.row);
- R row = getTableModel().getEntry(rowIndex);
+ R row = getTableModel().getEntry(adapter.row);
result = !row.isValid();
}
return result;
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java 2013-02-28 09:03:00 UTC (rev 499)
@@ -0,0 +1,53 @@
+package fr.ifremer.tutti.ui.swing.util.table;
+
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+
+import java.awt.Component;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * While using the swingX HighlightPredicate.IdentifierHighlightPredicate, it does not works very well with
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0.2
+ */
+public class MyIdentifierHighlightPredicate implements HighlightPredicate {
+ protected List<Object> columnList;
+
+ /**
+ * Instantiates a predicate which returns true for the
+ * given column identifiers.
+ *
+ * @param columns the identitiers of the columns to highlight.
+ */
+ public MyIdentifierHighlightPredicate(Object... columns) {
+ columnList = new ArrayList<Object>();
+ Collections.addAll(columnList, columns);
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p/>
+ * This implementation returns true if the adapter's column
+ * is contained in this predicates list.
+ */
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+// int modelIndex = adapter.convertColumnIndexToModel(adapter.column);
+ Object identifier = adapter.getColumnIdentifierAt(adapter.column);
+ return identifier != null && columnList.contains(identifier);
+ }
+
+ /** @return the identifiers */
+ public Object[] getIdentifiers() {
+ if (columnList.isEmpty()) {
+ return EMPTY_OBJECT_ARRAY;
+ } else {
+ return columnList.toArray(new Object[0]);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
r498 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency
by tchemit@users.forge.codelutin.com 28 Feb '13
by tchemit@users.forge.codelutin.com 28 Feb '13
28 Feb '13
Author: tchemit
Date: 2013-02-28 09:57:24 +0100 (Thu, 28 Feb 2013)
New Revision: 498
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/498
Log:
refs #2025 (compute column each time opening ui)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-02-28 08:56:29 UTC (rev 497)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-02-28 08:57:24 UTC (rev 498)
@@ -217,10 +217,11 @@
boolean isSelected,
int row,
int column) {
- if (tableModel == null) {
- tableModel = (SpeciesBatchTableModel) table.getModel();
- this.table = table;
- columnIdentifier = tableModel.getPropertyName(column);
+ tableModel = (SpeciesBatchTableModel) table.getModel();
+ this.table = table;
+ columnIdentifier = tableModel.getPropertyName(column);
+ if (log.isInfoEnabled()) {
+ log.info("Set columnIdentifier (" + column + ") :: " + columnIdentifier.getPropertyName());
}
TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value;
component.setComputedOrNotText(data);
1
0
r497 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise
by tchemit@users.forge.codelutin.com 28 Feb '13
by tchemit@users.forge.codelutin.com 28 Feb '13
28 Feb '13
Author: tchemit
Date: 2013-02-28 09:56:29 +0100 (Thu, 28 Feb 2013)
New Revision: 497
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/497
Log:
fix imports :(
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-02-28 08:55:41 UTC (rev 496)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-02-28 08:56:29 UTC (rev 497)
@@ -45,8 +45,6 @@
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import static org.nuiton.i18n.I18n._;
1
0