Wao-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
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
April 2014
- 5 participants
- 162 discussions
See <http://ci.codelutin.com/jenkins/job/wao-ci/120/changes>
Changes:
[bleny] refs #4487 contact creation from elligible boat
------------------------------------------
[...truncated 123 lines...]
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.FleetImpl], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.UserProfileImpl], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.TargetSpeciesDCFImpl], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.ObsDebCodeImpl], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.SampleRowLogImpl], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.NewsImpl], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.WaoUserTopiaDao], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.TerrestrialDivisionTopiaDao], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.SampleRowTopiaDao], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.BoatTopiaDao], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.ContactTopiaDao], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.TerrestrialLocationTopiaDao], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.ElligibleBoatTopiaDao], already found in class-path.
INFO [pool-1-thread-1 for channel] (ObjectModelTransformerToJava.java:998) isInClassPath - Will not generate [fr.ifremer.wao.entity.SampleMonthTopiaDao], already found in class-path.
[INFO] Add compile source root : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO] Add resource root :Resource {targetPath: null, filtering: false, FileSet {directory: <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…,> PatternSet [includes: {}, excludes: {**/*.java}]}}
[INFO]
[INFO] --- i18n-maven-plugin:3.0:parserJava (parseOthersAndGen) @ wao-persistence ---
[INFO] start entry basedir:<http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…,> includes:[**/*.java]
[INFO] 145 file(s) to process (among 145 files)
[INFO] start entry basedir:<http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…,> includes:[**/*.java]
[INFO] 64 file(s) to process (among 64 files)
[INFO] Parsing is done. [treated file(s) : 13/209](total time:6.623s) ( ~ 31.691ms / file)
[INFO]
[INFO] >>> i18n-maven-plugin:3.0:gen (parseOthersAndGen) @ wao-persistence >>>
[INFO]
[INFO] --- i18n-maven-plugin:3.0:get (get) @ wao-persistence ---
[INFO] config - basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] import getter java.getter in 351790ns
[INFO] Copying wao-persistence.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO] Copying wao-persistence.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO]
[INFO] <<< i18n-maven-plugin:3.0:gen (parseOthersAndGen) @ wao-persistence <<<
[INFO]
[INFO] --- i18n-maven-plugin:3.0:gen (parseOthersAndGen) @ wao-persistence ---
[INFO] config - src basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>
[INFO] config - out basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] prepare bundle for locale fr_FR
[INFO] merge bundle fr_FR to out
[WARNING] bundle fr_FR contains 1/144 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO] copy bundle fr_FR to src
[INFO] prepare bundle for locale en_GB
[INFO] merge bundle en_GB to out
[WARNING] bundle en_GB contains 2/145 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO] copy bundle en_GB to src
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ wao-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 6 resources
[INFO] Copying 28 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ wao-persistence ---
[INFO] Compiling 209 source files to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[397,48] formatDate(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[400,70] formatDate(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[401,70] formatDate(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[43,82] formatMonth(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[43,47] formatMonth(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[49,90] formatMonth(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ wao-persistence ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ wao-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ wao-persistence ---
[INFO] Compiling 1 source file to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ wao-persistence ---
[INFO] Surefire report directory: <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running fr.ifremer.wao.entity.SampleRowLogImplTest
2014/04/08 12:56:56 DEBUG (SampleRowLogImplTest.java:78) testNewSampleRowLog Le nombre d'observateurs est de 0
Le durée moyenne d'une marée est de 0.0
La ligne est sur la période du 03/2011 au 06/2011
Le métier de la ligne est
2014/04/08 12:56:56 DEBUG (SampleRowLogImplTest.java:94) testCompareSampleRowToItself
2014/04/08 12:56:56 DEBUG (SampleRowLogImplTest.java:118) testModifySampleRow La durée moyenne d'une marée est passé de 0.0 jours à 1.0
La ligne est désormais associée au programme programName
La date de fin est passée de 06/2011 à 07/2011
Les zones de pêches suivantes ont été ajoutées : null - null - IV
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.156 sec - in fr.ifremer.wao.entity.SampleRowLogImplTest
Results :
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ wao-persistence ---
[INFO] Building jar: <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ wao-persistence ---
[JENKINS] Archiving disabled
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Wao :: Services 4.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ wao-services ---
[INFO] Deleting <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ wao-services ---
[INFO]
[INFO] --- i18n-maven-plugin:3.0:parserJava (parseOthersAndGen) @ wao-services ---
[INFO] start entry basedir:<http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…,> includes:[**/*.java]
[INFO] 103 file(s) to process (among 103 files)
[INFO] Parsing is done. [treated file(s) : 29/103](total time:216.859ms) ( ~ 2.105ms / file)
[INFO]
[INFO] >>> i18n-maven-plugin:3.0:gen (parseOthersAndGen) @ wao-services >>>
[INFO]
[INFO] --- i18n-maven-plugin:3.0:get (get) @ wao-services ---
[INFO] config - basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/gen…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] import getter java.getter in 211656ns
[INFO] Copying wao-services.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/gen…>
[INFO] Copying wao-services.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/gen…>
[INFO]
[INFO] <<< i18n-maven-plugin:3.0:gen (parseOthersAndGen) @ wao-services <<<
[INFO]
[INFO] --- i18n-maven-plugin:3.0:gen (parseOthersAndGen) @ wao-services ---
[INFO] config - src basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/r…>
[INFO] config - out basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/gen…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] prepare bundle for locale fr_FR
[INFO] merge bundle fr_FR to out
[WARNING] bundle fr_FR contains 2/83 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO] copy bundle fr_FR to src
[INFO] prepare bundle for locale en_GB
[INFO] merge bundle en_GB to out
[WARNING] bundle en_GB contains 1/83 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO] copy bundle en_GB to src
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ wao-services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ wao-services ---
[INFO] Compiling 103 source files to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/cla…>
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…>:[173,46] findByEntityClassFqn(java.lang.String) in fr.ifremer.wao.entity.GeneratedReferentialMetaTopiaDao has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…>:[185,68] TOPIA_ID in org.nuiton.topia.persistence.TopiaEntity has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…>: Recompile with -Xlint:unchecked for details.
[INFO] 4 warnings
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…>:[786,18] cannot find symbol
symbol: class NullSampleMonthException
location: class fr.ifremer.wao.services.service.ObsMerContactsService
[INFO] 1 error
[INFO] -------------------------------------------------------------
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Wao ............................................... SUCCESS [ 2.515 s]
[INFO] Wao :: Persistence ................................ SUCCESS [ 17.144 s]
[INFO] Wao :: Services ................................... FAILURE [ 1.170 s]
[INFO] Wao :: Web ........................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.882 s
[INFO] Finished at: 2014-04-08T12:56:58+01:00
[INFO] Final Memory: 48M/823M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project wao-services: Compilation failure
[ERROR] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…>:[786,18] cannot find symbol
[ERROR] symbol: class NullSampleMonthException
[ERROR] location: class fr.ifremer.wao.services.service.ObsMerContactsService
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project wao-services: Compilation failure
<http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…>:[786,18] cannot find symbol
symbol: class NullSampleMonthException
location: class fr.ifremer.wao.services.service.ObsMerContactsService
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
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:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
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:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
<http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…>:[786,18] cannot find symbol
symbol: class NullSampleMonthException
location: class fr.ifremer.wao.services.service.ObsMerContactsService
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 30 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :wao-services
Sending e-mails to: wao-commits(a)list.forge.codelutin.com leny(a)codelutin.com
channel stopped
1
2
Build failed in Jenkins: wao-ci » Wao :: Services #120
by admin+ci-codelutin.com@codelutin.com 08 Apr '14
by admin+ci-codelutin.com@codelutin.com 08 Apr '14
08 Apr '14
See <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/120/chan…>
Changes:
[bleny] refs #4487 contact creation from elligible boat
------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Wao :: Services 4.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ wao-services ---
[INFO] Deleting <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/target>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ wao-services ---
[INFO]
[INFO] --- i18n-maven-plugin:3.0:parserJava (parseOthersAndGen) @ wao-services ---
[INFO] start entry basedir:<http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…,> includes:[**/*.java]
[INFO] 103 file(s) to process (among 103 files)
[INFO] Parsing is done. [treated file(s) : 29/103](total time:216.859ms) ( ~ 2.105ms / file)
[INFO]
[INFO] >>> i18n-maven-plugin:3.0:gen (parseOthersAndGen) @ wao-services >>>
[INFO]
[INFO] --- i18n-maven-plugin:3.0:get (get) @ wao-services ---
[INFO] config - basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] import getter java.getter in 211656ns
[INFO] Copying wao-services.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO] Copying wao-services.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO]
[INFO] <<< i18n-maven-plugin:3.0:gen (parseOthersAndGen) @ wao-services <<<
[INFO]
[INFO] --- i18n-maven-plugin:3.0:gen (parseOthersAndGen) @ wao-services ---
[INFO] config - src basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…>
[INFO] config - out basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] prepare bundle for locale fr_FR
[INFO] merge bundle fr_FR to out
[WARNING] bundle fr_FR contains 2/83 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO] copy bundle fr_FR to src
[INFO] prepare bundle for locale en_GB
[INFO] merge bundle en_GB to out
[WARNING] bundle en_GB contains 1/83 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO] copy bundle en_GB to src
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ wao-services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ wao-services ---
[INFO] Compiling 103 source files to <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…>:[173,46] findByEntityClassFqn(java.lang.String) in fr.ifremer.wao.entity.GeneratedReferentialMetaTopiaDao has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…>:[185,68] TOPIA_ID in org.nuiton.topia.persistence.TopiaEntity has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…>: Recompile with -Xlint:unchecked for details.
[INFO] 4 warnings
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…>:[786,18] cannot find symbol
symbol: class NullSampleMonthException
location: class fr.ifremer.wao.services.service.ObsMerContactsService
[INFO] 1 error
[INFO] -------------------------------------------------------------
[JENKINS] Archiving disabled
1
2
r1865 - trunk/wao-services/src/main/java/fr/ifremer/wao/services/service
by tchemit@users.forge.codelutin.com 08 Apr '14
by tchemit@users.forge.codelutin.com 08 Apr '14
08 Apr '14
Author: tchemit
Date: 2014-04-08 14:03:05 +0200 (Tue, 08 Apr 2014)
New Revision: 1865
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1865
Log:
fix build
Modified:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-08 11:44:47 UTC (rev 1864)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-08 12:03:05 UTC (rev 1865)
@@ -804,7 +804,7 @@
logMessage = "no similar contact found";
} else {
logMessage = "similar contact found to pre-fill values of contact : "
- + similarContact.getTopiaId() + " boat = " + similarContact.getBoat().getName();
+ + similarContact.getTopiaId() + " boat = " + similarContact.getBoat().getName();
}
log.debug(logMessage);
}
@@ -819,14 +819,7 @@
}
}
- try {
- save0(updateContactCommand);
- } catch (NullSampleMonthException e) {
- if (log.isErrorEnabled()) {
- log.error("should never occur", e);
- }
- throw new WaoTechnicalException(e);
- }
+ save0(updateContactCommand);
commit();
1
0
08 Apr '14
Author: tchemit
Date: 2014-04-08 13:44:47 +0200 (Tue, 08 Apr 2014)
New Revision: 1864
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1864
Log:
refs #4487 fix filter query, import of contact, test import
Added:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateBeforeObservationEndDateException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/LocalizedToStringParserFormatter.java
Removed:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java
Modified:
trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/BoatImportExportModel.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactStateMotivesImportModel.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/FishingZoneImportModel.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerContactImportExportModel.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ObservedDataControlParserFormatter.java
trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties
trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties
trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java
trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java
trunk/wao-services/src/test/resources/import/contacts.csv
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java
trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties
Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java
===================================================================
--- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -41,14 +41,16 @@
private static final Log log = LogFactory.getLog(ContactTopiaDao.class);
- public List<Contact> findAll(ContactsFilter filter) {
+ public List<Contact> findAll(ContactsFilter filter, boolean sort) {
HqlAndParametersBuilder<Contact> query = toSampleRowHqlAndParametersBuilder(filter);
- if (filter.isSortedByBoardingDate()) {
- query.setOrderByArguments(Contact.PROPERTY_OBSERVATION_BEGIN_DATE);
- } else {
- query.setOrderByArguments(Contact.PROPERTY_CREATION_DATE);
+ if (sort) {
+ if (filter.isSortedByBoardingDate()) {
+ query.setOrderByArguments(Contact.PROPERTY_OBSERVATION_BEGIN_DATE);
+ } else {
+ query.setOrderByArguments(Contact.PROPERTY_CREATION_DATE);
+ }
}
List<Contact> all = findAll(query.getHql(), query.getHqlParameters());
@@ -61,23 +63,27 @@
HqlAndParametersBuilder<Contact> query = toSampleRowHqlAndParametersBuilder(filter);
+ // Note: pager alrady contains the sort
List<Contact> boats = find(query.getHql(), query.getHqlParameters(), pager);
return boats;
}
public TopiaPagerBean newPager(ContactsFilter filter,
int pageSize,
- int pageIndex,
- String sortProperty,
- boolean sortAscendant) {
+ int pageIndex) {
HqlAndParametersBuilder<Contact> query = toSampleRowHqlAndParametersBuilder(filter);
TopiaPagerBean pager = newPager(query.getHql(), query.getHqlParameters(), pageSize);
pager.setPageIndex(pageIndex);
PagerBeanUtil.computeRecordIndexesAndPagesNumber(pager);
- pager.setSortColumn(sortProperty);
- pager.setSortAscendant(sortAscendant);
+
+ if (filter.isSortedByBoardingDate()) {
+ pager.setSortColumn(Contact.PROPERTY_OBSERVATION_BEGIN_DATE);
+ } else {
+ pager.setSortColumn(Contact.PROPERTY_CREATION_DATE);
+ }
+ pager.setSortAscendant(true);
return pager;
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -37,6 +37,7 @@
import fr.ifremer.wao.entity.WaoUserImpl;
import fr.ifremer.wao.entity.WaoUserTopiaDao;
import fr.ifremer.wao.services.service.ImportErrorException;
+import fr.ifremer.wao.services.service.ObsMerContactsService;
import fr.ifremer.wao.services.service.ObsMerSamplingPlanService;
import fr.ifremer.wao.services.service.administration.ReferentialService;
import org.apache.commons.io.IOUtils;
@@ -51,6 +52,10 @@
protected Map<String, Company> companies = new HashMap<>();
+ protected Map<String, WaoUser> waoUsers = new HashMap<>();
+
+ protected Map<String, UserProfile> userProfiles = new HashMap<>();
+
public ObsMerFixtures(WaoServiceContext serviceContext) {
this.serviceContext = serviceContext;
}
@@ -68,6 +73,64 @@
return company;
}
+ protected UserProfile getUserProfile(String userRole) {
+ UserProfile userProfile = userProfiles.get(userRole);
+ if (userProfile == null) {
+ switch (userRole) {
+ case "admin":
+ userProfile = new UserProfileImpl();
+ userProfile.setUserRole(UserRole.ADMIN);
+ userProfile.setObsProgram(ObsProgram.OBSMER);
+ userProfile.setCanWrite(true);
+ break;
+ case "jmichmuche":
+ userProfile = new UserProfileImpl();
+ userProfile.setUserRole(UserRole.COORDINATOR);
+ userProfile.setObsProgram(ObsProgram.OBSMER);
+ userProfile.setCanWrite(true);
+ break;
+ default:
+ throw new IllegalArgumentException("Don't know userRole: " + userRole);
+ }
+ UserProfileTopiaDao userProfileDao = serviceContext.getPersistenceContext().getUserProfileDao();
+ userProfileDao.create(userProfile);
+ serviceContext.getPersistenceContext().commit();
+ userProfiles.put(userRole, userProfile);
+ }
+ return userProfile;
+ }
+
+ protected WaoUser getWaoUser(String login) {
+ WaoUser waoUser = waoUsers.get(login);
+ if (waoUser == null) {
+
+ switch (login) {
+ case "admin":
+ waoUser = new WaoUserImpl();
+ waoUser.setCompany(ifremer());
+ waoUser.setLogin(login);
+ waoUser.setActive(true);
+ waoUser.addUserProfile(getUserProfile("admin"));
+ break;
+ case "jmichmuche":
+ waoUser = new WaoUserImpl();
+ waoUser.setCompany(ifremer());
+ waoUser.setLogin(login);
+ waoUser.setActive(true);
+ waoUser.addUserProfile(getUserProfile("jmichmuche"));
+ break;
+ default:
+ throw new IllegalArgumentException("Don't know user: " + login);
+ }
+
+ WaoUserTopiaDao waoUserDao = serviceContext.getPersistenceContext().getWaoUserDao();
+ waoUserDao.create(waoUser);
+ serviceContext.getPersistenceContext().commit();
+ waoUsers.put(login, waoUser);
+ }
+ return waoUser;
+ }
+
public Company ifremer() {
return getCompany("Ifremer");
}
@@ -77,23 +140,44 @@
}
public AuthenticatedWaoUser admin() {
- WaoUserTopiaDao waoUserDao = serviceContext.getPersistenceContext().getWaoUserDao();
- WaoUser admin = new WaoUserImpl();
- admin.setCompany(ifremer());
- admin.setLogin("admin");
- admin.setActive(true);
- UserProfileTopiaDao userProfileDao = serviceContext.getPersistenceContext().getUserProfileDao();
- UserProfile userProfile = new UserProfileImpl();
- userProfile.setUserRole(UserRole.ADMIN);
- userProfile.setObsProgram(ObsProgram.OBSMER);
- userProfile.setCanWrite(true);
- userProfileDao.create(userProfile);
- admin.addUserProfile(userProfile);
- waoUserDao.create(admin);
+// WaoUserTopiaDao waoUserDao = serviceContext.getPersistenceContext().getWaoUserDao();
+ WaoUser admin = getWaoUser("admin");
+ UserProfile userProfile = getUserProfile("admin");
+// admin.setCompany(ifremer());
+// admin.setLogin("admin");
+// admin.setActive(true);
+// UserProfileTopiaDao userProfileDao = serviceContext.getPersistenceContext().getUserProfileDao();
+// UserProfile userProfile = new UserProfileImpl();
+// userProfile.setUserRole(UserRole.ADMIN);
+// userProfile.setObsProgram(ObsProgram.OBSMER);
+// userProfile.setCanWrite(true);
+// userProfileDao.create(userProfile);
+// admin.addUserProfile(userProfile);
+// waoUserDao.create(admin);
AuthenticatedWaoUser authenticatedWaoUser = new AuthenticatedWaoUser(admin, userProfile);
return authenticatedWaoUser;
}
+ public AuthenticatedWaoUser jmichmuche() {
+ WaoUser jmichmuche = getWaoUser("jmichmuche");
+ UserProfile userProfile = getUserProfile("jmichmuche");
+// WaoUserTopiaDao waoUserDao = serviceContext.getPersistenceContext().getWaoUserDao();
+// WaoUser jmichmuche = new WaoUserImpl();
+// jmichmuche.setCompany(ifremer());
+// jmichmuche.setLogin("jmichmuche");
+// jmichmuche.setActive(true);
+// UserProfileTopiaDao userProfileDao = serviceContext.getPersistenceContext().getUserProfileDao();
+// UserProfile userProfile = new UserProfileImpl();
+// userProfile.setUserRole(UserRole.COORDINATOR);
+// userProfile.setObsProgram(ObsProgram.OBSMER);
+// userProfile.setCanWrite(true);
+// userProfileDao.create(userProfile);
+// jmichmuche.addUserProfile(userProfile);
+// waoUserDao.create(jmichmuche);
+ AuthenticatedWaoUser authenticatedWaoUser = new AuthenticatedWaoUser(jmichmuche, userProfile);
+ return authenticatedWaoUser;
+ }
+
public void fishingZones() {
InputStream input = null;
try {
@@ -106,6 +190,18 @@
}
}
+ public void navires() {
+ InputStream input = null;
+ try {
+ input = getClass().getResourceAsStream("/import/navires.csv");
+ serviceContext.newService(ReferentialService.class).importBoats(input);
+ } catch (ImportErrorException e) {
+ throw new WaoTechnicalException(e);
+ } finally {
+ IOUtils.closeQuietly(input);
+ }
+ }
+
public void samplingPlan() {
ifremer();
oceanet();
@@ -121,6 +217,21 @@
}
}
+ public void contacts() {
+ samplingPlan();
+ jmichmuche();
+ navires();
+ InputStream input = null;
+ try {
+ input = getClass().getResourceAsStream("/import/contacts.csv");
+ serviceContext.newService(ObsMerContactsService.class).importContacts(admin(), input);
+ } catch (ImportErrorException e) {
+ throw new WaoTechnicalException(e);
+ } finally {
+ IOUtils.closeQuietly(input);
+ }
+ }
+
public FishingGearDCF ptb() {
FishingGearDCFTopiaDao fishingGearDCFDao = serviceContext.getPersistenceContext().getFishingGearDCFDao();
FishingGearDCF ptb = fishingGearDCFDao.forCodeEquals("PTB").findUnique();
Deleted: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -1,18 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-import fr.ifremer.wao.entity.Contact;
-
-/**
- * Created on 4/7/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class ContactDataInputDateAfterObservationEndDateException extends WaoContactValidationException {
-
- private static final long serialVersionUID = 1L;
-
- public ContactDataInputDateAfterObservationEndDateException(Contact contact) {
- super(contact);
- }
-}
Copied: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateBeforeObservationEndDateException.java (from rev 1859, trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java)
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateBeforeObservationEndDateException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateBeforeObservationEndDateException.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ContactDataInputDateBeforeObservationEndDateException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public ContactDataInputDateBeforeObservationEndDateException(Contact contact) {
+ super(contact);
+ }
+}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -22,7 +22,6 @@
*/
import fr.ifremer.wao.WaoException;
-import org.nuiton.csv.ImportRuntimeException;
import org.nuiton.i18n.I18n;
import java.util.Locale;
@@ -34,7 +33,7 @@
private static final long serialVersionUID = 1L;
- public ImportErrorException(ImportRuntimeException e) {
+ public ImportErrorException(Throwable e) {
super(e);
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -54,14 +54,18 @@
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.csv.AbstractImportErrorInfo;
import org.nuiton.csv.Export;
import org.nuiton.csv.ExportModel;
-import org.nuiton.csv.Import;
+import org.nuiton.csv.Import2;
+import org.nuiton.csv.ImportConf;
import org.nuiton.csv.ImportModel;
-import org.nuiton.csv.ImportRuntimeException;
+import org.nuiton.csv.ImportRow;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.pager.TopiaPagerBean;
import org.nuiton.util.DateUtil;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
import java.io.InputStream;
import java.util.Calendar;
@@ -72,6 +76,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import static org.nuiton.i18n.I18n.l;
@@ -82,7 +87,7 @@
public ContactsFilterValues getContactsFilterValues(ContactsFilter filter) {
ContactTopiaDao dao = getContactDao();
- List<Contact> contacts = dao.findAll(filter);
+ List<Contact> contacts = dao.findAll(filter, false);
ContactsFilterValues contactsFilterValues = new ContactsFilterValues(serviceContext.getLocale(), filter.getObsProgram());
@@ -100,9 +105,7 @@
TopiaPagerBean pager = dao.newPager(filter,
queryPager.getPageSize(),
- queryPager.getPageIndex(),
- queryPager.getSortColumn(),
- queryPager.isSortAscendant());
+ queryPager.getPageIndex());
List<Contact> contacts = dao.find(filter, pager);
@@ -209,7 +212,7 @@
public InputStream exportContacts(ContactsFilter filter) {
ContactTopiaDao dao = getContactDao();
- List<Contact> contacts = dao.findAll(filter);
+ List<Contact> contacts = dao.findAll(filter, true);
ExportModel<Contact> exportModel = ObsMerContactImportExportModel.forExport(getLocale(),
filter.getSampleRowFilter().getObsProgram());
@@ -249,108 +252,143 @@
boats,
motives);
- Import<Contact> contactImport = Import.newImport(contactImportModel, csv);
+ ImportConf importConf = new ImportConf();
+ importConf.setStrictMode(true);
- try {
+ Import2<Contact> contactImport = Import2.newImport(importConf, contactImportModel, csv);
- for (Contact contact : contactImport) {
+ for (ImportRow<Contact> contactRow : contactImport) {
- String contactId = contact.getTopiaId();
+ if (!contactRow.isValid()) {
+ // throw first error
+ Set<AbstractImportErrorInfo<Contact>> errors = contactRow.getErrors();
+ AbstractImportErrorInfo<Contact> errorInfo = errors.iterator().next();
+ throw new ImportErrorException(errorInfo.getCause());
+ }
+ long lineNumber = contactRow.getLineNumber();
- Optional<String> optionalContactId = Optional.fromNullable(contactId);
- UpdateContactCommand updateContactCommand = newUpdateContactCommand(authenticatedWaoUser,
- optionalContactId);
+ Contact contact = contactRow.getBean();
- if (updateContactCommand.isCreation()) {
+ String contactId = contact.getTopiaId();
- // TODO bind everything ?
- } else {
+ if (StringUtils.isEmpty(contactId)) {
+ contactId = null;
+ }
- // TODO bind only filled ?
- }
+ Optional<String> optionalContactId = Optional.fromNullable(contactId);
+ UpdateContactCommand updateContactCommand = newUpdateContactCommand(authenticatedWaoUser,
+ optionalContactId);
- preValidate(authenticatedWaoUser, updateContactCommand, false);
+ if (updateContactCommand.isCreation()) {
- save0(updateContactCommand);
+ updateContactCommand.setContact(contact);
+ } else {
+
+ Contact contactToUpdate = updateContactCommand.getContact();
+ Binder<Contact, Contact> binder = BinderFactory.newBinder(Contact.class);
+ binder.copy(contact, contactToUpdate,
+ Contact.PROPERTY_CREATION_DATE,
+ Contact.PROPERTY_MAIN_OBSERVER,
+ Contact.PROPERTY_SECONDARY_OBSERVERS,
+ "contactState",
+ Contact.PROPERTY_OBSERVATION_BEGIN_DATE,
+ Contact.PROPERTY_OBSERVATION_END_DATE,
+ Contact.PROPERTY_DATA_INPUT_DATE,
+ Contact.PROPERTY_COMMENT,
+ Contact.PROPERTY_COMMENT_COORDINATOR,
+ Contact.PROPERTY_COMMENT_ADMIN,
+ Contact.PROPERTY_BOAT,
+ Contact.PROPERTY_VALIDATION_COMPANY,
+ Contact.PROPERTY_VALIDATION_PROGRAM,
+ Contact.PROPERTY_SAMPLE_ROW,
+ Contact.PROPERTY_MAMMALS_OBSERVATION,
+ Contact.PROPERTY_MAMMALS_CAPTURE,
+ Contact.PROPERTY_MAMMALS_INFO,
+ Contact.PROPERTY_CONTACT_STATE_MOTIF,
+ Contact.PROPERTY_RESTITUTION,
+ Contact.PROPERTY_OBSERVED_DATA_CONTROL);
}
- } catch (ImportRuntimeException e) {
- throw new ImportErrorException(e);
- } catch (ContactNotUpdatableException e) {
- String message = l(l, "wao.import.contact.failure.not.updatable");
- throw new ImportErrorException(message);
- } catch (UnwantedContactContactStateMotifException e) {
- String message = l(l, "wao.import.contact.failure.unwantedContactStateMotif");
- throw new ImportErrorException(message);
- } catch (MissingContactNbObservantsException e) {
- String state = WaoUtils.l(l, e.getContact().getContactState());
- String message = l(l, "wao.import.contact.failure.missingObserver", state);
- throw new ImportErrorException(message);
- } catch (MissingContactObservationEndDateException e) {
- String state = WaoUtils.l(l, e.getContact().getContactState());
- String message = l(l, "wao.import.contact.failure.missingObservationEndDate", state);
- throw new ImportErrorException(message);
- } catch (ContactDataInputDateAfterObservationEndDateException e) {
- String message = l(l, "wao.import.contact.failure.dataInputDateAfterObservationEndDate");
- throw new ImportErrorException(message);
- } catch (InvalidContactObservationBeginDateException e) {
- String message = l(l, "wao.import.contact.failure.invalidObservationBeginDate");
- throw new ImportErrorException(message);
- } catch (MissingContactRestitutionException e) {
- String message = l(l, "wao.import.contact.failure.missingRestitution");
- throw new ImportErrorException(message);
- } catch (ContactDataInputDateAfterTodayException e) {
- String message = l(l, "wao.import.contact.failure.dataInputDateAfterObservationEndDate");
- throw new ImportErrorException(message);
- } catch (MissingContactCommentException e) {
- String state = WaoUtils.l(l, e.getContact().getContactState());
- String message = l(l, "wao.import.contact.failure.missingComment", state);
- throw new ImportErrorException(message);
- } catch (MismatchContactMainObserverCompanyException e) {
- String companyName = e.getCompany().getName();
- String observerLogin = e.getObserver().getLogin();
- String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName);
- throw new ImportErrorException(message);
- } catch (ContactRestitutionDateBeforeDataInputDateException e) {
- String message = l(l, "wao.import.contact.failure.transmissionDateBeforeDataInputDate");
- throw new ImportErrorException(message);
- } catch (ContactObservationEndDateBeforeBeginDateException e) {
- String message = l(l, "wao.import.contact.failure.observationEndDateBeforeBeginDate");
- throw new ImportErrorException(message);
- } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
- String message = l(l, "wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers");
- throw new ImportErrorException(message);
- } catch (MissingContactDataReliabilityException e) {
- String message = l(l, "wao.import.contact.failure.missingDataReliability");
- throw new ImportErrorException(message);
- } catch (MismatchContactSecondaryObserverCompanyException e) {
- String companyName = e.getCompany().getName();
- String observerLogin = e.getObserver().getLogin();
- String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName);
- throw new ImportErrorException(message);
- } catch (MissingContactObservedDataControlException e) {
- String message = l(l, "wao.import.contact.failure.missingObservedDataControl");
- throw new ImportErrorException(message);
- } catch (MissingContactStateMotifException e) {
- String message = l(l, "wao.import.contact.failure.missingContactStateMotif");
- throw new ImportErrorException(message);
- } catch (MissingContactDataInputDateException e) {
- String message = l(l, "wao.import.contact.failure.missingDataInputDate");
- throw new ImportErrorException(message);
- } catch (MissingContactMainObserverException e) {
- String message = l(l, "wao.import.contact.failure.missingMainObserver");
- throw new ImportErrorException(message);
- } catch (MissingContactCommentAdminException e) {
- String dataReliability = WaoUtils.l(l, e.getContact().getDataReliability());
- String message = l(l, "wao.import.contact.failure.missingCommentAdmin", dataReliability);
- throw new ImportErrorException(message);
- } catch (ContactObservationEndDateAfterTodayException e) {
- String message = l(l, "wao.import.contact.failure.observationEndDateAfterToday");
- throw new ImportErrorException(message);
- } catch (MissingContactObservationBeginDateException e) {
- String state = WaoUtils.l(l, e.getContact().getContactState());
- String message = l(l, "wao.import.contact.failure.missingObservationBeginDate", state);
- throw new ImportErrorException(message);
+ try {
+ preValidate(authenticatedWaoUser, updateContactCommand, false);
+ } catch (ContactNotUpdatableException e) {
+ String message = l(l, "wao.import.contact.failure.not.updatable", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (UnwantedContactContactStateMotifException e) {
+ String message = l(l, "wao.import.contact.failure.unwantedContactStateMotif", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactNbObservantsException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingObserver", lineNumber, state);
+ throw new ImportErrorException(message);
+ } catch (MissingContactObservationEndDateException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingObservationEndDate", lineNumber, state);
+ throw new ImportErrorException(message);
+ } catch (ContactDataInputDateBeforeObservationEndDateException e) {
+ String message = l(l, "wao.import.contact.failure.dataInputDateBeforeObservationEndDate", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (InvalidContactObservationBeginDateException e) {
+ String message = l(l, "wao.import.contact.failure.invalidObservationBeginDate", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactRestitutionException e) {
+ String message = l(l, "wao.import.contact.failure.missingRestitution", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (ContactDataInputDateAfterTodayException e) {
+ String message = l(l, "wao.import.contact.failure.dataInputDateAfterToday", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactCommentException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingComment", state, lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MismatchContactMainObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", lineNumber, observerLogin, companyName);
+ throw new ImportErrorException(message);
+ } catch (ContactRestitutionDateBeforeDataInputDateException e) {
+ String message = l(l, "wao.import.contact.failure.transmissionDateBeforeDataInputDate", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (ContactObservationEndDateBeforeBeginDateException e) {
+ String message = l(l, "wao.import.contact.failure.observationEndDateBeforeBeginDate", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
+ String message = l(l, "wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactDataReliabilityException e) {
+ String message = l(l, "wao.import.contact.failure.missingDataReliability", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MismatchContactSecondaryObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", lineNumber, observerLogin, companyName);
+ throw new ImportErrorException(message);
+ } catch (MissingContactObservedDataControlException e) {
+ String message = l(l, "wao.import.contact.failure.missingObservedDataControl", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactStateMotifException e) {
+ String message = l(l, "wao.import.contact.failure.missingContactStateMotif", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactDataInputDateException e) {
+ String message = l(l, "wao.import.contact.failure.missingDataInputDate", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactMainObserverException e) {
+ String message = l(l, "wao.import.contact.failure.missingMainObserver", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactCommentAdminException e) {
+ String dataReliability = WaoUtils.l(l, e.getContact().getDataReliability());
+ String message = l(l, "wao.import.contact.failure.missingCommentAdmin", lineNumber, dataReliability);
+ throw new ImportErrorException(message);
+ } catch (ContactObservationEndDateAfterTodayException e) {
+ String message = l(l, "wao.import.contact.failure.observationEndDateAfterToday", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactObservationBeginDateException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingObservationBeginDate", lineNumber, state);
+ throw new ImportErrorException(message);
+ }
+
+ save0(updateContactCommand);
}
commit();
@@ -367,7 +405,7 @@
InvalidContactObservationBeginDateException,
ContactObservationEndDateBeforeBeginDateException,
ContactObservationEndDateAfterTodayException,
- ContactDataInputDateAfterObservationEndDateException,
+ ContactDataInputDateBeforeObservationEndDateException,
ContactDataInputDateAfterTodayException,
MissingContactCommentException,
MissingContactObservationBeginDateException,
@@ -490,11 +528,11 @@
// observation. Since the first is a day (at 00:00) and the second
// is date-time, there may be a bug if the data input day is the same
// as the end of observation
- boolean observationEndDateIsBeforeDataInputDate =
- observationEndDate.before(DateUtil.setMaxTimeOfDay(dataInputDate));
+ boolean dataInputDateAfterObservationEndDate =
+ observationEndDate.after(DateUtil.setMaxTimeOfDay(dataInputDate));
- if (!observationEndDateIsBeforeDataInputDate) {
- throw new ContactDataInputDateAfterObservationEndDateException(contact);
+ if (dataInputDateAfterObservationEndDate) {
+ throw new ContactDataInputDateBeforeObservationEndDateException(contact);
}
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -29,6 +29,7 @@
import fr.ifremer.wao.entity.SampleRowLog;
import fr.ifremer.wao.entity.TerrestrialLocation;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.nuiton.util.DateUtil;
import java.io.Serializable;
@@ -41,8 +42,6 @@
import java.util.Locale;
import java.util.Map;
-import static org.nuiton.i18n.I18n.l;
-
public class ObsMerSamplingPlan implements Iterable<ObsMerSamplingPlan.ObsMerSamplingPlanFacadePart>, Serializable {
private static final long serialVersionUID = 1L;
@@ -245,8 +244,6 @@
}
}
-// protected static final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
-
/**
* Created on 3/24/14.
*
@@ -419,9 +416,9 @@
dcf5CodesAndDescriptions = new LinkedHashMap<>();
for (DCF5Code dcf5Code : sampleRow.getdCF5Code()) {
String key = dcf5Code.getCode();
- String description = dcf5Code.getFishingGearCode() + " - " + l(locale, dcf5Code.getFishingGearDCF().getI18nKey());
+ String description = dcf5Code.getFishingGearCode() + " - " + WaoUtils.l(locale, dcf5Code.getFishingGearDCF());
if (dcf5Code.getTargetSpeciesCode() != null) {
- description += " ; " + dcf5Code.getTargetSpeciesCode() + " - " + l(locale, dcf5Code.getTargetSpeciesDCF().getI18nKey());
+ description += " ; " + dcf5Code.getTargetSpeciesCode() + " - " + WaoUtils.l(locale, dcf5Code.getTargetSpeciesDCF());
}
dcf5CodesAndDescriptions.put(key, description);
}
@@ -435,7 +432,8 @@
}
}
professionDescriptionWithoutDCF5 = sampleRow.getProfessionDescriptionWithoutDCF5();
- samplingStrategy = "";//TODO sampleRow.getSamplingStrategy().getI18nKey();
+ //FIXME Is this ok?
+ samplingStrategy = WaoUtils.l(locale,sampleRow.getSamplingStrategy());
sampleRowId = sampleRow.getTopiaId();
// compute lastSampleLogCreateDate
@@ -614,18 +612,6 @@
return observationTimesInDaysEstimated;
}
-// public boolean hasNbTidesReal(Date month) {
-// Date current = new Date();
-// boolean validMonth = month.before(current) || WaoUtils.isCurrentMonth(month);
-// return validMonth && getNbTidesReal(month) != null;
-// }
-//
-// public boolean hasNbTidesEstimated(Date month) {
-// Date current = new Date();
-// boolean validMonth = month.before(current) || WaoUtils.isCurrentMonth(month);
-// return validMonth && getNbTidesEstimated(month) != null;
-// }
-
public boolean isElligibleBoatsProvided() {
return elligibleBoatsProvided;
}
@@ -701,5 +687,11 @@
return ratio;
}
+ @Override
+ public String toString() {
+ String toString = ToStringBuilder.reflectionToString(this);
+ return toString;
+ }
+
}
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -632,7 +632,7 @@
// on exclue les contacts invalidés par la société
contactFilter.setCompanyAcceptations(Sets.newHashSet(true, null));
- Collection<Contact> contacts = getContactDao().findAll(contactFilter);
+ Collection<Contact> contacts = getContactDao().findAll(contactFilter, false);
final double minutesPerDay = 24 * 60;
// Pour calculer le temps passé, on prend pour chaque observation
@@ -729,7 +729,7 @@
// on exclue les contacts invalidés par la société
contactFilter.setCompanyAcceptations(Sets.newHashSet(true, null));
- Collection<Contact> contacts = getContactDao().findAll(contactFilter);
+ Collection<Contact> contacts = getContactDao().findAll(contactFilter, false);
//----
// Recalcul des tides
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/BoatImportExportModel.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/BoatImportExportModel.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/BoatImportExportModel.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -59,7 +59,7 @@
/**
* Constructor for export.
*
- * @param locale
+ * @param locale current locale used for this import/export
*/
public BoatImportExportModel(Locale locale) {
this.locale = locale;
@@ -68,7 +68,7 @@
/**
* Constructor for import.
*
- * @param locale
+ * @param locale current locale used for this import/export
* @param ports ports that can be used by boats as port of registry
*/
public BoatImportExportModel(Locale locale, List<TerrestrialLocation> ports, List<TerrestrialLocation> districts) {
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -40,6 +40,7 @@
import fr.ifremer.wao.services.service.csv.operations.BoatParserFormatter;
import fr.ifremer.wao.services.service.csv.operations.CompanyParserFormatter;
import fr.ifremer.wao.services.service.csv.operations.ContactStateMotivesParserFormatter;
+import fr.ifremer.wao.services.service.csv.operations.LocalizedToStringParserFormatter;
import fr.ifremer.wao.services.service.csv.operations.LocationTypeParserFormatter;
import fr.ifremer.wao.services.service.csv.operations.ObsDebCodeParserFormatter;
import fr.ifremer.wao.services.service.csv.operations.ObservedDataControlParserFormatter;
@@ -119,7 +120,7 @@
terrestrialLocation = indexedLocations.get(locationType).get(code);
if (terrestrialLocation == null) {
throw new IllegalArgumentException(I18n.t("wao.import.contact.failure.wrongTerrestrialLocation",
- locationType.toString(), code));
+ locationType.toString(), code));
}
}
return terrestrialLocation;
@@ -182,7 +183,7 @@
protected ModelBuilder<Contact> getModel() {
ModelBuilder<Contact> modelBuilder = new ModelBuilder<>();
- modelBuilder.newColumnForImportExport("CONTACT_ID", Contact.TOPIA_ID);
+ modelBuilder.newColumnForImportExport("CONTACT_ID", Contact.PROPERTY_TOPIA_ID);
modelBuilder.newColumnForImportExport("CONTACT_DATE_CREATION", Contact.PROPERTY_CREATION_DATE, Common.DAY_TIME);
modelBuilder.newColumnForImportExport("CONTACT_OBSERVATEUR_PRINCIPAL", Contact.PROPERTY_MAIN_OBSERVER, new UserParserFormatter(locale, waoUsers));
modelBuilder.newColumnForImportExport("CONTACT_OBSERVATEURS_SECONDAIRES", Contact.PROPERTY_SECONDARY_OBSERVERS, new UsersParserFormatter(locale, waoUsers));
@@ -212,7 +213,7 @@
},
new CompanyParserFormatter(locale, null)
);
- modelBuilder.newColumnForImportExport("CONTACT_ETAT", "contactState", new Common.ToStringParserFormatter(ContactState.getAllowedStates(obsProgram)));
+ modelBuilder.newColumnForImportExport("CONTACT_ETAT", "contactState", new LocalizedToStringParserFormatter<>(locale, ContactState.getAllowedStates(obsProgram)));
modelBuilder.newColumnForImportExport("CONTACT_DEBUT_OBSERVATION", Contact.PROPERTY_OBSERVATION_BEGIN_DATE, Common.DAY_TIME);
modelBuilder.newColumnForImportExport("CONTACT_FIN_OBSERVATION", Contact.PROPERTY_OBSERVATION_END_DATE, Common.DAY_TIME);
modelBuilder.newColumnForImportExport("CONTACT_SAISIE_DONNEES", Contact.PROPERTY_DATA_INPUT_DATE, Common.DAY);
@@ -235,7 +236,7 @@
if (obsProgram == ObsProgram.OBSMER) {
modelBuilder.newColumnForImportExport("CONTACT_QUALITE_DONNEE", "dataReliability",
- new Common.ToStringParserFormatter<>(DataReliability.values()));
+ new LocalizedToStringParserFormatter<>(locale, DataReliability.values()));
modelBuilder.newColumnForImportExport("CONTACT_OBSERVATION_MAMMIFERE", Contact.PROPERTY_MAMMALS_OBSERVATION, Common.BOOLEAN);
modelBuilder.newColumnForImportExport("CONTACT_CAPTURE_ACCIDENTELLE", Contact.PROPERTY_MAMMALS_CAPTURE, Common.BOOLEAN);
modelBuilder.newIgnoredColumn("CONTACT_CAPTURE_ACCIDENTELLE_DETAILS");
@@ -253,7 +254,7 @@
}
});
modelBuilder.newColumnForImportExport("CONTACT_TRANSMISSION_RESTITUTION", Contact.PROPERTY_RESTITUTION, Common.DAY);
- modelBuilder.newColumnForImportExport("CONTACT_DONNEES_ALLEGRO_VALIDEES", Contact.PROPERTY_OBSERVED_DATA_CONTROL, new ObservedDataControlParserFormatter());
+ modelBuilder.newColumnForImportExport("CONTACT_DONNEES_ALLEGRO_VALIDEES", Contact.PROPERTY_OBSERVED_DATA_CONTROL, new ObservedDataControlParserFormatter(locale));
} else {
// FIXME 20110606 bleny contact.getTerrestrialLocation() may be null, export will fail
@@ -272,12 +273,13 @@
LocationType locationType = null;
if (contact.getTerrestrialLocation() != null) {
locationType = contact.getTerrestrialLocation()
- .getLocationType();
+ .getLocationType();
}
return locationType;
}
},
- locationTypeParserFormatter);
+ locationTypeParserFormatter
+ );
modelBuilder.newColumnForImportExport(
"CONTACT_LIEU_CODE",
Contact.PROPERTY_TERRESTRIAL_LOCATION,
@@ -290,7 +292,7 @@
String description = "";
if (contact.getTerrestrialLocation() != null) {
description = contact.getTerrestrialLocation()
- .getDescription();
+ .getDescription();
}
return description;
}
@@ -303,7 +305,7 @@
if (obsProgram == ObsProgram.OBSDEB) {
modelBuilder.newColumnForImportExport("CONTACT_DATE_DEBARQUEMENT", Contact.PROPERTY_LANDING_DATE, Common.DAY_TIME);
- modelBuilder.newColumnForImportExport("CONTACT_TYPE_OBSERVATION", "observationType", new Common.ToStringParserFormatter(ObservationType.values()));
+ modelBuilder.newColumnForImportExport("CONTACT_TYPE_OBSERVATION", "observationType", new LocalizedToStringParserFormatter<>(locale, ObservationType.values()));
modelBuilder.newColumnForImportExport("CONTACT_METIER", Contact.PROPERTY_OBS_DEB_CODE, new ObsDebCodeParserFormatter(locale, obsDebCodes));
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactStateMotivesImportModel.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactStateMotivesImportModel.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactStateMotivesImportModel.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -74,6 +74,7 @@
@Override
public String parse(String value) throws ParseException {
if (value.length() != 6) {
+ //FIXME Not correct i18n key
throw new IllegalArgumentException(I18n.l(locale, "wao.import.contact.failure.wrongColor", value));
}
return value.trim();
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/FishingZoneImportModel.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/FishingZoneImportModel.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/FishingZoneImportModel.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -31,7 +31,6 @@
import org.nuiton.csv.ImportableColumn;
import org.nuiton.csv.ModelBuilder;
-import java.util.Collection;
import java.util.List;
import java.util.Locale;
@@ -69,6 +68,6 @@
modelBuilder.newMandatoryColumn("PECHE_FACADE", FishingZone.PROPERTY_FACADE_NAME);
modelBuilder.newMandatoryColumn("PECHE_LATITUDE", FishingZone.PROPERTY_LATITUDE, new LatitudeParserFormatter(locale, true));
modelBuilder.newMandatoryColumn("PECHE_LONGITUDE", FishingZone.PROPERTY_LONGITUDE, new LongitudeParserFormatter(locale, true));
- return (Collection) modelBuilder.getColumnsForImport();
+ return (Iterable) modelBuilder.getColumnsForImport();
}
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerContactImportExportModel.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerContactImportExportModel.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerContactImportExportModel.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -37,6 +37,7 @@
import fr.ifremer.wao.services.service.csv.operations.BoatParserFormatter;
import fr.ifremer.wao.services.service.csv.operations.CompanyParserFormatter;
import fr.ifremer.wao.services.service.csv.operations.ContactStateMotivesParserFormatter;
+import fr.ifremer.wao.services.service.csv.operations.LocalizedToStringParserFormatter;
import fr.ifremer.wao.services.service.csv.operations.ObservedDataControlParserFormatter;
import fr.ifremer.wao.services.service.csv.operations.SampleRowParserFormatter;
import fr.ifremer.wao.services.service.csv.operations.UserParserFormatter;
@@ -118,18 +119,6 @@
return newContact;
}
- public ModelBuilder<Contact> getExportModel() {
- return getModel();
- }
-
- public ModelBuilder<Contact> getImportModel() {
- Preconditions.checkState(sampleRows != null, "To import must have sampleRows");
- Preconditions.checkState(waoUsers != null, "To import must have waoUsers");
- Preconditions.checkState(boats != null, "To import must have boats");
- Preconditions.checkState(motives != null, "To import must have motives");
- return getModel();
- }
-
protected ModelBuilder<Contact> getModel() {
ModelBuilder<Contact> modelBuilder = new ModelBuilder<>();
modelBuilder.newColumnForImportExport("CONTACT_ID", Contact.PROPERTY_TOPIA_ID);
@@ -165,7 +154,7 @@
},
new CompanyParserFormatter(locale, null)
);
- modelBuilder.newColumnForImportExport("CONTACT_ETAT", "contactState", new Common.ToStringParserFormatter(ContactState.getAllowedStates(obsProgram)));
+ modelBuilder.newColumnForImportExport("CONTACT_ETAT", "contactState", new LocalizedToStringParserFormatter<>(locale, ContactState.getAllowedStates(obsProgram)));
modelBuilder.newColumnForImportExport("CONTACT_DEBUT_OBSERVATION", Contact.PROPERTY_OBSERVATION_BEGIN_DATE, Common.DAY_TIME);
modelBuilder.newColumnForImportExport("CONTACT_FIN_OBSERVATION", Contact.PROPERTY_OBSERVATION_END_DATE, Common.DAY_TIME);
modelBuilder.newColumnForImportExport("CONTACT_SAISIE_DONNEES", Contact.PROPERTY_DATA_INPUT_DATE, Common.DAY);
@@ -191,7 +180,7 @@
}
modelBuilder.newColumnForImportExport("CONTACT_QUALITE_DONNEE", "dataReliability",
- new Common.ToStringParserFormatter<>(DataReliability.values()));
+ new LocalizedToStringParserFormatter<>(locale, DataReliability.values()));
modelBuilder.newColumnForImportExport("CONTACT_OBSERVATION_MAMMIFERE", Contact.PROPERTY_MAMMALS_OBSERVATION, Common.BOOLEAN);
modelBuilder.newColumnForImportExport("CONTACT_CAPTURE_ACCIDENTELLE", Contact.PROPERTY_MAMMALS_CAPTURE, Common.BOOLEAN);
modelBuilder.newIgnoredColumn("CONTACT_CAPTURE_ACCIDENTELLE_DETAILS");
@@ -211,19 +200,19 @@
}
});
modelBuilder.newColumnForImportExport("CONTACT_TRANSMISSION_RESTITUTION", Contact.PROPERTY_RESTITUTION, Common.DAY);
- modelBuilder.newColumnForImportExport("CONTACT_DONNEES_ALLEGRO_VALIDEES", Contact.PROPERTY_OBSERVED_DATA_CONTROL, new ObservedDataControlParserFormatter());
+ modelBuilder.newColumnForImportExport("CONTACT_DONNEES_ALLEGRO_VALIDEES", Contact.PROPERTY_OBSERVED_DATA_CONTROL, new ObservedDataControlParserFormatter(locale));
return modelBuilder;
}
@Override
public Iterable<ExportableColumn<Contact, Object>> getColumnsForExport() {
- return (Iterable) getExportModel().getColumnsForExport();
+ return (Iterable) getModel().getColumnsForExport();
}
@Override
public Iterable<ImportableColumn<Contact, Object>> getColumnsForImport() {
- return (Iterable) getImportModel().getColumnsForImport();
+ return (Iterable) getModel().getColumnsForImport();
}
}
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/LocalizedToStringParserFormatter.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/LocalizedToStringParserFormatter.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/LocalizedToStringParserFormatter.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -0,0 +1,72 @@
+package fr.ifremer.wao.services.service.csv.operations;
+
+import com.google.common.collect.Sets;
+import org.nuiton.csv.ValueParserFormatter;
+import org.nuiton.util.StringUtil;
+
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n.l;
+
+/**
+ * Created on 4/8/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class LocalizedToStringParserFormatter<E> implements ValueParserFormatter<E> {
+
+ protected Map<E, String> toStrings = new HashMap<>();
+
+ protected Map<String, E> fromString = new HashMap<>();
+
+ protected Locale locale;
+
+ @SafeVarargs
+ public LocalizedToStringParserFormatter(Locale locale, E... values) {
+ this(locale, Sets.newHashSet(values), null);
+ }
+
+ public LocalizedToStringParserFormatter(Locale locale,
+ Iterable<E> values) {
+ this(locale, values, null);
+ }
+
+ public LocalizedToStringParserFormatter(Locale locale,
+ Iterable<E> values,
+ StringUtil.ToString<E> toString) {
+ this.locale = locale;
+ for (E value : values) {
+ String valueToString;
+ if (toString == null) {
+ valueToString = value.toString();
+ } else {
+ valueToString = toString.toString(value);
+ }
+ toStrings.put(value, valueToString);
+ fromString.put(valueToString, value);
+ }
+ }
+
+ @Override
+ public String format(E value) {
+ String valueAsString = toStrings.get(value);
+ if (valueAsString == null) {
+ throw new IllegalArgumentException();
+ }
+ return valueAsString;
+ }
+
+ @Override
+ public E parse(String valueAsString) throws ParseException {
+ E value = fromString.get(valueAsString);
+ if (value == null) {
+ String message = l(locale, "wao.import.failure.wrongValue", valueAsString, fromString.keySet().toString());
+ throw new IllegalArgumentException(message);
+ }
+ return value;
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/LocalizedToStringParserFormatter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ObservedDataControlParserFormatter.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ObservedDataControlParserFormatter.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ObservedDataControlParserFormatter.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -25,7 +25,6 @@
import fr.ifremer.wao.entity.ObservedDataControl;
import org.apache.commons.lang3.StringUtils;
-import org.nuiton.csv.Common;
import org.nuiton.csv.ValueParserFormatter;
import org.nuiton.util.StringUtil;
@@ -33,6 +32,7 @@
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import java.util.Locale;
/**
* Basé sur un ToStringParserFormatter (comme toutes les énums) mais il faut
@@ -44,7 +44,7 @@
protected ValueParserFormatter<ObservedDataControl> nonNullObservedDataControlParserFormatter;
- public ObservedDataControlParserFormatter() {
+ public ObservedDataControlParserFormatter(Locale locale) {
List<ObservedDataControl> observedDataControlsValues = new LinkedList<>();
Collections.addAll(observedDataControlsValues, ObservedDataControl.values());
observedDataControlsValues.add(null);
@@ -58,7 +58,7 @@
return toString;
}
};
- nonNullObservedDataControlParserFormatter = new Common.ToStringParserFormatter(observedDataControlsValues, nullableObservedDataControlToString);
+ nonNullObservedDataControlParserFormatter = new LocalizedToStringParserFormatter<>(locale, observedDataControlsValues, nullableObservedDataControlToString);
}
@Override
Modified: trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties
===================================================================
--- trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-04-08 11:44:47 UTC (rev 1864)
@@ -44,8 +44,8 @@
wao.import.contact.failure.missingDataInputDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution
wao.import.contact.failure.missingDataReliability=You must provide data reliability before validating
wao.import.contact.failure.missingHoursOfBeginEndObservation=You must provide accurate time for the beginning and the end of observation
-wao.import.contact.failure.missingMainBbserver=Il faut au moins un observateur référant
-wao.import.contact.failure.missingMainObserver=
+wao.import.contact.failure.missingMainObserver=Il faut au moins un observateur référant
+wao.import.failure.wrongValue=Unable to parse value '%S'. Possible values are %s
wao.import.contact.failure.missingObservationArea=Il faut préciser un lieu d'observation
wao.import.contact.failure.missingObservationBeginDate=La date de début de marée est obligatoire pour l'état '%s'
wao.import.contact.failure.missingObservationEndDate=La date de fin d'observation est obligatoire pour l'état '%s'
Modified: trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties
===================================================================
--- trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-04-08 11:44:47 UTC (rev 1864)
@@ -30,36 +30,35 @@
wao.import.boat.failure.invalid.locationCode=Le code '%s' n'est pas un code de lieu valide
wao.import.boat.failure.missing.port=Il faut préciser un port
wao.import.contact.failure.boatMissing=Il faut préciser l'immatriculation du navire associé au contact
-wao.import.contact.failure.dataInputDateAfterObservationEndDate=
-wao.import.contact.failure.dataInputDateBeforeObservationEndDate=La date de saisie des données ne peut pas être antérieure à la date de fin d'observation
-wao.import.contact.failure.dataInputDateBeforeToday=La date de saisie des données doit être antérieur à la date du jour
+wao.import.contact.failure.dataInputDateBeforeObservationEndDate=La date de saisie des données doit être postérieure à la date de fin d'observation
+wao.import.contact.failure.dataInputDateAfterToday=La date de saisie des données doit être antérieure à la date du jour
wao.import.contact.failure.districtMissing=Il faut préciser le code d'un quartier maritime
wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers=L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires
-wao.import.contact.failure.invalid.observationBeginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne
-wao.import.contact.failure.invalidObservationBeginDate=
+wao.import.contact.failure.invalidObservationBeginDate=Ligne %s : La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne
wao.import.contact.failure.locationTypeMissing=Le type du lieu doit être renseigné
-wao.import.contact.failure.mismatchCompanyForObserver=L'observateur %s n'est pas membre de la société %s
-wao.import.contact.failure.missingComment=Il faut préciser un commentaire pour l'état '%s'
-wao.import.contact.failure.missingCommentAdmin=Il faut préciser dans le commentaire administrateur pourquoi la donnée est '%s'
-wao.import.contact.failure.missingContactStateMotif=Il faut préciser un motif de refus
-wao.import.contact.failure.missingDataInputDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution
-wao.import.contact.failure.missingDataReliability=Il faut préciser la qualité de la donnée avant de valider
+wao.import.contact.failure.mismatchCompanyForObserver=Ligne %s : L'observateur %s n'est pas membre de la société %s
+wao.import.contact.failure.missingComment=Ligne %s : Il faut préciser un commentaire pour l'état '%s'
+wao.import.contact.failure.missingCommentAdmin=Ligne %s : Il faut préciser dans le commentaire administrateur pourquoi la donnée est '%s'
+wao.import.contact.failure.missingContactStateMotif=Ligne %s : Il faut préciser un motif de refus
+wao.import.contact.failure.missingDataInputDate=Ligne %s : Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution
+wao.import.contact.failure.missingDataReliability=Ligne %s : Il faut préciser la qualité de la donnée avant de valider
wao.import.contact.failure.missingHoursOfBeginEndObservation=Il faut préciser les heures exactes de début et de fin d'observation
-wao.import.contact.failure.missingMainObserver=Il faut au moins un observateur référant
+wao.import.contact.failure.missingMainObserver=Ligne %s : Il faut au moins un observateur référant
+wao.import.failure.wrongValue=Valeur '%s' non reconnue. Valeurs possibles : %s
wao.import.contact.failure.missingObservationArea=Il faut préciser un lieu d'observation
-wao.import.contact.failure.missingObservationBeginDate=La date de début de marée est obligatoire pour l'état '%s'
-wao.import.contact.failure.missingObservationEndDate=La date de fin d'observation est obligatoire pour l'état '%s'
-wao.import.contact.failure.missingObservedDataControl=Il faut préciser une valeur pour le contrôle des données observées
-wao.import.contact.failure.missingObserver=Il ne peut y avoir aucun observateur pour l'état '%s'
-wao.import.contact.failure.missingRestitution=Il faut préciser une date de transmission de la restitution de la donnée avant de valider
-wao.import.contact.failure.not.updatable=Vous n'avez pas les droits suffisants pour modifier le contact
-wao.import.contact.failure.observationEndDateAfterToday=La date de fin de la marée ne peut pas être postérieure à la date du jour
-wao.import.contact.failure.observationEndDateBeforeBeginDate=La date de fin d'observation ne peut pas être antérieure à celle du début
+wao.import.contact.failure.missingObservationBeginDate=Ligne %s : La date de début de marée est obligatoire pour l'état '%s'
+wao.import.contact.failure.missingObservationEndDate=Ligne %s : La date de fin d'observation est obligatoire pour l'état '%s'
+wao.import.contact.failure.missingObservedDataControl=Ligne %s : Il faut préciser une valeur pour le contrôle des données observées
+wao.import.contact.failure.missingObserver=Ligne %s : Il ne peut y avoir aucun observateur pour l'état '%s'
+wao.import.contact.failure.missingRestitution=Ligne %s : Il faut préciser une date de transmission de la restitution de la donnée avant de valider
+wao.import.contact.failure.not.updatable=Ligne %s : Vous n'avez pas les droits suffisants pour modifier le contact
+wao.import.contact.failure.observationEndDateAfterToday=Ligne %s : La date de fin de la marée ne peut pas être postérieure à la date du jour
+wao.import.contact.failure.observationEndDateBeforeBeginDate=Ligne %s : La date de fin d'observation ne peut pas être antérieure à celle du début
wao.import.contact.failure.sampleRowCodeMissing=Il manque le code de la ligne de plan associée
wao.import.contact.failure.terrestrialLocationMissing=Il manque le code du lieu
-wao.import.contact.failure.transmissionDateBeforeDataInputDate=Il faut que la date de transmission de la restitution soit après la date de saisie des données
+wao.import.contact.failure.transmissionDateBeforeDataInputDate=Ligne %s : Il faut que la date de transmission de la restitution soit après la date de saisie des données
wao.import.contact.failure.unkwonCompany=Il n'y a pas de société ayant pour nom '%s'
-wao.import.contact.failure.unwantedContactStateMotif=Il ne faut pas préciser de motif de refus
+wao.import.contact.failure.unwantedContactStateMotif=Ligne %s : Il ne faut pas préciser de motif de refus
wao.import.contact.failure.wrongBoat=Il n'y a pas de navire avec l'immatriculation '%s'
wao.import.contact.failure.wrongColor=Le code couleur '%s' n'est pas valide, il doit être composé de six caractères sans dièze voir http\://fr.wikipedia.org/wiki/Couleurs_du_Web
wao.import.contact.failure.wrongContactStateMotifCode=Le code '%s' n'est pas un code de motif de refus valide
Modified: trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java
===================================================================
--- trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -24,12 +24,22 @@
import fr.ifremer.wao.ContactsFilter;
import fr.ifremer.wao.services.AbstractWaoServiceTest;
import fr.ifremer.wao.services.ObsMerFixtures;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Assert;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.nuiton.topia.persistence.pager.TopiaPagerBean;
+import java.io.InputStream;
+
public class ObsMerContactsServiceTest extends AbstractWaoServiceTest {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ObsMerContactsServiceTest.class);
+
protected ObsMerContactsService service;
protected ObsMerFixtures fixtures;
@@ -62,4 +72,28 @@
ObsMerContactsList contactsList = service.getContactsList(filter, pager);
}
+ //FIXME finish to code samplingPlan import to make this works
+ @Ignore
+ @Test
+ public void testImportContacts() {
+ fixtures.samplingPlan();
+ fixtures.jmichmuche();
+ fixtures.navires();
+
+ InputStream input = null;
+ try {
+ Assert.assertEquals(0, service.getContactDao().count());
+ input = getClass().getResourceAsStream("/import/contacts.csv");
+ service.importContacts(fixtures.admin(), input);
+ Assert.assertEquals(2, service.getContactDao().count());
+ } catch (ImportErrorException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("unexpected exception raised", e);
+ }
+ Assert.fail("exception should not be raised");
+ } finally {
+ IOUtils.closeQuietly(input);
+ }
+ }
+
}
Modified: trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java
===================================================================
--- trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -23,6 +23,8 @@
import com.google.common.collect.ImmutableSet;
import fr.ifremer.wao.SampleRowsFilter;
+import fr.ifremer.wao.entity.SampleMonth;
+import fr.ifremer.wao.entity.SampleRow;
import fr.ifremer.wao.services.AbstractWaoServiceTest;
import fr.ifremer.wao.services.ObsMerFixtures;
import org.apache.commons.io.IOUtils;
@@ -35,6 +37,9 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
import static fr.ifremer.wao.services.service.ObsMerSamplingPlan.ObsMerSamplingPlanFacadePart;
import static fr.ifremer.wao.services.service.ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart;
@@ -96,13 +101,13 @@
filter = service.newSampleRowsFilter(fixtures.admin());
filter.setTargetSpeciesDcfIds(ImmutableSet.of(fixtures.def().getTopiaId()));
samplingPlan = service.getSamplingPlan(filter);
- assertSamplePlanRowsNumber(4, samplingPlan );
+ assertSamplePlanRowsNumber(4, samplingPlan);
filter = service.newSampleRowsFilter(fixtures.admin());
filter.setFishingGearDcfIds(ImmutableSet.of(fixtures.ptb().getTopiaId()));
filter.setTargetSpeciesDcfIds(ImmutableSet.of(fixtures.def().getTopiaId()));
samplingPlan = service.getSamplingPlan(filter);
- assertSamplePlanRowsNumber(1, samplingPlan );
+ assertSamplePlanRowsNumber(1, samplingPlan);
}
protected void assertSamplePlanRowsNumber(int expectedRowsSize, ObsMerSamplingPlan samplingPlan) {
@@ -151,4 +156,35 @@
}
}
+
+ @Test
+ public void testRecomputeSampleRowEstimatedAndRealTides() throws Exception {
+
+ fixtures.contacts();
+
+ SampleRow sampleRow = serviceContext.getPersistenceContext().getSampleRowDao().forCodeEquals("2010_M0011").findUnique();
+
+ Map<Date, ObsMerSamplingPlan.ObsMerSamplingPlanStatistics> oldStats = new HashMap<>();
+ for (SampleMonth sampleMonth : sampleRow.getSampleMonth()) {
+
+ ObsMerSamplingPlan.ObsMerSamplingPlanStatistics stats = new ObsMerSamplingPlan.ObsMerSamplingPlanStatistics(
+ sampleMonth.getExpectedTidesValue(),
+ sampleMonth.getRealTidesValue(),
+ sampleMonth.getEstimatedTidesValue()
+ );
+ oldStats.put(sampleMonth.getPeriodDate(), stats);
+ }
+ service.recomputeSampleRowEstimatedAndRealTides(sampleRow);
+
+ for (SampleMonth sampleMonth : sampleRow.getSampleMonth()) {
+
+ ObsMerSamplingPlan.ObsMerSamplingPlanStatistics oldMonth = oldStats.get(sampleMonth.getPeriodDate());
+ int expectedTidesValue = sampleMonth.getExpectedTidesValue();
+ int realTidesValue = sampleMonth.getRealTidesValue();
+ int estimatedTidesValue = sampleMonth.getEstimatedTidesValue();
+ Assert.assertEquals(oldMonth.getNbTidesExpected(), expectedTidesValue, 0.01);
+ Assert.assertEquals(oldMonth.getNbTidesReal(), realTidesValue, 0.01);
+ Assert.assertEquals(oldMonth.getNbTidesEstimated(), estimatedTidesValue, 0.01);
+ }
+ }
}
Modified: trunk/wao-services/src/test/resources/import/contacts.csv
===================================================================
--- trunk/wao-services/src/test/resources/import/contacts.csv 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-services/src/test/resources/import/contacts.csv 2014-04-08 11:44:47 UTC (rev 1864)
@@ -1,2 +1,2 @@
CONTACT_ID;CONTACT_DATE_CREATION;CONTACT_OBSERVATEUR_PRINCIPAL;CONTACT_OBSERVATEURS_SECONDAIRES;CONTACT_ETAT;CONTACT_DEBUT_OBSERVATION;CONTACT_FIN_OBSERVATION;CONTACT_SAISIE_DONNEES;CONTACT_COMMENTAIRE_OBSERVATEUR;CONTACT_COMMENTAIRE_COORDINATEUR;CONTACT_COMMENTAIRE_PROGRAMME;PLAN_CODE;NAVIRE_IMMATRICULATION;CONTACT_VALIDATION_SOCIETE;CONTACT_VALIDATION_PROGRAMME;CONTACT_QUALITE_DONNEE;CONTACT_OBSERVATION_MAMMIFERE;CONTACT_CAPTURE_ACCIDENTELLE;CONTACT_ETAT_MOTIF_CODE;CONTACT_ETAT_MOTIF_NOM;CONTACT_TRANSMISSION_RESTITUTION;CONTACT_DONNEES_ALLEGRO_VALIDEES
-;01/03/2011 10:24;jmichmuche;;Refus définitif;;;;ne veut plus collaborer;;;2010_0001;175846;?;?;Inconnue;N;N;REFUS_PROFESSION;;;
\ No newline at end of file
+;01/03/2011 10:24;jmichmuche;;CONTACT_DEFINITELY_REFUSED;;;;ne veut plus collaborer;;;2010_M0001;174258;?;?;UNKNOWN;N;N;REFUS_PROFESSION;;;
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -26,7 +26,7 @@
import com.opensymphony.xwork2.Preparable;
import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.services.AuthenticatedWaoUser;
-import fr.ifremer.wao.services.service.ContactDataInputDateAfterObservationEndDateException;
+import fr.ifremer.wao.services.service.ContactDataInputDateBeforeObservationEndDateException;
import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException;
import fr.ifremer.wao.services.service.ContactNotUpdatableException;
import fr.ifremer.wao.services.service.ContactObservationEndDateAfterTodayException;
@@ -107,80 +107,100 @@
try {
service.preValidate(authenticatedWaoUser, updateContactCommand, true);
} catch (ContactNotUpdatableException e) {
- addActionError(t("wao.ui.contacts.validation.failure.not.updatable"));
- addFieldError("updateContactCommand.contact.", t("wao.ui.contacts.validation.failure.not.updatable", e.getMessage()));
+ session.addErrorMessages(t("wao.ui.contacts.validation.failure.not.updatable"));
} catch (UnwantedContactContactStateMotifException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.unwantedContactStateMotif"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.unwantedContactStateMotif"));
} catch (MissingContactNbObservantsException e) {
String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObserver", state));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingObserver", state));
} catch (MissingContactObservationEndDateException e) {
String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObservationEndDate", state));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingObservationEndDate", state));
- } catch (ContactDataInputDateAfterObservationEndDateException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.dataInputDateAfterObservationEndDate"));
+ } catch (ContactDataInputDateBeforeObservationEndDateException e) {
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.dataInputDateBeforeObservationEndDate"));
} catch (InvalidContactObservationBeginDateException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.invalidObservationBeginDate"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.invalidObservationBeginDate"));
} catch (MissingContactRestitutionException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingRestitution"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingRestitution"));
} catch (ContactDataInputDateAfterTodayException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.dataInputDateAfterObservationEndDate"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.dataInputDateAfterToday"));
} catch (MissingContactCommentException e) {
String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingComment", state));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingComment", state));
} catch (MismatchContactMainObserverCompanyException e) {
String companyName = e.getCompany().getName();
String observerLogin = e.getObserver().getLogin();
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.mismatchCompanyForObserver", observerLogin, companyName));
} catch (ContactRestitutionDateBeforeDataInputDateException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.transmissionDateBeforeDataInputDate"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.transmissionDateBeforeDataInputDate"));
} catch (ContactObservationEndDateBeforeBeginDateException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.observationEndDateBeforeBeginDate"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.observationEndDateBeforeBeginDate"));
} catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.duplicatedMainObserverInSecondaryObservers"));
} catch (MissingContactDataReliabilityException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingDataReliability"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingDataReliability"));
} catch (MismatchContactSecondaryObserverCompanyException e) {
String companyName = e.getCompany().getName();
String observerLogin = e.getObserver().getLogin();
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.mismatchCompanyForObserver", observerLogin, companyName));
} catch (MissingContactObservedDataControlException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObservedDataControl"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingObservedDataControl"));
} catch (MissingContactStateMotifException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingContactStateMotif"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingContactStateMotif"));
} catch (MissingContactDataInputDateException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingDataInputDate"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingDataInputDate"));
} catch (MissingContactMainObserverException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingMainObserver"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingMainObserver"));
} catch (MissingContactCommentAdminException e) {
String dataReliability = WaoUtils.l(getLocale(), e.getContact().getDataReliability());
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingCommentAdmin", dataReliability));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingCommentAdmin", dataReliability));
} catch (ContactObservationEndDateAfterTodayException e) {
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.observationEndDateAfterToday"));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.observationEndDateAfterToday"));
} catch (MissingContactObservationBeginDateException e) {
String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObservationBeginDate", state));
+ //TODO fix field
+ addFieldError("updateContactCommand.contact.", t("wao.ui.form.Contact.error.missingObservationBeginDate", state));
}
}
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-04-08 11:44:47 UTC (rev 1864)
@@ -26,7 +26,7 @@
import com.opensymphony.xwork2.Preparable;
import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.services.AuthenticatedWaoUser;
-import fr.ifremer.wao.services.service.ContactDataInputDateAfterObservationEndDateException;
+import fr.ifremer.wao.services.service.ContactDataInputDateBeforeObservationEndDateException;
import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException;
import fr.ifremer.wao.services.service.ContactNotUpdatableException;
import fr.ifremer.wao.services.service.ContactObservationEndDateAfterTodayException;
@@ -180,7 +180,7 @@
String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
errorMessage = t("wao.import.contact.failure.missingObservationEndDate", state);
- } catch (ContactDataInputDateAfterObservationEndDateException e) {
+ } catch (ContactDataInputDateBeforeObservationEndDateException e) {
errorMessage = t("wao.import.contact.failure.dataInputDateAfterObservationEndDate");
} catch (InvalidContactObservationBeginDateException e) {
Modified: trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties
===================================================================
--- trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-04-08 10:54:25 UTC (rev 1863)
+++ trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-04-08 11:44:47 UTC (rev 1864)
@@ -5,25 +5,6 @@
wao.import.boatGroups.success=Import des flotilles réalisé avec succès
wao.import.boats.prompt=Import des navires
wao.import.boats.success=Import des navires réalisé avec succès
-wao.import.contact.failure.dataInputDateAfterObservationEndDate=
-wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers=
-wao.import.contact.failure.invalidObservationBeginDate=
-wao.import.contact.failure.mismatchCompanyForObserver=
-wao.import.contact.failure.missingComment=
-wao.import.contact.failure.missingCommentAdmin=
-wao.import.contact.failure.missingContactStateMotif=
-wao.import.contact.failure.missingDataInputDate=
-wao.import.contact.failure.missingDataReliability=
-wao.import.contact.failure.missingMainObserver=
-wao.import.contact.failure.missingObservationBeginDate=
-wao.import.contact.failure.missingObservationEndDate=
-wao.import.contact.failure.missingObservedDataControl=
-wao.import.contact.failure.missingObserver=
-wao.import.contact.failure.missingRestitution=
-wao.import.contact.failure.observationEndDateAfterToday=
-wao.import.contact.failure.observationEndDateBeforeBeginDate=
-wao.import.contact.failure.transmissionDateBeforeDataInputDate=
-wao.import.contact.failure.unwantedContactStateMotif=
wao.import.contactStateMotives.prompt=Import des motifs de refus
wao.import.contactStateMotives.success=Import des motifs de refus réalisé avec succès
wao.import.fishingZones.prompt=Import des zones de pêches
@@ -158,6 +139,26 @@
wao.ui.contacts.validation.to.accept.state.success=Le contact a été accepté avec succès
wao.ui.contacts.validation.to.reject.state.success=Le contact a été rejeté avec succès
wao.ui.contacts.validation.to.unvalidate.state.success=Le contact a été invalidé avec succès
+wao.ui.form.Contact.error.dataInputDateBeforeObservationEndDate=La date de saisie des données doit être postérieure à la date de fin d'observation
+wao.ui.form.Contact.error.dataInputDateAfterToday=La date de saisie des données doit être antérieure à la date du jour
+wao.ui.form.Contact.error.duplicatedMainObserverInSecondaryObservers=L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires
+wao.ui.form.Contact.error.invalidObservationBeginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne
+wao.ui.form.Contact.error.mismatchCompanyForObserver=L'observateur %s n'est pas membre de la société %s
+wao.ui.form.Contact.error.missingComment=Il faut préciser un commentaire pour l'état '%s'
+wao.ui.form.Contact.error.missingCommentAdmin=Il faut préciser dans le commentaire administrateur pourquoi la donnée est '%s'
+wao.ui.form.Contact.error.missingContactStateMotif=Il faut préciser un motif de refus
+wao.ui.form.Contact.error.missingDataInputDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution
+wao.ui.form.Contact.error.missingDataReliability=Il faut préciser la qualité de la donnée avant de valider
+wao.ui.form.Contact.error.missingMainObserver=Il faut au moins un observateur référant
+wao.ui.form.Contact.error.missingObservationBeginDate=La date de début de marée est obligatoire pour l'état '%s'
+wao.ui.form.Contact.error.missingObservationEndDate=La date de fin d'observation est obligatoire pour l'état '%s'
+wao.ui.form.Contact.error.missingObservedDataControl=Il faut préciser une valeur pour le contrôle des données observées
+wao.ui.form.Contact.error.missingObserver=Il ne peut y avoir aucun observateur pour l'état '%s'
+wao.ui.form.Contact.error.missingRestitution=Il faut préciser une date de transmission de la restitution de la donnée avant de valider
+wao.ui.form.Contact.error.observationEndDateAfterToday=La date de fin de la marée ne peut pas être postérieure à la date du jour
+wao.ui.form.Contact.error.observationEndDateBeforeBeginDate=La date de fin d'observation ne peut pas être antérieure à celle du début
+wao.ui.form.Contact.error.transmissionDateBeforeDataInputDate=Il faut que la date de transmission de la restitution soit après la date de saisie des données
+wao.ui.form.Contact.error.unwantedContactStateMotif=Il ne faut pas préciser de motif de refus
wao.ui.disclaimer=Le site de « SUIVI DU REALISE DU PLAN D'ECHANTILLONNAGE DES OBSERVATIONS A LA MER » a fait l'objet d'une déclaration à la CNIL sous le numéro suivant \: 1414476
wao.ui.disclaimer.boats=Les données saisies dans cette page sont la propriété exclusive de la société. En dehors de la société, seul l'administrateur peut les consulter pour des questions de maintenance sur le site. L'administrateur est une personne de l'Ifremer.
wao.ui.email=Adresse e-mail
1
0
r1863 - in trunk: wao-persistence/src/main/java/fr/ifremer/wao/entity wao-services/src/main/java/fr/ifremer/wao/services/service wao-services/src/test/java/fr/ifremer/wao/services/service wao-web/src/main/java/fr/ifremer/wao/web wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer wao-web/src/main/webapp/WEB-INF/content/obsmer
by bleny@users.forge.codelutin.com 08 Apr '14
by bleny@users.forge.codelutin.com 08 Apr '14
08 Apr '14
Author: bleny
Date: 2014-04-08 12:54:25 +0200 (Tue, 08 Apr 2014)
New Revision: 1863
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1863
Log:
refs #4487 contact creation from elligible boat
Added:
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CreateContactAction.java
Modified:
trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java
trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatDetails.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValues.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerBoatsServiceTest.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoSession.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsFilterValuesJsonAction.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java
trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp
trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp
Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java
===================================================================
--- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -87,7 +87,7 @@
sampleRowTopiaDao.toSampleRowHqlAndParametersBuilder(
filter.getElligibleForSampleRowsFilter()
);
- query.addWhereClause("b.topiaId IN (SELECT eb.boat.topiaId FROM fr.ifremer.wao.entity.ElligibleBoatImpl eb WHERE eb.sampleRow.topiaId IN ( select sr.topiaId " + sampleRowsQuery.getHql() + " ))",
+ query.addWhereClause("b.topiaId IN (select eb.boat.topiaId from fr.ifremer.wao.entity.ElligibleBoatImpl eb where (eb.globalActive is true and eb.companyActive is null or eb.companyActive is true) and eb.sampleRow.topiaId IN ( select sr.topiaId " + sampleRowsQuery.getHql() + " ))",
sampleRowsQuery.getHqlParameters());
}
Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java
===================================================================
--- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -30,9 +30,9 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.persistence.HqlAndParametersBuilder;
import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaQueryBuilderAddCriteriaOrRunQueryStep;
import org.nuiton.topia.persistence.pager.TopiaPagerBean;
import org.nuiton.util.PagerBeanUtil;
-import org.nuiton.topia.persistence.TopiaQueryBuilderAddCriteriaOrRunQueryStep;
import java.util.Collection;
import java.util.List;
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatDetails.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatDetails.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatDetails.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -23,18 +23,27 @@
import fr.ifremer.wao.entity.BoatInfos;
import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ElligibleBoat;
+import fr.ifremer.wao.entity.ObsProgram;
+import fr.ifremer.wao.entity.SampleRow;
+import org.apache.commons.lang3.BooleanUtils;
import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
public class BoatDetails implements Serializable {
private static final long serialVersionUID = 1L;
+ protected ObsProgram obsProgram;
+
protected BoatInfos boatInfos;
protected Contact mostRecentContact;
- public BoatDetails(BoatInfos boatInfos, Contact mostRecentContact) {
+ public BoatDetails(ObsProgram obsProgram, BoatInfos boatInfos, Contact mostRecentContact) {
+ this.obsProgram = obsProgram;
this.boatInfos = boatInfos;
this.mostRecentContact = mostRecentContact;
}
@@ -48,8 +57,21 @@
}
public boolean isNewContactCreatable() {
- boolean newContactCreatable = mostRecentContact != null
- && mostRecentContact.getContactState().isFinalState();
+ boolean newContactCreatable = boatInfos.getBoat().isActive()
+ && (mostRecentContact == null || mostRecentContact.getContactState().isFinalState());
return newContactCreatable;
}
+
+ public List<SampleRow> getElligibleForSampleRows() {
+ List<SampleRow> elligibleForSampleRows = new LinkedList<>();
+ for (ElligibleBoat elligibleBoat : boatInfos.getBoat().getElligibleBoat()) {
+ SampleRow sampleRow = elligibleBoat.getSampleRow();
+ if (sampleRow.getCompany().equals(boatInfos.getCompany()) && sampleRow.getObsProgram().equals(obsProgram)) {
+ if (elligibleBoat.isGlobalActive() || BooleanUtils.isNotFalse(elligibleBoat.getCompanyActive())) {
+ elligibleForSampleRows.add(sampleRow);
+ }
+ }
+ }
+ return elligibleForSampleRows;
+ }
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValues.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValues.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValues.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -29,6 +29,7 @@
import fr.ifremer.wao.entity.SampleRow;
import fr.ifremer.wao.entity.ShipOwner;
import fr.ifremer.wao.entity.TerrestrialLocation;
+import org.apache.commons.lang3.BooleanUtils;
import java.util.Locale;
import java.util.SortedSet;
@@ -91,7 +92,8 @@
for (ElligibleBoat elligibleBoat : boat.getElligibleBoat()) {
SampleRow sampleRow = elligibleBoat.getSampleRow();
- if (obsProgram.equals(sampleRow.getObsProgram())) {
+ // TODO brendan 08/04/14 vérifier que la sample row est bien associée à la société du coordinateur
+ if (obsProgram.equals(sampleRow.getObsProgram()) && (elligibleBoat.isGlobalActive() || BooleanUtils.isNotFalse(elligibleBoat.getCompanyActive()))) {
elligibleForSampleRowsFilterValues.addSampleRow(sampleRow);
}
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -23,6 +23,7 @@
import com.google.common.base.Charsets;
import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
import fr.ifremer.wao.BoatsFilter;
import fr.ifremer.wao.WaoTechnicalException;
import fr.ifremer.wao.entity.Boat;
@@ -47,6 +48,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import java.util.Set;
/**
* Created on 4/1/14.
@@ -59,22 +61,32 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ObsMerBoatsService.class);
- public BoatsFilterValues getBoatsFilterValues(BoatsFilter filter) {
+ public BoatsFilterValues getBoatsFilterValues(AuthenticatedWaoUser authenticatedWaoUser, BoatsFilter filter) {
BoatTopiaDao dao = getBoatDao();
+
+ // XXX brendan 07/04/14 ne pas inclure les lignes qui ne sont pas associées à un autre société que celle du coordinateur
+ Set<String> companyIds = null;
+ if (authenticatedWaoUser.isCoordinatorOrObserver()) {
+ companyIds = filter.getElligibleForSampleRowsFilter().getCompanyIds();
+ filter.getElligibleForSampleRowsFilter().setCompanyIds(ImmutableSet.of(authenticatedWaoUser.getCompany().getTopiaId()));
+ }
List<Boat> boats = dao.findAll(filter);
+ if (authenticatedWaoUser.isCoordinatorOrObserver()) {
+ filter.getElligibleForSampleRowsFilter().setCompanyIds(companyIds);
+ }
BoatsFilterValues boatsFilterValues = new BoatsFilterValues(serviceContext.getLocale(), filter.getObsProgram());
for (Boat boat : boats) {
- // TODO brendan 07/04/14 ne pas inclure les lignes qui ne sont pas associées à un autre société que celle du coordinateur
boatsFilterValues.addBoat(boat);
}
return boatsFilterValues;
}
- public ObsMerBoatsList getBoatsList(BoatsFilter filter,
+ public ObsMerBoatsList getBoatsList(AuthenticatedWaoUser authenticatedWaoUser,
+ BoatsFilter filter,
TopiaPagerBean queryPager) {
BoatTopiaDao dao = getBoatDao();
@@ -89,7 +101,7 @@
PaginationBean paginationBean = new PaginationBean(pager, 10);
- BoatsFilterValues boatsFilterValues = getBoatsFilterValues(filter);
+ BoatsFilterValues boatsFilterValues = getBoatsFilterValues(authenticatedWaoUser, filter);
ObsMerBoatsList obsMerBoatsList = new ObsMerBoatsList();
obsMerBoatsList.setBoats(boats);
@@ -159,7 +171,7 @@
long count = getContactDao().newQueryBuilder().addTopiaIdEquals(Contact.PROPERTY_BOAT, boatId).count();
- BoatDetails boatDetails = new BoatDetails(boatInfos, mostRecentContact);
+ BoatDetails boatDetails = new BoatDetails(obsProgram, boatInfos, mostRecentContact);
return boatDetails;
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -67,6 +67,7 @@
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@@ -691,4 +692,108 @@
dao.update(contact);
}
}
+
+ public Contact createContact(AuthenticatedWaoUser authenticatedWaoUser, String sampleRowId, String boatId) {
+
+ if (log.isInfoEnabled()) {
+ log.info(authenticatedWaoUser.getWaoUser() + " is creating a contact for " + sampleRowId + " and " + boatId);
+ }
+
+ UpdateContactCommand updateContactCommand = newUpdateContactCommand(authenticatedWaoUser, Optional.<String>absent());
+
+ Boat boat = getBoatDao().findByTopiaId(boatId);
+ Preconditions.checkState(boat.isActive(), "boat must be active");
+
+ SampleRow sampleRow = getSampleRowDao().findByTopiaId(sampleRowId);
+ ObsProgram obsProgram = sampleRow.getObsProgram();
+
+ WaoUser observer = authenticatedWaoUser.getWaoUser();
+ Contact mostRecentContactOrNull = getContactDao().findMostRecentContactOrNull(obsProgram, boatId, observer.getCompany().getTopiaId());
+ Preconditions.checkState(
+ mostRecentContactOrNull == null || mostRecentContactOrNull.getContactState().isFinalState(),
+ "contact already exists");
+
+ Date now = serviceContext.getNow();
+
+ Contact newContact = updateContactCommand.getContact();
+ newContact.setDataReliability(DataReliability.UNKNOWN);
+ newContact.setBoat(boat);
+ newContact.setMainObserver(observer);
+ newContact.setSampleRow(sampleRow);
+ newContact.setCreationDate(now);
+
+ // initial contact state depends on the program
+ if (obsProgram == ObsProgram.OBSMER) {
+ newContact.setContactState(ContactState.CONTACT_START);
+ } else if (obsProgram == ObsProgram.OBSVENTE) {
+ newContact.setContactState(ContactState.OBSERVATION_EXPECTED);
+ }
+
+ // we can suppose a new contact default values are the one
+ // expected in the sampling plan
+
+ if (newContact.getObsProgram() == ObsProgram.OBSVENTE) {
+ // we hope in this contact, user used expected sampling strategy
+ newContact.setSamplingStrategy(sampleRow.getSamplingStrategy());
+ }
+
+ // In the case of ObsVente, we may have a user who wants to create
+ // multiple contact for a same day. Here we try, to ease the input
+ // of data by trying to pre-fill some field using data given
+ // in a previous entered contact
+
+ if (newContact.getObsProgram() == ObsProgram.OBSVENTE) {
+ // try to pre-fill some field for user-experience
+
+ // let's try to find a recent similar contact
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(Contact.PROPERTY_OBS_PROGRAM_ORDINAL, newContact.getObsProgram().ordinal());
+ properties.put(Contact.PROPERTY_SAMPLE_ROW, sampleRow);
+ properties.put(Contact.PROPERTY_MAIN_OBSERVER, observer);
+
+ List<Contact> candidates = getContactDao().forProperties(properties).findAll();
+
+ Contact similarContact = null; // to be found among candidates
+ for (Contact candidate : candidates) {
+ if (DateUtil.getDifferenceInDays(candidate.getCreationDate(), now) <= 1) {
+ similarContact = candidate;
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ String logMessage;
+ if (similarContact == null) {
+ logMessage = "no similar contact found";
+ } else {
+ logMessage = "similar contact found to pre-fill values of contact : "
+ + similarContact.getTopiaId() + " boat = " + similarContact.getBoat().getName();
+ }
+ log.debug(logMessage);
+ }
+
+ if (similarContact != null) {
+ newContact.setObservationBeginDate(similarContact.getObservationBeginDate());
+ newContact.setObservationEndDate(similarContact.getObservationEndDate());
+ newContact.setTerrestrialLocation(similarContact.getTerrestrialLocation());
+ newContact.clearSecondaryObservers();
+ newContact.addAllSecondaryObservers(similarContact.getSecondaryObservers());
+ newContact.setDataInputDate(similarContact.getDataInputDate());
+ }
+ }
+
+ try {
+ save0(updateContactCommand);
+ } catch (NullSampleMonthException e) {
+ if (log.isErrorEnabled()) {
+ log.error("should never occur", e);
+ }
+ throw new WaoTechnicalException(e);
+ }
+
+ commit();
+
+ return newContact;
+
+ }
+
}
Modified: trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerBoatsServiceTest.java
===================================================================
--- trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerBoatsServiceTest.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerBoatsServiceTest.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -55,7 +55,7 @@
BoatsFilter filter = service.newBoatsFilter(fixtures.admin());
- BoatsFilterValues boatsFilterValues = service.getBoatsFilterValues(filter);
+ BoatsFilterValues boatsFilterValues = service.getBoatsFilterValues(fixtures.admin(), filter);
}
@@ -66,7 +66,7 @@
TopiaPagerBean pager = service.newBoatsPager(50);
- ObsMerBoatsList boatsList = service.getBoatsList(filter, pager);
+ ObsMerBoatsList boatsList = service.getBoatsList(fixtures.admin(), filter, pager);
}
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoSession.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoSession.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoSession.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -41,6 +41,8 @@
protected String sampleRowToHighlightId;
+ protected String contactToHighlightId;
+
public Collection<String> getMessages() {
if (messages == null) {
messages = Lists.newLinkedList();
@@ -83,4 +85,12 @@
public void setSampleRowToHighlightId(String sampleRowToHighlightId) {
this.sampleRowToHighlightId = sampleRowToHighlightId;
}
+
+ public void setContactToHighlightId(String contactToHighlightId) {
+ this.contactToHighlightId = contactToHighlightId;
+ }
+
+ public String getContactToHighlightId() {
+ return contactToHighlightId;
+ }
}
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -99,7 +99,7 @@
@Override
public String execute() {
- boatList = service.getBoatsList(filter, getPager());
+ boatList = service.getBoatsList(getAuthenticatedWaoUser(), filter, getPager());
return SUCCESS;
}
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsFilterValuesJsonAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsFilterValuesJsonAction.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsFilterValuesJsonAction.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -67,7 +67,7 @@
@Override
public String execute() {
- filterValues = service.getBoatsFilterValues(filter);
+ filterValues = service.getBoatsFilterValues(session.getAuthenticatedWaoUser(), filter);
return SUCCESS;
}
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -222,4 +222,8 @@
result = result.replaceAll("%", "%");
return result;
}
+
+ public String getContactToHighlightId() {
+ return session.getContactToHighlightId();
+ }
}
\ No newline at end of file
Added: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CreateContactAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CreateContactAction.java (rev 0)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CreateContactAction.java 2014-04-08 10:54:25 UTC (rev 1863)
@@ -0,0 +1,43 @@
+package fr.ifremer.wao.web.action.obsmer;
+
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.services.service.ObsMerContactsService;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.convention.annotation.Results;
+
+@Results({
+ @Result(name="success", type="redirectAction", params = { "actionName", "contacts" })
+})
+public class CreateContactAction extends WaoJspActionSupport {
+
+ protected ObsMerContactsService service;
+
+ protected String boatId;
+
+ protected String sampleRowId;
+
+ public void setService(ObsMerContactsService service) {
+ this.service = service;
+ }
+
+ public void setBoatId(String boatId) {
+ this.boatId = boatId;
+ }
+
+ public void setSampleRowId(String sampleRowId) {
+ this.sampleRowId = sampleRowId;
+ }
+
+ @Override
+ public String execute() {
+
+ Contact contact = service.createContact(getAuthenticatedWaoUser(), sampleRowId, boatId);
+
+ session.setContactToHighlightId(contact.getTopiaId());
+
+ return SUCCESS;
+
+ }
+
+}
Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp 2014-04-08 10:54:25 UTC (rev 1863)
@@ -140,11 +140,17 @@
<s:text name="wao.ui.boats.associatedLine"/>
</h3>
<ul>
- <s:iterator value="boatDetails.boatInfos.boat.elligibleBoat">
+ <s:iterator value="boatDetails.elligibleForSampleRows">
<li>
- <s:property value="sampleRow.code"/>
+ <s:property value="code"/>
<s:if test="boatDetails.newContactCreatable && authenticatedWaoUser.authorizedToCreateContact">
- <s:text name="wao.ui.contacts.createFromBoat"/>
+ <s:url action="create-contact" id="createContactUrl">
+ <s:param name="boatId" value="boatDetails.boatInfos.boat.topiaId"/>
+ <s:param name="sampleRowId" value="topiaId"/>
+ </s:url>
+ <s:a href="%{createContactUrl}">
+ <s:text name="wao.ui.contacts.createFromBoat"/>
+ </s:a>
</s:if>
</li>
</s:iterator>
Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp 2014-04-08 08:52:34 UTC (rev 1862)
+++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp 2014-04-08 10:54:25 UTC (rev 1863)
@@ -371,7 +371,7 @@
<tbody>
<s:iterator value="contacts" var="contact">
-<tr class="contact-row">
+<tr class="contact-row <s:if test="topiaId.equals(contactToHighlightId)"> highlight</s:if>">
<td>
<s:property value="%{formatDate(creationDate)}"/>
</td>
1
0
Author: bleny
Date: 2014-04-08 10:52:34 +0200 (Tue, 08 Apr 2014)
New Revision: 1862
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1862
Log:
set model version to 4.0
Modified:
trunk/wao-persistence/src/main/xmi/wao-model.zargo
Modified: trunk/wao-persistence/src/main/xmi/wao-model.zargo
===================================================================
(Binary files differ)
1
0
r1861 - trunk/wao-services/src/main/java/fr/ifremer/wao/services/service
by tchemit@users.forge.codelutin.com 07 Apr '14
by tchemit@users.forge.codelutin.com 07 Apr '14
07 Apr '14
Author: tchemit
Date: 2014-04-07 19:44:45 +0200 (Mon, 07 Apr 2014)
New Revision: 1861
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1861
Log:
refs #4487 recompute sample rows tides when contact is modified or created
Removed:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactStatus.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/NullSampleMonthException.java
Modified:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
Deleted: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactStatus.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactStatus.java 2014-04-07 17:13:57 UTC (rev 1860)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactStatus.java 2014-04-07 17:44:45 UTC (rev 1861)
@@ -1,350 +0,0 @@
-/*
- * #%L
- * Wao :: Business
- * *
- * $Id$
- * $HeadURL: https://svn.codelutin.com/wao/tags/wao-3.4.1/wao-business/src/main/java/fr/… $
- * %%
- * Copyright (C) 2009 - 2010 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero 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 Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-package fr.ifremer.wao.services.service;
-
-import fr.ifremer.wao.entity.Contact;
-import fr.ifremer.wao.entity.ContactState;
-import fr.ifremer.wao.entity.SampleMonth;
-import fr.ifremer.wao.entity.SampleMonthTopiaDao;
-import fr.ifremer.wao.entity.SampleRow;
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.persistence.TopiaNoResultException;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * //FIXME a revoir...
- * This class is used to know status changed between an old contact and a new
- * one (new change to apply). There is three different cases for constructor
- * parameters :
- * <ul>
- * <li>CREATE : olContact is null and newContact is defined</li>
- * <li>UPDATE : both oldContact and newContact are defined</li>
- * <li>DELETE : oldContact is defined and newContact is null</li>
- * </ul>
- * Three fields of contact are considered to be changed for sampleMonth calcul
- * on tides value :
- * <ul>
- * <li>
- * STATE : check the change on {@link ContactState#OBSERVATION_DONE} state.
- * Use {@link #isContactDoneChanged() } method to check the change.
- * This change is important to manage estimated tides value on sampleMonth
- * referenced by the contact retrieve with {@link #getSampleMonth()}
- * </li>
- * <li>
- * VALIDATION : check the change on validationCompany and validationProgram.
- * Use {@link #isContactValidateChanged() } method to check the change.
- * This change is important to manage real tides value on sampleMonth
- * referenced by the contact retrieve with {@link #getSampleMonth()}
- * </li>
- * <li>
- * TIDE BEGIN DATE : check the change on tideBeginDate month.
- * Use {@link #isTideBeginDateMonthChanged() } method to check the change.
- * This change is important to manage both estimated and real tides value on
- * the old sampleMonth referenced by the old contact retrieve with
- * {@link #getOldSampleMonth()}
- * </ul>
- * <p/>
- * <p/>
- * Created: 19 avr. 2010
- *
- * @author fdesbois
- */
-public class ContactStatus {
-
- /** Logger. */
- private static final Log logger = LogFactory.getLog(ContactStatus.class);
-
- protected Contact oldContact;
-
- protected Contact newContact;
-
- protected SampleRow sampleRow;
-
- protected SampleMonth oldSampleMonth;
-
- protected SampleMonth sampleMonth;
-
- protected final SampleMonthTopiaDao dao;
-
- public ContactStatus(SampleMonthTopiaDao dao,
- Contact old,
- Contact contact) {
- this.dao = dao;
- this.oldContact = old;
- this.newContact = contact;
- this.sampleRow = contact != null ?
- newContact.getSampleRow() : oldContact.getSampleRow();
- }
-
- public boolean isOldContactValidate() {
- return isContactValidate(Context.OLD);
- }
-
- public boolean isNewContactValidate() {
- return isContactValidate(Context.NEW);
- }
-
- /**
- * Return true if oldContact validate is not the same as newContact
- * validate.
- *
- * @return true if contact validate has changed.
- * @see #isContactValidate(Context)
- */
- public boolean isContactValidateChanged() {
- return isOldContactValidate() != isNewContactValidate();
- }
-
- public boolean isOldContactDone() {
- return isContactDone(Context.OLD);
- }
-
- public boolean isNewContactDone() {
- return isContactDone(Context.NEW);
- }
-
- /**
- * Return true if oldContact state is not the same as newContact state.
- * Check only for {@link ContactState#OBSERVATION_DONE} changed.
- *
- * @return true if contact state has changed.
- * @see #isContactDone(Context)
- */
- public boolean isContactDoneChanged() {
- return isOldContactDone() != isNewContactDone();
- }
-
- /**
- * Return true if tideBeginDate has changed its month between oldContact
- * and newContact. The both oldContact and newContact dates must be not
- * null.
- *
- * @return true if tideBeginDate status changed
- */
- public boolean isTideBeginDateMonthChanged() {
-
- if (oldContact == null || newContact == null) {
- return false;
- }
- DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
- Date oldTideBeginDate = oldContact.getObservationBeginDate();
- Date newTideBeginDate = newContact.getObservationBeginDate();
-
- logger.debug("old : " + oldTideBeginDate + ", new : " + newTideBeginDate);
-
- // Only if old not null and new not null
- if (oldTideBeginDate != null && newTideBeginDate != null) {
- String oldTideBeginStr = dateFormat.format(oldTideBeginDate);
- String newTideBeginStr = dateFormat.format(newTideBeginDate);
- return !oldTideBeginStr.equals(newTideBeginStr);
- }
- return false;
- }
-
- public SampleRow getSampleRow() {
- return sampleRow;
- }
-
- /**
- * Retrive the old SampleMonth referenced by the tideBeginDate of the
- * old contact.
- *
- * @return the sampleMonth found or throw NullSampleMonthException
- * @throws NullSampleMonthException
- */
- public SampleMonth getOldSampleMonth()
- throws NullSampleMonthException {
- if (oldSampleMonth == null) {
- oldSampleMonth = getExistingSampleMonth(Context.OLD);
- }
- return oldSampleMonth;
- }
-
- /**
- * Retrive the SampleMonth referenced by the tideBeginDate of the
- * new contact.
- *
- * @return the sampleMonth found or throw NullSampleMonthException
- * @throws NullSampleMonthException
- */
- public SampleMonth getSampleMonth()
- throws NullSampleMonthException {
- if (sampleMonth == null) {
- sampleMonth = getExistingSampleMonth(Context.NEW);
- }
- return sampleMonth;
- }
-
- protected enum Context {
- OLD, NEW
- }
-
- /**
- * Retrieve existing sampleMonth corresponding to the contact. The
- * sampleMonth must match with contact sampleRow, also the tideBeginDate
- * (day) of the contact must match the sampleMonth periodDate (month).
- *
- * @param context OLD or NEW
- * @return the sampleMonth found if exists, or NullSampleMonthException
- * will be thrown
- * @throws NullSampleMonthException if month was not found
- */
- protected SampleMonth getExistingSampleMonth(Context context) throws NullSampleMonthException {
-
- // Reference date for query
- Date tideBeginDate = null;
-
- switch (context) {
- case OLD:
- tideBeginDate = oldContact.getObservationBeginDate();
- break;
- // newContact may be null in CREATE case, so we use the previous
- // one
- case NEW:
- if (newContact != null &&
- newContact.getObservationBeginDate() != null) {
- tideBeginDate = newContact.getObservationBeginDate();
- } else {
- tideBeginDate = oldContact.getObservationBeginDate();
- }
- }
-
- SampleMonth result;
- try {
- result = dao.getExistingSampleMonth(sampleRow, tideBeginDate);
- } catch (TopiaNoResultException e) {
- throw new NullSampleMonthException(
- "Aucun mois correspondant pour" +
- " la ligne du plan d'échantillonnage " +
- sampleRow.getCode() +
- " et la date de début de marée du contact " +
- tideBeginDate
- );
- }
- return result;
- }
-
- /**
- * Return true if contact is validate depends on {@code context}. The
- * oldContact validation will be tested for an {@link Context#OLD} context
- * and the newContact will be tested for a {@link Context#NEW} context.
- * The validation is tested as validationCompany must be TRUE and
- * validationProgram must be not FALSE (otherwise TRUE or NULL).
- *
- * @param context to check the good contact
- * @return true depends on validationCompany and validationProgram of
- * the contact (oldContact or newContact depends on context in argument).
- */
- protected boolean isContactValidate(Context context) {
- Contact contact = context == Context.OLD ? oldContact : newContact;
-
- Boolean validationCompany = contact != null ?
- contact.getValidationCompany() : null;
- Boolean validationProgram = contact != null ?
- contact.getValidationProgram() : null;
-
- if (logger.isTraceEnabled()) {
- logger.trace(context + " validation company = " + validationCompany
- + " _ validation program = " + validationProgram);
- }
-
- boolean contactValidate =
- BooleanUtils.isTrue(validationCompany) &&
- BooleanUtils.isNotFalse(validationProgram);
- return contactValidate;
- }
-
- public boolean isRefused() {
- Boolean oldValidationProgram = oldContact != null ?
- oldContact.getValidationProgram() : null;
- Boolean newValidationProgram = newContact != null ?
- newContact.getValidationProgram() : null;
-
- return BooleanUtils.isNotFalse(oldValidationProgram) &&
- BooleanUtils.isFalse(newValidationProgram);
- }
-
- public boolean isNoMoreRefused() {
- Boolean oldValidationProgram = oldContact != null ?
- oldContact.getValidationProgram() : null;
- Boolean newValidationProgram = newContact != null ?
- newContact.getValidationProgram() : null;
-
- return BooleanUtils.isFalse(oldValidationProgram) &&
- BooleanUtils.isNotFalse(newValidationProgram);
- }
-
- /**
- * Return true if contact state is {@link ContactState#OBSERVATION_DONE}
- * depends on {@code context}. To check oldContact state, use
- * {@link Context#OLD} and to check newContact state, use
- * {@link Context#NEW}. A null contact will return false.
- *
- * @param context to check the good contact
- * @return true if the contact state is {@link ContactState#OBSERVATION_DONE}
- */
- protected boolean isContactDone(Context context) {
- Contact contact = context == Context.OLD ? oldContact : newContact;
- ContactState contactState = contact != null ?
- contact.getContactState() : null;
-
- if (logger.isTraceEnabled()) {
- logger.trace(context + " contact state = " + contactState);
- }
- boolean contactDone = ContactState.OBSERVATION_DONE.equals(contactState);
- return contactDone;
- }
-
- @Override
- public String toString() {
- DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
- String oldMonth = oldContact != null &&
- oldContact.getObservationBeginDate() != null ?
- dateFormat.format(oldContact.getObservationBeginDate()) : "";
-
- String newMonth = newContact != null &&
- newContact.getObservationBeginDate() != null ?
- dateFormat.format(newContact.getObservationBeginDate()) : "";
-
- StringBuilder builder =
- new StringBuilder("\nContactStatus : VALIDATE :: ").
- append("oldValidate = ").append(isOldContactValidate()).
- append(" _ newValidate = ").append(isNewContactValidate()).
- append("\nContactStatus : CONTACT_STATE :: ").
- append("oldDone = ").append(isOldContactDone()).
- append(" _ newDone = ").append(isNewContactDone()).
- append("\nContactStatus : TIDE_BEGIN_DATE :: ").
- append("oldMonth = ").append(oldMonth).
- append(" _ newMonth = ").append(newMonth).
- append(" _ changed = ").append(isTideBeginDateMonthChanged());
-
- return builder.toString();
- }
-}
Deleted: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/NullSampleMonthException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/NullSampleMonthException.java 2014-04-07 17:13:57 UTC (rev 1860)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/NullSampleMonthException.java 2014-04-07 17:44:45 UTC (rev 1861)
@@ -1,37 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-/*
- * #%L
- * Wao :: Services
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero 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 Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import fr.ifremer.wao.WaoException;
-
-/**
- * This exception is used to indicate that a problem is occured during
- * retrieving sampleMonth corresponding to a contact.
- */
-public final class NullSampleMonthException extends WaoException {
-
- private static final long serialVersionUID = 1L;
-
- public NullSampleMonthException(String message) {
- super(message);
- }
-}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-07 17:13:57 UTC (rev 1860)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-07 17:44:45 UTC (rev 1861)
@@ -41,7 +41,6 @@
import fr.ifremer.wao.entity.ObsProgram;
import fr.ifremer.wao.entity.ObservedDataControl;
import fr.ifremer.wao.entity.SampleMonth;
-import fr.ifremer.wao.entity.SampleMonths;
import fr.ifremer.wao.entity.SampleRow;
import fr.ifremer.wao.entity.WaoUser;
import fr.ifremer.wao.entity.WaoUserTopiaDao;
@@ -402,8 +401,6 @@
// Pass validation controls
Contact contact = updateContactCommand.getContact();
- Locale l = serviceContext.getLocale();
-
Company company = contact.getSampleRow().getCompany();
WaoUser mainObserver = contact.getMainObserver();
@@ -625,9 +622,10 @@
throw new IllegalDeletionException(allUsages);
}
- //FIXME
-// updateSampleMonthTidesValue(contact, null, true);
+ ObsMerSamplingPlanService samplingPlanService = newService(ObsMerSamplingPlanService.class);
+ samplingPlanService.recomputeSampleRowEstimatedAndRealTides(contact.getSampleRow());
+
dao.delete(contact);
commit();
@@ -640,6 +638,8 @@
ContactTopiaDao dao = getContactDao();
+ ObsMerSamplingPlanService samplingPlanService = newService(ObsMerSamplingPlanService.class);
+
if (updateContactCommand.isCreation()) {
//Update the elligible boat depends on contact creation. The
@@ -659,19 +659,17 @@
}
elligible.setCompanyActive(Boolean.TRUE);
- //FIXME Recompute for the hole sample row?
-// updateSampleMonthTidesValue(null, contact, true);
-
if (contact.getCreationDate() == null) {
contact.setCreationDate(serviceContext.getNow());
}
+ samplingPlanService.recomputeSampleRowEstimatedAndRealTides(contact.getSampleRow());
+
dao.create(contact);
} else {
- //FIXME Recompute for the hole sample row?
-// updateSampleMonthTidesValue(contactFound, contact, true);
+ samplingPlanService.recomputeSampleRowEstimatedAndRealTides(contact.getSampleRow());
if (updateContactCommand.isMammalsInfosChanged()) {
@@ -689,133 +687,8 @@
getEmailService().send(email);
}
+
dao.update(contact);
}
}
-
- /**
- * Update the SampleMonth data for tidesValue (estimated and real) from
- * {@code contact} compared to its old state {@code oldContact}. The
- * estimated is update when contact state {@link ContactState#OBSERVATION_DONE}
- * is changed. The real is update when contact validationCompany is changed.
- * The {@code calculateReal} flag determines if the real tides has to be
- * calculated or not. Three cases :
- * <ul>
- * <li>CREATE : {@code oldContact} = null and {@code contact} is defined</li>
- * <li>UPDATE : both {@code oldContact} and {@code contact} are defined</li>
- * <li>DELETE : {@code oldContact} is defined and {@code contact} = null</li>
- * </ul>
- * <p>
- * <strong>Estimated Tides value</strong> = nbContacts with OBSERVATION_DONE
- * state and not refused by program (validationProgram != FALSE)
- * </p>
- * <p>
- * <strong>Real Tides value</strong> = nbContacts accepted by company
- * (validationCompany = TRUE) and not refused by program
- * (validationProgram != FALSE)
- * </p>
- *
- * @param oldContact old state of the contact
- * @param contact changed can be null for delete case
- * @param calculateReal to calculate real tides value
- * @throws NullSampleMonthException if SampleMonth can't be found
- */
- protected void updateSampleMonthTidesValue(Contact oldContact,
- Contact contact,
- boolean calculateReal) throws NullSampleMonthException {
-
- if (oldContact == null && contact == null) {
- throw new IllegalArgumentException("Both contact and oldContact" +
- " can't be null to update sampleMonth tides value");
- }
-
- // Instantiate contact status which provide status on oldContact and
- // contact changes
- ContactStatus status = new ContactStatus(getSampleMonthDao(), oldContact, contact);
-
- if (log.isDebugEnabled()) {
- log.debug(status.toString());
- }
-
- // Month of TideBeginDate has changed, must decrement values on
- // old sampleMonth
- boolean tideBeginDateChanged = false;
- if (oldContact != null && contact != null &&
- status.isTideBeginDateMonthChanged()) {
-
- tideBeginDateChanged = status.isTideBeginDateMonthChanged();
-
- // Retrieve oldMonth from status
- try {
- SampleMonth oldMonth = status.getOldSampleMonth();
-
- // Apply changes on oldMonth
- if (status.isOldContactValidate()) {
- // decrement real tides
- SampleMonths.addRealTideTime(oldMonth, -1);
- }
- // Decrement estimated only if old state is OBSERVATION_DONE
- // and old validationProgram is NOT FALSE
- // the estimated value has already been decremented during
- // refused
- if (status.isOldContactDone() && BooleanUtils.isNotFalse(
- oldContact.getValidationProgram())) {
- // decrement estimated tides
- SampleMonths.addEstimatedTideTime(oldMonth, -1);
- }
-
- // Catch the null exception, only a warning if the oldSampleMonth is
- // not found
- } catch (NullSampleMonthException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Error on retrieve old sampleMonth", eee);
- }
- }
- }
-
- ContactState currentState = contact != null ?
- contact.getContactState() : oldContact.getContactState();
-
- // Validation of contact has changed in status, modify realTides
- // Only calculate real for a currentState equals to OBSERVATION_DONE
- if (calculateReal && ContactState.OBSERVATION_DONE.equals(currentState) &&
- (status.isContactValidateChanged() || tideBeginDateChanged)) {
-
- SampleMonth sampleMonth = status.getSampleMonth();
-
- if (status.isNewContactValidate()) {
- // increment real tides
- SampleMonths.addRealTideTime(sampleMonth, 1);
- // validationProgram becomes not FALSE, estimatedTides must be
- // incremented
- if (status.isNoMoreRefused()) {
- SampleMonths.addEstimatedTideTime(sampleMonth, 1);
- }
- // never decrement if tideBeginDate has changed
- } else if (status.isOldContactValidate() && !tideBeginDateChanged) {
- // decrement real tides
- SampleMonths.addRealTideTime(sampleMonth, -1);
- // validationProgram becomes FALSE, estimatedTides must be
- // decremented
- if (status.isRefused()) {
- SampleMonths.addEstimatedTideTime(sampleMonth, -1);
- }
- }
- }
-
- // ContactState of contact has changed in status, modify estimatedTides
- if (status.isContactDoneChanged() || tideBeginDateChanged) {
-
- SampleMonth sampleMonth = status.getSampleMonth();
-
- if (status.isNewContactDone()) {
- // increment estimated tides
- SampleMonths.addEstimatedTideTime(sampleMonth, 1);
- // never decrement if tideBeginDate has changed
- } else if (status.isOldContactDone() && !tideBeginDateChanged) {
- // decrement estimated tides
- SampleMonths.addEstimatedTideTime(sampleMonth, -1);
- }
- }
- }
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-04-07 17:13:57 UTC (rev 1860)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-04-07 17:44:45 UTC (rev 1861)
@@ -702,4 +702,55 @@
commit();
}
+
+ public void recomputeSampleRowEstimatedAndRealTides(SampleRow sampleRow) {
+
+ //----
+ // Reset des tides de la ligne
+ //----
+
+ for (SampleMonth sampleMonth : sampleRow.getSampleMonth()) {
+ sampleMonth.setEstimatedTidesValue(0);
+ sampleMonth.setRealTidesValue(0);
+ }
+
+ //----
+ // Recuperation de tous les contacts de la ligne
+ //----
+
+ ContactsFilter contactFilter = new ContactsFilter(sampleRow.getObsProgram());
+
+ contactFilter.setFilterOnObservationBeginDate(true);
+ contactFilter.getSampleRowFilter().setSampleRowIds(Sets.newHashSet(sampleRow.getTopiaId()));
+
+ contactFilter.setContactStates(ImmutableSet.of(ContactState.OBSERVATION_DONE));
+ // on exclue les contacts qui sont invalidés par le programme
+ contactFilter.setProgramAcceptations(Sets.newHashSet(true, null));
+ // on exclue les contacts invalidés par la société
+ contactFilter.setCompanyAcceptations(Sets.newHashSet(true, null));
+
+ Collection<Contact> contacts = getContactDao().findAll(contactFilter);
+
+ //----
+ // Recalcul des tides
+ //----
+
+ for (Contact contact : contacts) {
+
+ Boolean validationProgram = contact.getValidationProgram();
+ Boolean validationCompany = contact.getValidationCompany();
+
+ boolean accepted = validationCompany != null || validationProgram != null;
+
+ Date observationBeginDate = contact.getObservationBeginDate();
+
+ SampleMonth month = sampleRow.getSampleMonth(observationBeginDate);
+
+ if (accepted) {
+ month.setRealTidesValue(month.getRealTidesValue() + 1);
+ } else {
+ month.setEstimatedTidesValue(month.getEstimatedTidesValue() + 1);
+ }
+ }
+ }
}
1
0
r1860 - in trunk: wao-services/src/main/java/fr/ifremer/wao/services/service wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer
by tchemit@users.forge.codelutin.com 07 Apr '14
by tchemit@users.forge.codelutin.com 07 Apr '14
07 Apr '14
Author: tchemit
Date: 2014-04-07 19:13:57 +0200 (Mon, 07 Apr 2014)
New Revision: 1860
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1860
Log:
refs #4487 fix some exception names and api
Added:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsException.java
Removed:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java
Modified:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java 2014-04-07 17:10:27 UTC (rev 1859)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java 2014-04-07 17:13:57 UTC (rev 1860)
@@ -14,14 +14,14 @@
private static final long serialVersionUID = 1L;
- protected Date now;
+ protected Date today;
- public ContactDataInputDateAfterTodayException(Contact contact, Date now) {
+ public ContactDataInputDateAfterTodayException(Contact contact, Date today) {
super(contact);
- this.now = now;
+ this.today = today;
}
- public Date getNow() {
- return now;
+ public Date getToday() {
+ return today;
}
}
Deleted: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java 2014-04-07 17:10:27 UTC (rev 1859)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java 2014-04-07 17:13:57 UTC (rev 1860)
@@ -1,18 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-import fr.ifremer.wao.entity.Contact;
-
-/**
- * Created on 4/7/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class InvalidContactMainObserverException extends WaoContactValidationException {
-
- private static final long serialVersionUID = 1L;
-
- public InvalidContactMainObserverException(Contact contact, String message) {
- super(contact);
- }
-}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java 2014-04-07 17:10:27 UTC (rev 1859)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java 2014-04-07 17:13:57 UTC (rev 1860)
@@ -18,7 +18,7 @@
protected WaoUser observer;
- public MismatchContactMainObserverCompanyException(Contact contact, Company company, WaoUser observer) {
+ public MismatchContactMainObserverCompanyException(Contact contact, WaoUser observer, Company company) {
super(contact);
this.company = company;
this.observer = observer;
Copied: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsException.java (from rev 1859, trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java)
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsException.java 2014-04-07 17:13:57 UTC (rev 1860)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactNbObservantsException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactNbObservantsException(Contact contact) {
+ super(contact);
+ }
+
+}
Deleted: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java 2014-04-07 17:10:27 UTC (rev 1859)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java 2014-04-07 17:13:57 UTC (rev 1860)
@@ -1,40 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-/*
- * #%L
- * Wao :: Services
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero 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 Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import fr.ifremer.wao.entity.Contact;
-
-/**
- * Created on 4/4/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class MissingContactNbObservantsForObservationDoneStateException extends WaoContactValidationException {
-
- private static final long serialVersionUID = 1L;
-
- public MissingContactNbObservantsForObservationDoneStateException(Contact contact) {
- super(contact);
- }
-
-}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-07 17:10:27 UTC (rev 1859)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-07 17:13:57 UTC (rev 1860)
@@ -282,7 +282,7 @@
} catch (UnwantedContactContactStateMotifException e) {
String message = l(l, "wao.import.contact.failure.unwantedContactStateMotif");
throw new ImportErrorException(message);
- } catch (MissingContactNbObservantsForObservationDoneStateException e) {
+ } catch (MissingContactNbObservantsException e) {
String state = WaoUtils.l(l, e.getContact().getContactState());
String message = l(l, "wao.import.contact.failure.missingObserver", state);
throw new ImportErrorException(message);
@@ -372,7 +372,7 @@
MissingContactCommentException,
MissingContactObservationBeginDateException,
MissingContactObservationEndDateException,
- MissingContactNbObservantsForObservationDoneStateException,
+ MissingContactNbObservantsException,
MissingContactStateMotifException,
UnwantedContactContactStateMotifException,
MissingContactObservedDataControlException,
@@ -419,7 +419,7 @@
boolean observerWorksForCompanyInSampleRow = mainObserver.getCompany().equals(company);
if (!observerWorksForCompanyInSampleRow) {
- throw new MismatchContactMainObserverCompanyException(contact, company, mainObserver);
+ throw new MismatchContactMainObserverCompanyException(contact, mainObserver, company);
}
}
@@ -532,7 +532,7 @@
throw new MissingContactObservationEndDateException(contact);
}
if (contact.getNbObservants() == 0) {
- throw new MissingContactNbObservantsForObservationDoneStateException(contact);
+ throw new MissingContactNbObservantsException(contact);
}
break;
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-04-07 17:10:27 UTC (rev 1859)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-04-07 17:13:57 UTC (rev 1860)
@@ -41,7 +41,7 @@
import fr.ifremer.wao.services.service.MissingContactDataInputDateException;
import fr.ifremer.wao.services.service.MissingContactDataReliabilityException;
import fr.ifremer.wao.services.service.MissingContactMainObserverException;
-import fr.ifremer.wao.services.service.MissingContactNbObservantsForObservationDoneStateException;
+import fr.ifremer.wao.services.service.MissingContactNbObservantsException;
import fr.ifremer.wao.services.service.MissingContactObservationBeginDateException;
import fr.ifremer.wao.services.service.MissingContactObservationEndDateException;
import fr.ifremer.wao.services.service.MissingContactObservedDataControlException;
@@ -113,7 +113,7 @@
} catch (UnwantedContactContactStateMotifException e) {
addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.unwantedContactStateMotif"));
- } catch (MissingContactNbObservantsForObservationDoneStateException e) {
+ } catch (MissingContactNbObservantsException e) {
String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObserver", state));
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-04-07 17:10:27 UTC (rev 1859)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-04-07 17:13:57 UTC (rev 1860)
@@ -41,14 +41,13 @@
import fr.ifremer.wao.services.service.MissingContactDataInputDateException;
import fr.ifremer.wao.services.service.MissingContactDataReliabilityException;
import fr.ifremer.wao.services.service.MissingContactMainObserverException;
-import fr.ifremer.wao.services.service.MissingContactNbObservantsForObservationDoneStateException;
+import fr.ifremer.wao.services.service.MissingContactNbObservantsException;
import fr.ifremer.wao.services.service.MissingContactObservationBeginDateException;
import fr.ifremer.wao.services.service.MissingContactObservationEndDateException;
import fr.ifremer.wao.services.service.MissingContactObservedDataControlException;
import fr.ifremer.wao.services.service.MissingContactRestitutionException;
import fr.ifremer.wao.services.service.MissingContactStateMotifException;
import fr.ifremer.wao.services.service.UnwantedContactContactStateMotifException;
-import fr.ifremer.wao.services.service.WaoContactValidationException;
import fr.ifremer.wao.services.service.ObsMerContactsService;
import fr.ifremer.wao.services.service.UpdateContactCommand;
import fr.ifremer.wao.web.WaoJsonActionSupport;
@@ -173,7 +172,7 @@
} catch (UnwantedContactContactStateMotifException e) {
errorMessage = t("wao.import.contact.failure.unwantedContactStateMotif");
- } catch (MissingContactNbObservantsForObservationDoneStateException e) {
+ } catch (MissingContactNbObservantsException e) {
String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
errorMessage = t("wao.import.contact.failure.missingObserver", state);
1
0
r1859 - trunk/wao-web/src/main/webapp/WEB-INF/decorators
by tchemit@users.forge.codelutin.com 07 Apr '14
by tchemit@users.forge.codelutin.com 07 Apr '14
07 Apr '14
Author: tchemit
Date: 2014-04-07 19:10:27 +0200 (Mon, 07 Apr 2014)
New Revision: 1859
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1859
Log:
refs #4487 remove bad link
Modified:
trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp
Modified: trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-04-07 17:09:47 UTC (rev 1858)
+++ trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-04-07 17:10:27 UTC (rev 1859)
@@ -178,7 +178,7 @@
<s:actionerror theme="bootstrap" />
<s:actionmessage theme="bootstrap" />
<s:fielderror theme="bootstrap" />
- <div id="notifications"><a href="#notifications"></a></div>
+ <div id="notifications"></div>
<decorator:body />
</main>
1
0
r1858 - in trunk: wao-services/src/main/java/fr/ifremer/wao/services/service wao-services/src/main/resources/i18n wao-web/src/main/java/fr/ifremer/wao/web/action wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer wao-web/src/main/resources/i18n
by tchemit@users.forge.codelutin.com 07 Apr '14
by tchemit@users.forge.codelutin.com 07 Apr '14
07 Apr '14
Author: tchemit
Date: 2014-04-07 19:09:47 +0200 (Mon, 07 Apr 2014)
New Revision: 1858
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1858
Log:
refs #4487 validation of a contact + improve import i18n message in exception
Added:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateAfterTodayException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateBeforeBeginDateException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactRestitutionDateBeforeDataInputDateException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/DuplicatedContactMainObserverInSecondaryObserversException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactObservationBeginDateException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactSecondaryObserverCompanyException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentAdminException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataInputDateException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataReliabilityException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactMainObserverException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationBeginDateException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationEndDateException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservedDataControlException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactRestitutionException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactStateMotifException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UnwantedContactContactStateMotifException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoContactValidationException.java
Removed:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactNotValidException.java
Modified:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalDeletionException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java
trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties
trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractImportCsvAction.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java
trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties
trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ContactDataInputDateAfterObservationEndDateException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public ContactDataInputDateAfterObservationEndDateException(Contact contact) {
+ super(contact);
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,27 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+import java.util.Date;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ContactDataInputDateAfterTodayException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Date now;
+
+ public ContactDataInputDateAfterTodayException(Contact contact, Date now) {
+ super(contact);
+ this.now = now;
+ }
+
+ public Date getNow() {
+ return now;
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactNotValidException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactNotValidException.java 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactNotValidException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -1,41 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-/*
- * #%L
- * Wao :: Services
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero 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 Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import fr.ifremer.wao.WaoException;
-
-/**
- * Quand un contact n'est pas valide (lors d'une création ou d'un import).
- * <p/>
- * Created on 4/4/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class ContactNotValidException extends WaoException {
-
- private static final long serialVersionUID = 1L;
-
- public ContactNotValidException(String message) {
- super(message);
- }
-}
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateAfterTodayException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateAfterTodayException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateAfterTodayException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,27 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+import java.util.Date;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ContactObservationEndDateAfterTodayException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Date today;
+
+ public ContactObservationEndDateAfterTodayException(Contact contact, Date today) {
+ super(contact);
+ this.today = today;
+ }
+
+ public Date getToday() {
+ return today;
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateAfterTodayException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateBeforeBeginDateException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateBeforeBeginDateException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateBeforeBeginDateException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ContactObservationEndDateBeforeBeginDateException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public ContactObservationEndDateBeforeBeginDateException(Contact contact) {
+ super(contact);
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateBeforeBeginDateException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactRestitutionDateBeforeDataInputDateException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactRestitutionDateBeforeDataInputDateException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactRestitutionDateBeforeDataInputDateException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ContactRestitutionDateBeforeDataInputDateException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public ContactRestitutionDateBeforeDataInputDateException(Contact contact) {
+ super(contact);
+ }
+
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactRestitutionDateBeforeDataInputDateException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/DuplicatedContactMainObserverInSecondaryObserversException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/DuplicatedContactMainObserverInSecondaryObserversException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/DuplicatedContactMainObserverInSecondaryObserversException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class DuplicatedContactMainObserverInSecondaryObserversException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public DuplicatedContactMainObserverInSecondaryObserversException(Contact contact) {
+ super(contact);
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/DuplicatedContactMainObserverInSecondaryObserversException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalDeletionException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalDeletionException.java 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalDeletionException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -40,6 +40,8 @@
*/
public class IllegalDeletionException extends WaoException {
+ private static final long serialVersionUID = 1L;
+
protected static final ImmutableMap<Class<? extends TopiaEntity>, String> ENTITIES_I18N_KEYS =
ImmutableMap.of(
Contact.class, I18n.n("wao.action.delete.failure.attachedContacts"),
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -25,6 +25,8 @@
import org.nuiton.csv.ImportRuntimeException;
import org.nuiton.i18n.I18n;
+import java.util.Locale;
+
/**
* Une erreur est survenue lors d'un import CSV.
*/
@@ -32,24 +34,22 @@
private static final long serialVersionUID = 1L;
- //FIXME ? Why?
- protected static final String MESSAGE = I18n.t("wao.import.failure");
-
public ImportErrorException(ImportRuntimeException e) {
super(e);
}
- public ImportErrorException(ContactNotValidException e) {
- super(e);
+ public ImportErrorException(String message) {
+ super(message);
}
- public ImportErrorException(NullSampleMonthException e) {
- super(e);
+ public String getMessage(Locale locale) {
+ String causeMessage;
+ if (getCause() == null) {
+ causeMessage = getMessage();
+ } else {
+ causeMessage = getCause().getMessage();
+ }
+ return I18n.l(locale, "wao.import.failure", causeMessage);
}
- @Override
- public String getMessage() {
- return MESSAGE + " " + getCause().getMessage();
- }
-
}
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class InvalidContactMainObserverException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public InvalidContactMainObserverException(Contact contact, String message) {
+ super(contact);
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactObservationBeginDateException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactObservationBeginDateException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactObservationBeginDateException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class InvalidContactObservationBeginDateException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public InvalidContactObservationBeginDateException(Contact contact) {
+ super(contact);
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactObservationBeginDateException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,34 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.WaoUser;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MismatchContactMainObserverCompanyException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Company company;
+
+ protected WaoUser observer;
+
+ public MismatchContactMainObserverCompanyException(Contact contact, Company company, WaoUser observer) {
+ super(contact);
+ this.company = company;
+ this.observer = observer;
+ }
+
+ public Company getCompany() {
+ return company;
+ }
+
+ public WaoUser getObserver() {
+ return observer;
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactSecondaryObserverCompanyException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactSecondaryObserverCompanyException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactSecondaryObserverCompanyException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,34 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.WaoUser;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MismatchContactSecondaryObserverCompanyException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ protected WaoUser observer;
+
+ protected Company company;
+
+ public MismatchContactSecondaryObserverCompanyException(Contact contact, WaoUser observer, Company company) {
+ super(contact);
+ this.observer = observer;
+ this.company = company;
+ }
+
+ public WaoUser getObserver() {
+ return observer;
+ }
+
+ public Company getCompany() {
+ return company;
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactSecondaryObserverCompanyException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentAdminException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentAdminException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentAdminException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactCommentAdminException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactCommentAdminException(Contact contact) {
+ super(contact);
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentAdminException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactCommentException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactCommentException(Contact contact) {
+ super(contact);
+ }
+
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataInputDateException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataInputDateException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataInputDateException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactDataInputDateException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactDataInputDateException(Contact contact) {
+ super(contact);
+ }
+
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataInputDateException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataReliabilityException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataReliabilityException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataReliabilityException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactDataReliabilityException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactDataReliabilityException(Contact contact) {
+ super(contact);
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataReliabilityException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactMainObserverException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactMainObserverException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactMainObserverException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactMainObserverException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactMainObserverException(Contact contact) {
+ super(contact);
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactMainObserverException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactNbObservantsForObservationDoneStateException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactNbObservantsForObservationDoneStateException(Contact contact) {
+ super(contact);
+ }
+
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationBeginDateException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationBeginDateException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationBeginDateException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactObservationBeginDateException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactObservationBeginDateException(Contact contact) {
+ super(contact);
+ }
+
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationBeginDateException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationEndDateException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationEndDateException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationEndDateException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactObservationEndDateException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactObservationEndDateException(Contact contact) {
+ super(contact);
+ }
+
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationEndDateException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservedDataControlException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservedDataControlException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservedDataControlException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactObservedDataControlException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactObservedDataControlException(Contact contact) {
+ super(contact);
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservedDataControlException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactRestitutionException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactRestitutionException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactRestitutionException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactRestitutionException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactRestitutionException(Contact contact) {
+ super(contact);
+ }
+
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactRestitutionException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactStateMotifException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactStateMotifException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactStateMotifException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class MissingContactStateMotifException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingContactStateMotifException(Contact contact) {
+ super(contact);
+ }
+
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactStateMotifException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -27,7 +27,9 @@
import com.google.common.collect.ImmutableSet;
import fr.ifremer.wao.ContactsFilter;
import fr.ifremer.wao.WaoTechnicalException;
+import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.Company;
import fr.ifremer.wao.entity.Contact;
import fr.ifremer.wao.entity.ContactImpl;
import fr.ifremer.wao.entity.ContactState;
@@ -238,8 +240,9 @@
List<Boat> boats = getBoatDao().findAll();
List<ContactStateMotif> motives = getContactStateMotifDao().findAll();
+ Locale l = getLocale();
ImportModel<Contact> contactImportModel =
- ObsMerContactImportExportModel.forImport(getLocale(),
+ ObsMerContactImportExportModel.forImport(l,
obsProgram,
waoUsers,
sampleRows,
@@ -258,27 +261,96 @@
UpdateContactCommand updateContactCommand = newUpdateContactCommand(authenticatedWaoUser,
optionalContactId);
- //FIXME Apply imported contact...
-// updateContactCommand.setContact(contact);
+ if (updateContactCommand.isCreation()) {
- try {
- preValidate(authenticatedWaoUser, updateContactCommand, false);
- } catch (ContactNotUpdatableException e) {
- if (log.isWarnEnabled()) {
- log.warn("Can't update contact: " + contactId);
- }
- continue;
+ // TODO bind everything ?
+ } else {
+
+ // TODO bind only filled ?
}
+ preValidate(authenticatedWaoUser, updateContactCommand, false);
+
save0(updateContactCommand);
}
} catch (ImportRuntimeException e) {
throw new ImportErrorException(e);
- } catch (ContactNotValidException e) {
- throw new ImportErrorException(e);
- } catch (NullSampleMonthException e) {
- throw new ImportErrorException(e);
+ } catch (ContactNotUpdatableException e) {
+ String message = l(l, "wao.import.contact.failure.not.updatable");
+ throw new ImportErrorException(message);
+ } catch (UnwantedContactContactStateMotifException e) {
+ String message = l(l, "wao.import.contact.failure.unwantedContactStateMotif");
+ throw new ImportErrorException(message);
+ } catch (MissingContactNbObservantsForObservationDoneStateException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingObserver", state);
+ throw new ImportErrorException(message);
+ } catch (MissingContactObservationEndDateException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingObservationEndDate", state);
+ throw new ImportErrorException(message);
+ } catch (ContactDataInputDateAfterObservationEndDateException e) {
+ String message = l(l, "wao.import.contact.failure.dataInputDateAfterObservationEndDate");
+ throw new ImportErrorException(message);
+ } catch (InvalidContactObservationBeginDateException e) {
+ String message = l(l, "wao.import.contact.failure.invalidObservationBeginDate");
+ throw new ImportErrorException(message);
+ } catch (MissingContactRestitutionException e) {
+ String message = l(l, "wao.import.contact.failure.missingRestitution");
+ throw new ImportErrorException(message);
+ } catch (ContactDataInputDateAfterTodayException e) {
+ String message = l(l, "wao.import.contact.failure.dataInputDateAfterObservationEndDate");
+ throw new ImportErrorException(message);
+ } catch (MissingContactCommentException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingComment", state);
+ throw new ImportErrorException(message);
+ } catch (MismatchContactMainObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName);
+ throw new ImportErrorException(message);
+ } catch (ContactRestitutionDateBeforeDataInputDateException e) {
+ String message = l(l, "wao.import.contact.failure.transmissionDateBeforeDataInputDate");
+ throw new ImportErrorException(message);
+ } catch (ContactObservationEndDateBeforeBeginDateException e) {
+ String message = l(l, "wao.import.contact.failure.observationEndDateBeforeBeginDate");
+ throw new ImportErrorException(message);
+ } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
+ String message = l(l, "wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers");
+ throw new ImportErrorException(message);
+ } catch (MissingContactDataReliabilityException e) {
+ String message = l(l, "wao.import.contact.failure.missingDataReliability");
+ throw new ImportErrorException(message);
+ } catch (MismatchContactSecondaryObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName);
+ throw new ImportErrorException(message);
+ } catch (MissingContactObservedDataControlException e) {
+ String message = l(l, "wao.import.contact.failure.missingObservedDataControl");
+ throw new ImportErrorException(message);
+ } catch (MissingContactStateMotifException e) {
+ String message = l(l, "wao.import.contact.failure.missingContactStateMotif");
+ throw new ImportErrorException(message);
+ } catch (MissingContactDataInputDateException e) {
+ String message = l(l, "wao.import.contact.failure.missingDataInputDate");
+ throw new ImportErrorException(message);
+ } catch (MissingContactMainObserverException e) {
+ String message = l(l, "wao.import.contact.failure.missingMainObserver");
+ throw new ImportErrorException(message);
+ } catch (MissingContactCommentAdminException e) {
+ String dataReliability = WaoUtils.l(l, e.getContact().getDataReliability());
+ String message = l(l, "wao.import.contact.failure.missingCommentAdmin", dataReliability);
+ throw new ImportErrorException(message);
+ } catch (ContactObservationEndDateAfterTodayException e) {
+ String message = l(l, "wao.import.contact.failure.observationEndDateAfterToday");
+ throw new ImportErrorException(message);
+ } catch (MissingContactObservationBeginDateException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingObservationBeginDate", state);
+ throw new ImportErrorException(message);
}
commit();
@@ -286,7 +358,29 @@
public void preValidate(AuthenticatedWaoUser authenticatedWaoUser,
UpdateContactCommand updateContactCommand,
- boolean needUpdate) throws ContactNotUpdatableException, ContactNotValidException {
+ boolean needUpdate) throws
+ ContactNotUpdatableException,
+ MissingContactMainObserverException,
+ MismatchContactMainObserverCompanyException,
+ DuplicatedContactMainObserverInSecondaryObserversException,
+ MismatchContactSecondaryObserverCompanyException,
+ InvalidContactObservationBeginDateException,
+ ContactObservationEndDateBeforeBeginDateException,
+ ContactObservationEndDateAfterTodayException,
+ ContactDataInputDateAfterObservationEndDateException,
+ ContactDataInputDateAfterTodayException,
+ MissingContactCommentException,
+ MissingContactObservationBeginDateException,
+ MissingContactObservationEndDateException,
+ MissingContactNbObservantsForObservationDoneStateException,
+ MissingContactStateMotifException,
+ UnwantedContactContactStateMotifException,
+ MissingContactObservedDataControlException,
+ MissingContactRestitutionException,
+ MissingContactDataInputDateException,
+ ContactRestitutionDateBeforeDataInputDateException,
+ MissingContactDataReliabilityException,
+ MissingContactCommentAdminException {
if (needUpdate) {
Preconditions.checkState(!updateContactCommand.isCreation());
@@ -310,155 +404,204 @@
Locale l = serviceContext.getLocale();
- if (contact.getMainObserver() == null) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.missing.main.observer"));
- }
+ Company company = contact.getSampleRow().getCompany();
- if (contact.isSecondaryObserversNotEmpty() && contact.getSecondaryObservers().contains(contact.getMainObserver())) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.mainObserver.cant.be.secondaryObserver"));
- }
+ WaoUser mainObserver = contact.getMainObserver();
- for (WaoUser observer : contact.getAllObservers()) {
- boolean observerWorksForCompanyInSampleRow = observer.getCompany().equals(contact.getSampleRow().getCompany());
+ {
+ //---
+ // mainObserver
+ //---
+
+ if (mainObserver == null) {
+ throw new MissingContactMainObserverException(contact);
+ }
+
+ boolean observerWorksForCompanyInSampleRow = mainObserver.getCompany().equals(company);
if (!observerWorksForCompanyInSampleRow) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.company.for.observer",
- observer.getLogin(), contact.getSampleRow().getCompany().getName()));
+ throw new MismatchContactMainObserverCompanyException(contact, company, mainObserver);
}
}
- // Validation for saving contact depends on contactState
- ContactState contactState = contact.getContactState();
- Date observationBeginDate = contact.getObservationBeginDate();
- if (log.isDebugEnabled()) {
- log.debug("For state : " + contactState + " and observation begin date " + observationBeginDate);
- }
+ if (contact.isSecondaryObserversNotEmpty()) {
- // need the sample months to be loaded, it's never the case :-(
- // boolean operationBeginDateIsValid = contact.getSampleRow().isValid(observationBeginDate);
+ //---
+ // secondaryObservers
+ //---
- String sampleRowCode = contact.getSampleRow().getCode();
- SampleRow sampleRow = getSampleRowDao().forCodeEquals(sampleRowCode).findAny();
+ if (contact.getSecondaryObservers().contains(mainObserver)) {
+ throw new DuplicatedContactMainObserverInSecondaryObserversException(contact);
+ }
- SampleMonth month = sampleRow.getSampleMonth(observationBeginDate);
- boolean operationBeginDateIsValid = month != null;
-
- if (log.isDebugEnabled()) {
- log.debug("operation begin data is valid : " + operationBeginDateIsValid);
+ for (WaoUser observer : contact.getSecondaryObservers()) {
+ boolean observerWorksForCompanyInSampleRow = observer.getCompany().equals(company);
+ if (!observerWorksForCompanyInSampleRow) {
+ throw new MismatchContactSecondaryObserverCompanyException(contact, observer, company);
+ }
+ }
}
- if (observationBeginDate != null && !operationBeginDateIsValid) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.trip.beginDate",
- contact.getSampleRow().getCode()));
- }
-
+ Date observationBeginDate = contact.getObservationBeginDate();
Date observationEndDate = contact.getObservationEndDate();
- if (observationBeginDate != null && observationEndDate != null
- && observationEndDate.before(observationBeginDate)) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.observation.endDate"));
- }
-
Date dataInputDate = contact.getDataInputDate();
- // Here, we check that the date input date is after the end of the
- // observation. Since the first is a day (at 00:00) and the second
- // is date-time, there may be a bug if the data input day is the same
- // as the end of observation
- boolean observationEndDateIsBeforeDataInputDate =
- observationEndDate == null
- || dataInputDate == null
- || observationEndDate.before(DateUtil.setMaxTimeOfDay(dataInputDate));
- if (log.isDebugEnabled()) {
- log.debug("observationEndDate = " + observationEndDate +
- ", dateInputDate = " + dataInputDate + ", observationEndDateIsBeforeDataInputDate = "
- + observationEndDateIsBeforeDataInputDate);
+ SampleRow sampleRow = contact.getSampleRow();
+
+ if (observationBeginDate != null) {
+
+ //---
+ // observationBeginDate
+ //---
+
+ SampleMonth month = sampleRow.getSampleMonth(observationBeginDate);
+ boolean operationBeginDateIsValid = month != null;
+
+ if (!operationBeginDateIsValid) {
+ throw new InvalidContactObservationBeginDateException(contact);
+ }
}
- if (!observationEndDateIsBeforeDataInputDate) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.observation.end"));
- }
Date currentDate = serviceContext.getNow();
- if (observationEndDate != null && observationEndDate.after(currentDate)) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.trip.endDate"));
- }
- if (dataInputDate != null && dataInputDate.after(currentDate)) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.observation.end2"));
- }
+ if (observationEndDate != null) {
- // Non abouti
- if (contactState == ContactState.OBSERVATION_CANCELLED && StringUtils.isBlank(contact.getComment())) {
- throw new ContactNotValidException(l(l, "wao.business.contact.validation.commentMissingForState",
- contact.getContactState().toString()));
- // Observation réalisée
- } else if (contactState.equals(ContactState.OBSERVATION_DONE)) {
+ //---
+ // observationEndDate
+ //---
- if (observationBeginDate == null) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.missing.trip.beginDate", contactState));
+ if (observationBeginDate != null
+ && observationEndDate.before(observationBeginDate)) {
+ throw new ContactObservationEndDateBeforeBeginDateException(contact);
}
- if (observationEndDate == null) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.missing.observation.endDate", contactState));
+
+ if (observationEndDate.after(currentDate)) {
+ throw new ContactObservationEndDateAfterTodayException(contact, currentDate);
}
- if (contact.getNbObservants() == 0) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.observer.state", contactState));
- }
- if (contact.getObsProgram() == ObsProgram.OBSVENTE) {
- if (contact.getTerrestrialLocation() == null) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.missing.observationArea"));
+
+ }
+
+ if (dataInputDate != null) {
+
+ //---
+ // dataInputDate
+ //---
+
+ if (observationEndDate != null) {
+
+ // Here, we check that the date input date is after the end of the
+ // observation. Since the first is a day (at 00:00) and the second
+ // is date-time, there may be a bug if the data input day is the same
+ // as the end of observation
+ boolean observationEndDateIsBeforeDataInputDate =
+ observationEndDate.before(DateUtil.setMaxTimeOfDay(dataInputDate));
+
+ if (!observationEndDateIsBeforeDataInputDate) {
+ throw new ContactDataInputDateAfterObservationEndDateException(contact);
}
}
+
+ if (dataInputDate.after(currentDate)) {
+ throw new ContactDataInputDateAfterTodayException(contact, currentDate);
+ }
}
- boolean contactMustHaveAMotif = contact.getObsProgram() == ObsProgram.OBSMER
- && (contactState == ContactState.CONTACT_REFUSED
- || contactState == ContactState.CONTACT_DEFINITELY_REFUSED);
+ //---
+ // contactState
+ //---
+
+ ContactState contactState = contact.getContactState();
+
+ boolean contactMustHaveAMotif = false;
+ switch (contactState) {
+ case OBSERVATION_CANCELLED:
+
+ // Non abouti
+
+ if (StringUtils.isBlank(contact.getComment())) {
+ throw new MissingContactCommentException(contact);
+ }
+ break;
+ case OBSERVATION_DONE:
+
+ // Observation réalisée
+
+ if (observationBeginDate == null) {
+ throw new MissingContactObservationBeginDateException(contact);
+ }
+ if (observationEndDate == null) {
+ throw new MissingContactObservationEndDateException(contact);
+ }
+ if (contact.getNbObservants() == 0) {
+ throw new MissingContactNbObservantsForObservationDoneStateException(contact);
+ }
+ break;
+
+ case CONTACT_REFUSED:
+ contactMustHaveAMotif = true;
+ break;
+ case CONTACT_DEFINITELY_REFUSED:
+ contactMustHaveAMotif = true;
+ break;
+
+ }
+
+ //---
+ // contactStateMotif
+ //---
+
if (contactMustHaveAMotif && contact.getContactStateMotif() == null) {
- throw new ContactNotValidException(l(l, "wao.business.contact.validation.contactStateMotifMissing"));
+ throw new MissingContactStateMotifException(contact);
}
if (!contactMustHaveAMotif && contact.getContactStateMotif() != null) {
- throw new ContactNotValidException(l(l, "wao.business.contact.validation.contactStateMotifUnwanted"));
+ throw new UnwantedContactContactStateMotifException(contact);
}
- if (log.isDebugEnabled()) {
- log.debug("validationProgram = " + contact.getValidationProgram());
- }
+ if (BooleanUtils.isTrue(contact.getValidationCompany())) {
- if (BooleanUtils.isTrue(contact.getValidationCompany())) {
+ //---
+ // validationCompany
+ //---
+
// Pour valider un contact société, il faut que le contact aie une date de transmission
- if (contact.getContactState() == ContactState.OBSERVATION_DONE && contact.getObservedDataControl() == null) {
- throw new ContactNotValidException(l(l, "wao.business.contact.validation.observedDataControlMissingForValidation"));
+ if (ContactState.OBSERVATION_DONE == contactState && contact.getObservedDataControl() == null) {
+ throw new MissingContactObservedDataControlException(contact);
}
- if (contact.getObservedDataControl() == ObservedDataControl.ACCEPTED && contact.getRestitution() == null) {
- throw new ContactNotValidException(l(l, "wao.business.contact.validation.restitutionMissingForValidation"));
+ Date restitution = contact.getRestitution();
+
+ if (ObservedDataControl.ACCEPTED == contact.getObservedDataControl() && restitution == null) {
+ throw new MissingContactRestitutionException(contact);
}
- if (contact.getDataInputDate() == null && contact.getRestitution() != null) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.missing.observationDate"));
+ if (dataInputDate == null && restitution != null) {
+ throw new MissingContactDataInputDateException(contact);
}
- if (contact.getDataInputDate() != null && contact.getRestitution() != null && contact.getRestitution().before(contact.getDataInputDate())) {
- throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.transmissionDate"));
+ if (dataInputDate != null && restitution != null && restitution.before(dataInputDate)) {
+ throw new ContactRestitutionDateBeforeDataInputDateException(contact);
}
}
if (BooleanUtils.isTrue(contact.getValidationProgram())) {
+
+ //---
+ // validationProgram
+ //---
+
// it's an admin validation, data-reliability field must be filled
- if (log.isDebugEnabled()) {
- log.debug("field data reliability is " + contact.getDataReliability());
- }
- if (contact.getDataReliability() == null ||
- contact.getDataReliability() == DataReliability.UNKNOWN) {
- throw new ContactNotValidException(l(l, "wao.business.contact.validation.dataReliabilityMissingForValidation"));
- } else if (contact.getDataReliability() != DataReliability.RELIABLE
+ DataReliability dataReliability = contact.getDataReliability();
+
+ if (dataReliability == null || DataReliability.UNKNOWN == dataReliability) {
+ throw new MissingContactDataReliabilityException(contact);
+ } else if (DataReliability.RELIABLE != dataReliability
&& StringUtils.isEmpty(contact.getCommentAdmin())) {
- throw new ContactNotValidException(l(l, "wao.business.contact.validation.commentAdminNecessaryForDataReliability",
- contact.getDataReliability().toString()));
+ throw new MissingContactCommentAdminException(contact);
}
}
}
}
public void save(UpdateContactCommand updateContactCommand,
- boolean needUpdate) throws ContactNotValidException, ContactNotUpdatableException, NullSampleMonthException {
+ boolean needUpdate) throws ContactNotUpdatableException {
if (needUpdate) {
Preconditions.checkState(!updateContactCommand.isCreation());
@@ -490,7 +633,7 @@
commit();
}
- protected void save0(UpdateContactCommand updateContactCommand) throws NullSampleMonthException {
+ protected void save0(UpdateContactCommand updateContactCommand) {
// Get contact to validate (must exist)
Contact contact = updateContactCommand.getContact();
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UnwantedContactContactStateMotifException.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UnwantedContactContactStateMotifException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UnwantedContactContactStateMotifException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,18 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Created on 4/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class UnwantedContactContactStateMotifException extends WaoContactValidationException {
+
+ private static final long serialVersionUID = 1L;
+
+ public UnwantedContactContactStateMotifException(Contact contact) {
+ super(contact);
+ }
+}
Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UnwantedContactContactStateMotifException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -130,7 +130,7 @@
*/
public boolean mustValidateContact() {
boolean needValidation = isCreation() || // new contact
- oldValidationProgram == null || // want to unvalidate a contact
+ oldValidationProgram == null || // want to validate a contact
getValidationProgram() != null; // want to validate a contact
return needValidation;
}
Copied: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoContactValidationException.java (from rev 1848, trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactNotValidException.java)
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoContactValidationException.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoContactValidationException.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -0,0 +1,48 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.entity.Contact;
+
+/**
+ * Exception de base pour la validation d'une création - mise à jour ou import d'un contact.
+ * <p/>
+ * Created on 4/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class WaoContactValidationException extends WaoException {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Contact contact;
+
+ public WaoContactValidationException(Contact contact) {
+ this.contact = contact;
+ }
+
+ public Contact getContact() {
+ return contact;
+ }
+}
Modified: trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties
===================================================================
--- trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-04-07 17:09:47 UTC (rev 1858)
@@ -17,14 +17,6 @@
wao.business.completeSampling.false=No
wao.business.completeSampling.true=Yes
wao.business.completeSampling.undefined=Undefined
-wao.business.contact.validation.commentAdminNecessaryForDataReliability=You must precise in admin comment why data reliability is '%s'
-wao.business.contact.validation.commentMissingForState=You must give a comment for state '%s'
-wao.business.contact.validation.contactStateMotifMissing=You must precise a motif for the refusal
-wao.business.contact.validation.contactStateMotifUnwanted=You must not give a motif
-wao.business.contact.validation.dataReliabilityMissingForValidation=You must provide data reliability before validating
-wao.business.contact.validation.missingHoursOfBeginEndObservation=You must provide accurate time for the beginning and the end of observation
-wao.business.contact.validation.observedDataControlMissingForValidation=You must provide a value for observed data control
-wao.business.contact.validation.restitutionMissingForValidation=You must provide the restitution forward date
wao.business.entity.UserProfile.description=%s on %s%s
wao.business.mammalsCapture.mail.message=Hello,\n\nAn observer of the ObsMer program provided to WAO the following information\:\n\nTide\: %s\nProfession\: %s\n\nAccidental capture\:\n%s\n\nBest regards,\n\nObsmer program\nhttp\://www.ifremer.fr/wao
wao.business.mammalsCapture.mail.subject=Obsmer WAO\: Information about an accidental capture
@@ -39,33 +31,42 @@
wao.import.boat.failure.invalid.locationCode=The code '%s' is not a valid location code
wao.import.boat.failure.missing.port=The port is required
wao.import.contact.failure.boatMissing=You need to precise the plate number of the boat associated to the contact
+wao.import.contact.failure.dataInputDateAfterObservationEndDate=La date de saisie des données doit être postérieure à la date de fin d'observation
+wao.import.contact.failure.dataInputDateBeforeToday=La date de saisie des données doit être antérieur à la date du jour
wao.import.contact.failure.districtMissing=You need to precise the boat district
-wao.import.contact.failure.invalid.company.for.observer=L'observateur %s n'est pas membre de la société %s
-wao.import.contact.failure.invalid.dataInputDate=La date de saisie des données ne peut pas être postérieure à la date du jour
-wao.import.contact.failure.invalid.dataInputDate2=La date de saisie des données ne peut pas être antérieure à la date de fin d'observation
-wao.import.contact.failure.invalid.observation.endDate=La date de fin d'observation ne peut pas être antérieure à celle du début
-wao.import.contact.failure.invalid.observer.state=Il ne peut y avoir aucun observateur pour l'état '%s'
-wao.import.contact.failure.invalid.transmissionDate=Il faut que la date de transmission de la restitution soit après la date de saisie des données
-wao.import.contact.failure.invalid.trip.beginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne
-wao.import.contact.failure.invalid.trip.endDate=La date de fin de la marée ne peut pas être postérieure à la date du jour
+wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers=Main observer can not be also a secondary observer
+wao.import.contact.failure.invalidObservationBeginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne
wao.import.contact.failure.locationTypeMissing=The type of the location must be filled
-wao.import.contact.failure.mainObserver.cant.be.secondaryObserver=
-wao.import.contact.failure.mainObserver.cant.be.secondaryObserver.=L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires
-wao.import.contact.failure.missing.main.observer=Il faut au moins un observateur référant
-wao.import.contact.failure.missing.observation.endDate=La date de fin d'observation est obligatoire pour l'état '%s'
-wao.import.contact.failure.missing.observationArea=Il faut préciser un lieu d'observation
-wao.import.contact.failure.missing.observationDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution
-wao.import.contact.failure.missing.trip.beginDate=La date de début de marée est obligatoire pour l'état '%s'
+wao.import.contact.failure.mismatchCompanyForObserver=L'observateur %s n'est pas membre de la société %s
+wao.import.contact.failure.missingComment=You must give a comment for state '%s'
+wao.import.contact.failure.missingCommentAdmin=You must precise in admin comment why data reliability is '%s'
+wao.import.contact.failure.missingContactStateMotif=You must precise a motif for the refusal
+wao.import.contact.failure.missingDataInputDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution
+wao.import.contact.failure.missingDataReliability=You must provide data reliability before validating
+wao.import.contact.failure.missingHoursOfBeginEndObservation=You must provide accurate time for the beginning and the end of observation
+wao.import.contact.failure.missingMainBbserver=Il faut au moins un observateur référant
+wao.import.contact.failure.missingMainObserver=
+wao.import.contact.failure.missingObservationArea=Il faut préciser un lieu d'observation
+wao.import.contact.failure.missingObservationBeginDate=La date de début de marée est obligatoire pour l'état '%s'
+wao.import.contact.failure.missingObservationEndDate=La date de fin d'observation est obligatoire pour l'état '%s'
+wao.import.contact.failure.missingObservedDataControl=You must provide a value for observed data control
+wao.import.contact.failure.missingObserver=Il ne peut y avoir aucun observateur pour l'état '%s'
+wao.import.contact.failure.missingRestitution=You must provide the restitution forward date
+wao.import.contact.failure.not.updatable=Insufficient credentials to update contact
+wao.import.contact.failure.observationEndDateAfterToday=La date de fin de la marée ne peut pas être postérieure à la date du jour
+wao.import.contact.failure.observationEndDateBeforeBeginDate=La date de fin d'observation ne peut pas être antérieure à celle du début
wao.import.contact.failure.sampleRowCodeMissing=The code of the sample row line is missing
wao.import.contact.failure.terrestrialLocationMissing=The code of the terrestrial location is missing
+wao.import.contact.failure.transmissionDateBeforeDataInputDate=Il faut que la date de transmission de la restitution soit après la date de saisie des données
wao.import.contact.failure.unkwonCompany=Company named '%s' does not exist
+wao.import.contact.failure.unwantedContactStateMotif=You must not give a motif
wao.import.contact.failure.wrongBoat=There is no boat with plate number '%s'
wao.import.contact.failure.wrongColor=The color '%s' is not a valid color. It must be composed of 6 characters without the hash (\#), see http\://en.wikipedia.org/wiki/Web_colors
wao.import.contact.failure.wrongContactStateMotifCode=The code '%s' is not a valid code
wao.import.contact.failure.wrongDistrict='%s' is not a valid boat district code
wao.import.contact.failure.wrongSampleRowCode=The is no sample row with code '%s'
wao.import.contact.failure.wrongTerrestrialLocation=There is no location of type '%s' with code '%s'
-wao.import.failure=Import fail.
+wao.import.failure=Import fail for reason\: %s.
wao.import.failure.invalid.regionCode=The code '%s' is not a valid region code
wao.import.failure.wrongLocationType='%s' is not a valid location type, allowed values are %s
wao.import.failure.wrongObsDebCode=There is no profession code having code '%s'
Modified: trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties
===================================================================
--- trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-04-07 17:09:47 UTC (rev 1858)
@@ -17,14 +17,6 @@
wao.business.completeSampling.false=Non
wao.business.completeSampling.true=Oui
wao.business.completeSampling.undefined=Non défini
-wao.business.contact.validation.commentAdminNecessaryForDataReliability=Il faut préciser dans le commentaire administrateur pourquoi la donnée est '%s'
-wao.business.contact.validation.commentMissingForState=Il faut préciser un commentaire pour l'état '%s'
-wao.business.contact.validation.contactStateMotifMissing=Il faut préciser un motif de refus
-wao.business.contact.validation.contactStateMotifUnwanted=Il ne faut pas préciser de motif de refus
-wao.business.contact.validation.dataReliabilityMissingForValidation=Il faut préciser la qualité de la donnée avant de valider
-wao.business.contact.validation.missingHoursOfBeginEndObservation=Il faut préciser les heures exactes de début et de fin d'observation
-wao.business.contact.validation.observedDataControlMissingForValidation=Il faut préciser une valeur pour le contrôle des données observées
-wao.business.contact.validation.restitutionMissingForValidation=Il faut préciser une date de transmission de la restitution de la donnée avant de valider
wao.business.entity.UserProfile.description=%s sur %s%s
wao.business.mammalsCapture.mail.message=Bonjour,\n\nUn observateur du programme Obsmer a renseigné dans WAO l'information suivante \:\n\nMarée \: %s\nMétier \: %s\n\nCapture accidentelle \:\n%s\n\nCordialement,\n\nLe programme Obsmer\nhttp\://www.ifremer.fr/wao
wao.business.mammalsCapture.mail.subject=Obsmer WAO\: Information sur capture accidentelle
@@ -38,33 +30,43 @@
wao.import.boat.failure.invalid.locationCode=Le code '%s' n'est pas un code de lieu valide
wao.import.boat.failure.missing.port=Il faut préciser un port
wao.import.contact.failure.boatMissing=Il faut préciser l'immatriculation du navire associé au contact
+wao.import.contact.failure.dataInputDateAfterObservationEndDate=
+wao.import.contact.failure.dataInputDateBeforeObservationEndDate=La date de saisie des données ne peut pas être antérieure à la date de fin d'observation
+wao.import.contact.failure.dataInputDateBeforeToday=La date de saisie des données doit être antérieur à la date du jour
wao.import.contact.failure.districtMissing=Il faut préciser le code d'un quartier maritime
-wao.import.contact.failure.invalid.company.for.observer=L'observateur %s n'est pas membre de la société %s
-wao.import.contact.failure.invalid.dataInputDate=La date de saisie des données ne peut pas être postérieure à la date du jour
-wao.import.contact.failure.invalid.dataInputDate2=La date de saisie des données ne peut pas être antérieure à la date de fin d'observation
-wao.import.contact.failure.invalid.observation.endDate=La date de fin d'observation ne peut pas être antérieure à celle du début
-wao.import.contact.failure.invalid.observer.state=Il ne peut y avoir aucun observateur pour l'état '%s'
-wao.import.contact.failure.invalid.transmissionDate=Il faut que la date de transmission de la restitution soit après la date de saisie des données
-wao.import.contact.failure.invalid.trip.beginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne
-wao.import.contact.failure.invalid.trip.endDate=La date de fin de la marée ne peut pas être postérieure à la date du jour
+wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers=L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires
+wao.import.contact.failure.invalid.observationBeginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne
+wao.import.contact.failure.invalidObservationBeginDate=
wao.import.contact.failure.locationTypeMissing=Le type du lieu doit être renseigné
-wao.import.contact.failure.mainObserver.cant.be.secondaryObserver=
-wao.import.contact.failure.mainObserver.cant.be.secondaryObserver.=L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires
-wao.import.contact.failure.missing.main.observer=Il faut au moins un observateur référant
-wao.import.contact.failure.missing.observation.endDate=La date de fin d'observation est obligatoire pour l'état '%s'
-wao.import.contact.failure.missing.observationArea=Il faut préciser un lieu d'observation
-wao.import.contact.failure.missing.observationDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution
-wao.import.contact.failure.missing.trip.beginDate=La date de début de marée est obligatoire pour l'état '%s'
+wao.import.contact.failure.mismatchCompanyForObserver=L'observateur %s n'est pas membre de la société %s
+wao.import.contact.failure.missingComment=Il faut préciser un commentaire pour l'état '%s'
+wao.import.contact.failure.missingCommentAdmin=Il faut préciser dans le commentaire administrateur pourquoi la donnée est '%s'
+wao.import.contact.failure.missingContactStateMotif=Il faut préciser un motif de refus
+wao.import.contact.failure.missingDataInputDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution
+wao.import.contact.failure.missingDataReliability=Il faut préciser la qualité de la donnée avant de valider
+wao.import.contact.failure.missingHoursOfBeginEndObservation=Il faut préciser les heures exactes de début et de fin d'observation
+wao.import.contact.failure.missingMainObserver=Il faut au moins un observateur référant
+wao.import.contact.failure.missingObservationArea=Il faut préciser un lieu d'observation
+wao.import.contact.failure.missingObservationBeginDate=La date de début de marée est obligatoire pour l'état '%s'
+wao.import.contact.failure.missingObservationEndDate=La date de fin d'observation est obligatoire pour l'état '%s'
+wao.import.contact.failure.missingObservedDataControl=Il faut préciser une valeur pour le contrôle des données observées
+wao.import.contact.failure.missingObserver=Il ne peut y avoir aucun observateur pour l'état '%s'
+wao.import.contact.failure.missingRestitution=Il faut préciser une date de transmission de la restitution de la donnée avant de valider
+wao.import.contact.failure.not.updatable=Vous n'avez pas les droits suffisants pour modifier le contact
+wao.import.contact.failure.observationEndDateAfterToday=La date de fin de la marée ne peut pas être postérieure à la date du jour
+wao.import.contact.failure.observationEndDateBeforeBeginDate=La date de fin d'observation ne peut pas être antérieure à celle du début
wao.import.contact.failure.sampleRowCodeMissing=Il manque le code de la ligne de plan associée
wao.import.contact.failure.terrestrialLocationMissing=Il manque le code du lieu
+wao.import.contact.failure.transmissionDateBeforeDataInputDate=Il faut que la date de transmission de la restitution soit après la date de saisie des données
wao.import.contact.failure.unkwonCompany=Il n'y a pas de société ayant pour nom '%s'
+wao.import.contact.failure.unwantedContactStateMotif=Il ne faut pas préciser de motif de refus
wao.import.contact.failure.wrongBoat=Il n'y a pas de navire avec l'immatriculation '%s'
wao.import.contact.failure.wrongColor=Le code couleur '%s' n'est pas valide, il doit être composé de six caractères sans dièze voir http\://fr.wikipedia.org/wiki/Couleurs_du_Web
wao.import.contact.failure.wrongContactStateMotifCode=Le code '%s' n'est pas un code de motif de refus valide
wao.import.contact.failure.wrongDistrict='%s' n'est pas un code quartier maritime valide
wao.import.contact.failure.wrongSampleRowCode=Il n'y a pas de ligne du plan avec le code '%s'
wao.import.contact.failure.wrongTerrestrialLocation=Il n'y a pas de lieu de type '%s' ayant pour code '%s'
-wao.import.failure=Une erreur est survenue lors de l'import.
+wao.import.failure=Une erreur est survenue lors de l'import \: %s.
wao.import.failure.invalid.regionCode=Le code '%s' n'est pas un code de région valide
wao.import.failure.wrongLocationType='%s' n'est pas un type de lieu valide, les valeurs admises sont %s
wao.import.failure.wrongObsDebCode=Il n'y a pas de code métier ayant pour code '%s'
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractImportCsvAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractImportCsvAction.java 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractImportCsvAction.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -93,7 +93,7 @@
} catch (ImportErrorException e) {
- session.addErrorMessages(e.getMessage());
+ session.addErrorMessages(e.getMessage(getLocale()));
result = ERROR;
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -24,10 +24,31 @@
import com.google.common.base.Optional;
import com.google.common.base.Strings;
import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.services.AuthenticatedWaoUser;
+import fr.ifremer.wao.services.service.ContactDataInputDateAfterObservationEndDateException;
+import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException;
import fr.ifremer.wao.services.service.ContactNotUpdatableException;
-import fr.ifremer.wao.services.service.ContactNotValidException;
+import fr.ifremer.wao.services.service.ContactObservationEndDateAfterTodayException;
+import fr.ifremer.wao.services.service.ContactObservationEndDateBeforeBeginDateException;
+import fr.ifremer.wao.services.service.ContactRestitutionDateBeforeDataInputDateException;
+import fr.ifremer.wao.services.service.DuplicatedContactMainObserverInSecondaryObserversException;
+import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException;
+import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException;
+import fr.ifremer.wao.services.service.MismatchContactSecondaryObserverCompanyException;
+import fr.ifremer.wao.services.service.MissingContactCommentAdminException;
+import fr.ifremer.wao.services.service.MissingContactCommentException;
+import fr.ifremer.wao.services.service.MissingContactDataInputDateException;
+import fr.ifremer.wao.services.service.MissingContactDataReliabilityException;
+import fr.ifremer.wao.services.service.MissingContactMainObserverException;
+import fr.ifremer.wao.services.service.MissingContactNbObservantsForObservationDoneStateException;
+import fr.ifremer.wao.services.service.MissingContactObservationBeginDateException;
+import fr.ifremer.wao.services.service.MissingContactObservationEndDateException;
+import fr.ifremer.wao.services.service.MissingContactObservedDataControlException;
+import fr.ifremer.wao.services.service.MissingContactRestitutionException;
+import fr.ifremer.wao.services.service.MissingContactStateMotifException;
import fr.ifremer.wao.services.service.ObsMerContactsService;
+import fr.ifremer.wao.services.service.UnwantedContactContactStateMotifException;
import fr.ifremer.wao.services.service.UpdateContactCommand;
import fr.ifremer.wao.web.WaoJspActionSupport;
import org.apache.struts2.convention.annotation.Result;
@@ -86,9 +107,81 @@
try {
service.preValidate(authenticatedWaoUser, updateContactCommand, true);
} catch (ContactNotUpdatableException e) {
- addActionError(t("wao.ui.contacts.validation.failure.not.updatable", e.getMessage()));
- } catch (ContactNotValidException e) {
- addActionError(t("wao.ui.contacts.validation.failure.not.valid", e.getMessage()));
+ addActionError(t("wao.ui.contacts.validation.failure.not.updatable"));
+ addFieldError("updateContactCommand.contact.", t("wao.ui.contacts.validation.failure.not.updatable", e.getMessage()));
+
+ } catch (UnwantedContactContactStateMotifException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.unwantedContactStateMotif"));
+
+ } catch (MissingContactNbObservantsForObservationDoneStateException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObserver", state));
+
+ } catch (MissingContactObservationEndDateException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObservationEndDate", state));
+
+ } catch (ContactDataInputDateAfterObservationEndDateException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.dataInputDateAfterObservationEndDate"));
+
+ } catch (InvalidContactObservationBeginDateException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.invalidObservationBeginDate"));
+
+ } catch (MissingContactRestitutionException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingRestitution"));
+
+ } catch (ContactDataInputDateAfterTodayException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.dataInputDateAfterObservationEndDate"));
+
+ } catch (MissingContactCommentException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingComment", state));
+
+ } catch (MismatchContactMainObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName));
+
+ } catch (ContactRestitutionDateBeforeDataInputDateException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.transmissionDateBeforeDataInputDate"));
+
+ } catch (ContactObservationEndDateBeforeBeginDateException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.observationEndDateBeforeBeginDate"));
+
+ } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers"));
+
+ } catch (MissingContactDataReliabilityException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingDataReliability"));
+
+ } catch (MismatchContactSecondaryObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName));
+
+ } catch (MissingContactObservedDataControlException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObservedDataControl"));
+
+ } catch (MissingContactStateMotifException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingContactStateMotif"));
+
+ } catch (MissingContactDataInputDateException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingDataInputDate"));
+
+ } catch (MissingContactMainObserverException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingMainObserver"));
+
+ } catch (MissingContactCommentAdminException e) {
+ String dataReliability = WaoUtils.l(getLocale(), e.getContact().getDataReliability());
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingCommentAdmin", dataReliability));
+
+ } catch (ContactObservationEndDateAfterTodayException e) {
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.observationEndDateAfterToday"));
+
+ } catch (MissingContactObservationBeginDateException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObservationBeginDate", state));
+
}
}
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-04-07 17:09:47 UTC (rev 1858)
@@ -24,9 +24,31 @@
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.services.AuthenticatedWaoUser;
+import fr.ifremer.wao.services.service.ContactDataInputDateAfterObservationEndDateException;
+import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException;
import fr.ifremer.wao.services.service.ContactNotUpdatableException;
-import fr.ifremer.wao.services.service.ContactNotValidException;
+import fr.ifremer.wao.services.service.ContactObservationEndDateAfterTodayException;
+import fr.ifremer.wao.services.service.ContactObservationEndDateBeforeBeginDateException;
+import fr.ifremer.wao.services.service.ContactRestitutionDateBeforeDataInputDateException;
+import fr.ifremer.wao.services.service.DuplicatedContactMainObserverInSecondaryObserversException;
+import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException;
+import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException;
+import fr.ifremer.wao.services.service.MismatchContactSecondaryObserverCompanyException;
+import fr.ifremer.wao.services.service.MissingContactCommentAdminException;
+import fr.ifremer.wao.services.service.MissingContactCommentException;
+import fr.ifremer.wao.services.service.MissingContactDataInputDateException;
+import fr.ifremer.wao.services.service.MissingContactDataReliabilityException;
+import fr.ifremer.wao.services.service.MissingContactMainObserverException;
+import fr.ifremer.wao.services.service.MissingContactNbObservantsForObservationDoneStateException;
+import fr.ifremer.wao.services.service.MissingContactObservationBeginDateException;
+import fr.ifremer.wao.services.service.MissingContactObservationEndDateException;
+import fr.ifremer.wao.services.service.MissingContactObservedDataControlException;
+import fr.ifremer.wao.services.service.MissingContactRestitutionException;
+import fr.ifremer.wao.services.service.MissingContactStateMotifException;
+import fr.ifremer.wao.services.service.UnwantedContactContactStateMotifException;
+import fr.ifremer.wao.services.service.WaoContactValidationException;
import fr.ifremer.wao.services.service.ObsMerContactsService;
import fr.ifremer.wao.services.service.UpdateContactCommand;
import fr.ifremer.wao.web.WaoJsonActionSupport;
@@ -147,9 +169,79 @@
try {
service.preValidate(authenticatedWaoUser, updateContactCommand, true);
} catch (ContactNotUpdatableException e) {
- errorMessage = t("wao.ui.contacts.validation.failure.not.updatable", e.getMessage());
- } catch (ContactNotValidException e) {
- errorMessage = t("wao.ui.contacts.validation.failure.not.valid", e.getMessage());
+ errorMessage = t("wao.ui.contacts.validation.failure.not.updatable");
+ } catch (UnwantedContactContactStateMotifException e) {
+ errorMessage = t("wao.import.contact.failure.unwantedContactStateMotif");
+
+ } catch (MissingContactNbObservantsForObservationDoneStateException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ errorMessage = t("wao.import.contact.failure.missingObserver", state);
+
+ } catch (MissingContactObservationEndDateException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ errorMessage = t("wao.import.contact.failure.missingObservationEndDate", state);
+
+ } catch (ContactDataInputDateAfterObservationEndDateException e) {
+ errorMessage = t("wao.import.contact.failure.dataInputDateAfterObservationEndDate");
+
+ } catch (InvalidContactObservationBeginDateException e) {
+ errorMessage = t("wao.import.contact.failure.invalidObservationBeginDate");
+
+ } catch (MissingContactRestitutionException e) {
+ errorMessage = t("wao.import.contact.failure.missingRestitution");
+
+ } catch (ContactDataInputDateAfterTodayException e) {
+ errorMessage = t("wao.import.contact.failure.dataInputDateAfterObservationEndDate");
+
+ } catch (MissingContactCommentException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ errorMessage = t("wao.import.contact.failure.missingComment", state);
+
+ } catch (MismatchContactMainObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ errorMessage = t("wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName);
+
+ } catch (ContactRestitutionDateBeforeDataInputDateException e) {
+ errorMessage = t("wao.import.contact.failure.transmissionDateBeforeDataInputDate");
+
+ } catch (ContactObservationEndDateBeforeBeginDateException e) {
+ errorMessage = t("wao.import.contact.failure.observationEndDateBeforeBeginDate");
+
+ } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
+ errorMessage = t("wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers");
+
+ } catch (MissingContactDataReliabilityException e) {
+ errorMessage = t("wao.import.contact.failure.missingDataReliability");
+
+ } catch (MismatchContactSecondaryObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ errorMessage = t("wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName);
+
+ } catch (MissingContactObservedDataControlException e) {
+ errorMessage = t("wao.import.contact.failure.missingObservedDataControl");
+
+ } catch (MissingContactStateMotifException e) {
+ errorMessage = t("wao.import.contact.failure.missingContactStateMotif");
+
+ } catch (MissingContactDataInputDateException e) {
+ errorMessage = t("wao.import.contact.failure.missingDataInputDate");
+
+ } catch (MissingContactMainObserverException e) {
+ errorMessage = t("wao.import.contact.failure.missingMainObserver");
+
+ } catch (MissingContactCommentAdminException e) {
+ String dataReliability = WaoUtils.l(getLocale(), e.getContact().getDataReliability());
+ errorMessage = t("wao.import.contact.failure.missingCommentAdmin", dataReliability);
+
+ } catch (ContactObservationEndDateAfterTodayException e) {
+ errorMessage = t("wao.import.contact.failure.observationEndDateAfterToday");
+
+ } catch (MissingContactObservationBeginDateException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ errorMessage = t("wao.import.contact.failure.missingObservationBeginDate", state);
+
} catch (Exception e) {
if (log.isErrorEnabled()) {
log.error(e);
Modified: trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties
===================================================================
--- trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-04-07 17:09:47 UTC (rev 1858)
@@ -5,6 +5,25 @@
wao.import.boatGroups.success=Import boats successful
wao.import.boats.prompt=Import boat groups
wao.import.boats.success=Import boat groups successful
+wao.import.contact.failure.dataInputDateAfterObservationEndDate=
+wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers=
+wao.import.contact.failure.invalidObservationBeginDate=
+wao.import.contact.failure.mismatchCompanyForObserver=
+wao.import.contact.failure.missingComment=
+wao.import.contact.failure.missingCommentAdmin=
+wao.import.contact.failure.missingContactStateMotif=
+wao.import.contact.failure.missingDataInputDate=
+wao.import.contact.failure.missingDataReliability=
+wao.import.contact.failure.missingMainObserver=
+wao.import.contact.failure.missingObservationBeginDate=
+wao.import.contact.failure.missingObservationEndDate=
+wao.import.contact.failure.missingObservedDataControl=
+wao.import.contact.failure.missingObserver=
+wao.import.contact.failure.missingRestitution=
+wao.import.contact.failure.observationEndDateAfterToday=
+wao.import.contact.failure.observationEndDateBeforeBeginDate=
+wao.import.contact.failure.transmissionDateBeforeDataInputDate=
+wao.import.contact.failure.unwantedContactStateMotif=
wao.import.contactStateMotives.prompt=Import contact state motives
wao.import.contactStateMotives.success=Import contact state motives successful
wao.import.fishingZones.prompt=Import fishing zones
@@ -134,7 +153,7 @@
wao.ui.contacts.title=%s contacts found
wao.ui.contacts.validation=Validation
wao.ui.contacts.validation.failure=An error occurs %s
-wao.ui.contacts.validation.failure.not.updatable=You can not modify this contact\: %s
+wao.ui.contacts.validation.failure.not.updatable=You can not modify the contact
wao.ui.contacts.validation.failure.not.valid=Contact is not valid\: %s
wao.ui.contacts.validation.to.accept.state.success=Contact was accepted successful
wao.ui.contacts.validation.to.reject.state.success=Contact was rejected successful
Modified: trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties
===================================================================
--- trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-04-07 17:07:49 UTC (rev 1857)
+++ trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-04-07 17:09:47 UTC (rev 1858)
@@ -5,6 +5,25 @@
wao.import.boatGroups.success=Import des flotilles réalisé avec succès
wao.import.boats.prompt=Import des navires
wao.import.boats.success=Import des navires réalisé avec succès
+wao.import.contact.failure.dataInputDateAfterObservationEndDate=
+wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers=
+wao.import.contact.failure.invalidObservationBeginDate=
+wao.import.contact.failure.mismatchCompanyForObserver=
+wao.import.contact.failure.missingComment=
+wao.import.contact.failure.missingCommentAdmin=
+wao.import.contact.failure.missingContactStateMotif=
+wao.import.contact.failure.missingDataInputDate=
+wao.import.contact.failure.missingDataReliability=
+wao.import.contact.failure.missingMainObserver=
+wao.import.contact.failure.missingObservationBeginDate=
+wao.import.contact.failure.missingObservationEndDate=
+wao.import.contact.failure.missingObservedDataControl=
+wao.import.contact.failure.missingObserver=
+wao.import.contact.failure.missingRestitution=
+wao.import.contact.failure.observationEndDateAfterToday=
+wao.import.contact.failure.observationEndDateBeforeBeginDate=
+wao.import.contact.failure.transmissionDateBeforeDataInputDate=
+wao.import.contact.failure.unwantedContactStateMotif=
wao.import.contactStateMotives.prompt=Import des motifs de refus
wao.import.contactStateMotives.success=Import des motifs de refus réalisé avec succès
wao.import.fishingZones.prompt=Import des zones de pêches
@@ -134,7 +153,7 @@
wao.ui.contacts.title=%s contacts trouvés
wao.ui.contacts.validation=Validations
wao.ui.contacts.validation.failure=Une erreur est survenue %s
-wao.ui.contacts.validation.failure.not.updatable=Vous n'avez pas les droits pour modifier ce contact \: %s
+wao.ui.contacts.validation.failure.not.updatable=Vous n'avez pas les droits suffisants pour modifier le contact
wao.ui.contacts.validation.failure.not.valid=Le contact n'a pas pu être validé pour la raison suivante \: %s
wao.ui.contacts.validation.to.accept.state.success=Le contact a été accepté avec succès
wao.ui.contacts.validation.to.reject.state.success=Le contact a été rejeté avec succès
1
0