Pollen-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
- November
- October
- September
- August
- 3196 discussions
27 Apr '14
See <http://ci.chorem.org/jenkins/job/pollen-nightly/10/changes>
Changes:
[garandel] un template pour creation/edition/vote de sondage
[Tony CHEMIT] refs #885 : move to Topia3 stack
[garandel] update create and vote page
------------------------------------------
[...truncated 1726 lines...]
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] Scan 104 files header done in 148.175ms.
[INFO]
* uptodate header on 11 files.
* add header on 93 files.
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ pollen-persistence ---
[INFO] Compiling 86 source files to <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- animal-sniffer-maven-plugin:1.10:check (default) @ pollen-persistence ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java17:1.0
[INFO]
[INFO] --- jredmine-maven-plugin:1.8.1:generate-changes (jredmine-generate-changes) @ pollen-persistence ---
[INFO] Skipping goal (skipGenerateChanges flag is on).
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ pollen-persistence ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ pollen-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ pollen-persistence ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ pollen-persistence ---
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ pollen-persistence ---
[INFO] Building jar: <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO]
[INFO] >>> maven-source-plugin:2.2.1:jar (attach-sources) @ pollen-persistence >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (ensure-no-container-api) @ pollen-persistence ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ pollen-persistence ---
[INFO]
[INFO] --- helper-maven-plugin:2.1:share-server-secret (get-redmine-login) @ pollen-persistence ---
[INFO] Skipping goal (runOnce flag is on and goal was already executed).
[INFO]
[INFO] --- eugene-maven-plugin:2.9-SNAPSHOT:generate (generate-entities) @ pollen-persistence ---
[INFO] Process phase [zargo] for one entry.
[INFO] No file generated.
[INFO] Process phase [xmi] for one entry.
[INFO] No file generated.
[INFO] Process phase [model] for one entry.
WARN [pool-1-thread-1 for channel] (AbstractObjectModelReader.java:294) loadModelTagValue - Invalid model tag value [model.tagValue.String] : the tagvalue 'String' is unkown.
[INFO] No file generated.
[INFO] Process phase [java] for one entry.
[INFO] Apply generator JavaEnumerationTransformer
[INFO] Apply generator TopiaMetaTransformer
[INFO] No file generated.
[WARNING] Failed to getClass for org.apache.maven.plugin.source.SourceJarMojo
[INFO]
[INFO] <<< maven-source-plugin:2.2.1:jar (attach-sources) @ pollen-persistence <<<
[INFO]
[INFO] --- maven-source-plugin:2.2.1:jar (attach-sources) @ pollen-persistence ---
[INFO] Building jar: <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO]
[INFO] --- maven-javadoc-plugin:2.9.1:jar (attach-javadocs) @ pollen-persistence ---
[INFO] Building jar: <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/pollen-persistence…>
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ pollen-persistence ---
[INFO]
[INFO] --- helper-maven-plugin:2.1:share-server-secret (get-pgp-passphrase) @ pollen-persistence ---
[INFO] Exporting server [gpg-signer] username in ${gpg.keyname}
[INFO] Exporting server [gpg-signer] password in ${gpg.passphrase}
[INFO]
[INFO] --- helper-maven-plugin:2.1:collect-files (collect-build-artifacts) @ pollen-persistence ---
[INFO] Loaded <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/target/collect-art…>
[INFO] Copying pollen-persistence-2.0-SNAPSHOT.jar to <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/target/collect/org…>
[INFO] Copying THIRD-PARTY.properties to <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/target/collect/org…>
[INFO] Copying pollen-persistence-2.0-SNAPSHOT-sources.jar to <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/target/collect/org…>
[INFO] Copying pollen-persistence-2.0-SNAPSHOT-javadoc.jar to <http://ci.chorem.org/jenkins/job/pollen-nightly/ws/trunk/target/collect/org…>
[INFO]
[INFO] --- helper-maven-plugin:2.1:collect-files (collect-build-attachements) @ pollen-persistence ---
[WARNING] Skipping goal (No file to collect).
[INFO]
[INFO] --- maven-gpg-plugin:1.5:sign (sign-artifacts) @ pollen-persistence ---
[INFO]
[INFO] --- maven-dependency-plugin:2.8:analyze-only (analyze) @ pollen-persistence ---
[INFO] Used declared dependencies found:
[INFO] com.google.guava:guava:jar:16.0.1:compile
[INFO] org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] org.nuiton.topia:topia-persistence:jar:3.0-SNAPSHOT:compile
[WARNING] Unused declared dependencies found:
[WARNING] commons-codec:commons-codec:jar:1.9:compile
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Pollen ............................................ SUCCESS [ 31.689 s]
[INFO] Pollen :: VoteCounting (Api) ...................... SUCCESS [ 13.061 s]
[INFO] Pollen :: VoteCounting :: Normal .................. SUCCESS [ 4.288 s]
[INFO] Pollen :: VoteCounting :: Percentage .............. SUCCESS [ 4.142 s]
[INFO] Pollen :: VoteCounting :: Condorcet ............... SUCCESS [ 4.065 s]
[INFO] Pollen :: VoteCounting :: Number .................. SUCCESS [ 4.350 s]
[INFO] Pollen :: VoteCounting :: Borda ................... SUCCESS [ 4.042 s]
[INFO] Pollen :: VoteCounting :: Instant Runoff .......... SUCCESS [ 3.971 s]
[INFO] Pollen :: VoteCounting :: Coombs .................. SUCCESS [ 3.882 s]
[INFO] Pollen :: VoteCounting (Aggregator) ............... SUCCESS [ 1.482 s]
[INFO] Pollen :: Persistence ............................. FAILURE [ 21.887 s]
[INFO] Pollen :: Service ................................. SKIPPED
[INFO] Pollen :: Rest Api ................................ SKIPPED
[INFO] Pollen :: UI (CanJS) .............................. SKIPPED
[INFO] Pollen :: UI (Angular) ............................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:40 min
[INFO] Finished at: 2014-04-26T01:02:10+01:00
[INFO] Final Memory: 65M/286M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:analyze-only (analyze) on project pollen-persistence: Dependency problems found -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:analyze-only (analyze) on project pollen-persistence: Dependency problems found
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
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:745)
Caused by: org.apache.maven.plugin.MojoExecutionException: Dependency problems found
at org.apache.maven.plugin.dependency.analyze.AbstractAnalyzeMojo.execute(AbstractAnalyzeMojo.java:188)
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/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :pollen-persistence
Sending e-mails to: pollen-commits(a)list.chorem.org chemit+chorem-ci(a)codelutin.com
channel stopped
Skipping sonar analysis due to bad build status FAILURE
Failed to send e-mail to garandel because no e-mail address is known, and no default e-mail domain is configured
1
2
Build failed in Jenkins: pollen-nightly » Pollen :: Persistence #10
by admin+ci-chorem.org@codelutin.com 27 Apr '14
by admin+ci-chorem.org@codelutin.com 27 Apr '14
27 Apr '14
See <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
Changes:
[Tony CHEMIT] refs #885 : move to Topia3 stack
------------------------------------------
[...truncated 46 lines...]
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/eug… (2 KB at 49.2 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/nuiton/eugene… (2 KB at 4.2 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/nuiton/eugene…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/eug…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/nuiton/eug… (2 KB at 51.2 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/nuiton/eugene… (2 KB at 4.2 KB/sec)
[INFO] Process phase [zargo] for one entry.
[INFO] Generate one file in 57.382ms.
[INFO] Process phase [xmi] for one entry.
[INFO] Generate one file in 2.893s.
[INFO] Process phase [model] for one entry.
WARN [pool-1-thread-1 for channel] (AbstractObjectModelReader.java:294) loadModelTagValue - Invalid model tag value [model.tagValue.String] : the tagvalue 'String' is unkown.
[INFO] No file generated.
[INFO] Process phase [java] for one entry.
[INFO] Apply generator JavaEnumerationTransformer
[INFO] Apply generator TopiaMetaTransformer
[INFO] Generate 92 files in 372.936ms.
[INFO]
[INFO] --- license-maven-plugin:1.6:update-project-license (attach-licenses) @ pollen-persistence ---
[INFO] Will create or update license file [agpl_v3] to <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO]
[INFO] --- license-maven-plugin:1.6:add-third-party (attach-licenses) @ pollen-persistence ---
[INFO] Load missing file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/mch…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/com/mchange/c3p0/…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/mchange/c3p0/0.9.2.1/c3p0-0.9.2.1-t…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/mch…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/com/mchange/mchan…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/mchange/mchange-commons-java/0.2.3.…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/apache/common…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/3.3.2/…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/hib…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/hibernate/hib…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/hibernate/hibernate-c3p0/4.3.5.Fina…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/hib…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/hibernate/jav…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/hibernate/javax/persistence/hiberna…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/moc…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/mockito/mocki…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/mockito/mockito-core/1.9.5/mockito-…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/nui…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/nui… (855 B at 13.0 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/nuiton/nuiton…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/nuiton/nuiton… (855 B at 9.3 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/nuiton/nuiton-utils/2.7.1/nuiton-ut…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/nuiton/nuiton-utils/2.7.1/nuiton-ut… (855 B at 2.2 KB/sec)
[INFO] Detects third party descriptor /var/local/forge/data/chorem.org/maven/repository/org/nuiton/nuiton-utils/2.7.1/nuiton-utils-2.7.1-third-party.properties
[INFO] Load missing file /var/local/forge/data/chorem.org/maven/repository/org/nuiton/nuiton-utils/2.7.1/nuiton-utils-2.7.1-third-party.properties
[INFO] Missing file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…> is up-to-date.
[INFO] Writing third-party file to <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] Regenerate missing license file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] Will attach third party file from <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ pollen-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 12 resources
[INFO] Copying 2 resources
[INFO]
[INFO] --- license-maven-plugin:1.6:update-file-header (update-file-header) @ pollen-persistence ---
[INFO] Will search files to update from root <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] Will search files to update from root <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] Scan 104 files header done in 148.175ms.
[INFO]
* uptodate header on 11 files.
* add header on 93 files.
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ pollen-persistence ---
[INFO] Compiling 86 source files to <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- animal-sniffer-maven-plugin:1.10:check (default) @ pollen-persistence ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java17:1.0
[INFO]
[INFO] --- jredmine-maven-plugin:1.8.1:generate-changes (jredmine-generate-changes) @ pollen-persistence ---
[INFO] Skipping goal (skipGenerateChanges flag is on).
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ pollen-persistence ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ pollen-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ pollen-persistence ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ pollen-persistence ---
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ pollen-persistence ---
[INFO] Building jar: <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO]
[INFO] >>> maven-source-plugin:2.2.1:jar (attach-sources) @ pollen-persistence >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (ensure-no-container-api) @ pollen-persistence ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ pollen-persistence ---
[INFO]
[INFO] --- helper-maven-plugin:2.1:share-server-secret (get-redmine-login) @ pollen-persistence ---
[INFO] Skipping goal (runOnce flag is on and goal was already executed).
[INFO]
[INFO] --- eugene-maven-plugin:2.9-SNAPSHOT:generate (generate-entities) @ pollen-persistence ---
[INFO] Process phase [zargo] for one entry.
[INFO] No file generated.
[INFO] Process phase [xmi] for one entry.
[INFO] No file generated.
[INFO] Process phase [model] for one entry.
WARN [pool-1-thread-1 for channel] (AbstractObjectModelReader.java:294) loadModelTagValue - Invalid model tag value [model.tagValue.String] : the tagvalue 'String' is unkown.
[INFO] No file generated.
[INFO] Process phase [java] for one entry.
[INFO] Apply generator JavaEnumerationTransformer
[INFO] Apply generator TopiaMetaTransformer
[INFO] No file generated.
[WARNING] Failed to getClass for org.apache.maven.plugin.source.SourceJarMojo
[INFO]
[INFO] <<< maven-source-plugin:2.2.1:jar (attach-sources) @ pollen-persistence <<<
[INFO]
[INFO] --- maven-source-plugin:2.2.1:jar (attach-sources) @ pollen-persistence ---
[INFO] Building jar: <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO]
[INFO] --- maven-javadoc-plugin:2.9.1:jar (attach-javadocs) @ pollen-persistence ---
[INFO] Building jar: <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-pe…>
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ pollen-persistence ---
[INFO]
[INFO] --- helper-maven-plugin:2.1:share-server-secret (get-pgp-passphrase) @ pollen-persistence ---
[INFO] Exporting server [gpg-signer] username in ${gpg.keyname}
[INFO] Exporting server [gpg-signer] password in ${gpg.passphrase}
[INFO]
[INFO] --- helper-maven-plugin:2.1:collect-files (collect-build-artifacts) @ pollen-persistence ---
[INFO] Loaded /var/local/forge/data/chorem.org/jenkins/workspace/pollen-nightly/trunk/target/collect-artifacts.txt
[INFO] Copying pollen-persistence-2.0-SNAPSHOT.jar to /var/local/forge/data/chorem.org/jenkins/workspace/pollen-nightly/trunk/target/collect/org.chorem.pollen--pollen-persistence/pollen-persistence-2.0-SNAPSHOT.jar
[INFO] Copying THIRD-PARTY.properties to /var/local/forge/data/chorem.org/jenkins/workspace/pollen-nightly/trunk/target/collect/org.chorem.pollen--pollen-persistence/THIRD-PARTY.properties
[INFO] Copying pollen-persistence-2.0-SNAPSHOT-sources.jar to /var/local/forge/data/chorem.org/jenkins/workspace/pollen-nightly/trunk/target/collect/org.chorem.pollen--pollen-persistence/pollen-persistence-2.0-SNAPSHOT-sources.jar
[INFO] Copying pollen-persistence-2.0-SNAPSHOT-javadoc.jar to /var/local/forge/data/chorem.org/jenkins/workspace/pollen-nightly/trunk/target/collect/org.chorem.pollen--pollen-persistence/pollen-persistence-2.0-SNAPSHOT-javadoc.jar
[INFO]
[INFO] --- helper-maven-plugin:2.1:collect-files (collect-build-attachements) @ pollen-persistence ---
[WARNING] Skipping goal (No file to collect).
[INFO]
[INFO] --- maven-gpg-plugin:1.5:sign (sign-artifacts) @ pollen-persistence ---
[INFO]
[INFO] --- maven-dependency-plugin:2.8:analyze-only (analyze) @ pollen-persistence ---
[INFO] Used declared dependencies found:
[INFO] com.google.guava:guava:jar:16.0.1:compile
[INFO] org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] org.nuiton.topia:topia-persistence:jar:3.0-SNAPSHOT:compile
[WARNING] Unused declared dependencies found:
[WARNING] commons-codec:commons-codec:jar:1.9:compile
[JENKINS] Archiving disabled
1
2
r3881 - in trunk: pollen-persistence pollen-persistence/src/license pollen-persistence/src/main/java/org/chorem/pollen/persistence pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity pollen-rest-api pollen-rest-api/src/main/java/org/chorem/pollen/rest/api pollen-rest-api/src/test/java/org/chorem/pollen/rest/api pollen-services
by tchemit@users.chorem.org 27 Apr '14
by tchemit@users.chorem.org 27 Apr '14
27 Apr '14
Author: tchemit
Date: 2014-04-27 19:12:24 +0200 (Sun, 27 Apr 2014)
New Revision: 3881
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3881
Log:
optimze dependencies + add missing license headers
Modified:
trunk/pollen-persistence/pom.xml
trunk/pollen-persistence/src/license/THIRD-PARTY.properties
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenTopiaPersistenceContext.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUsers.java
trunk/pollen-rest-api/pom.xml
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
trunk/pollen-services/pom.xml
Modified: trunk/pollen-persistence/pom.xml
===================================================================
--- trunk/pollen-persistence/pom.xml 2014-04-27 16:47:39 UTC (rev 3880)
+++ trunk/pollen-persistence/pom.xml 2014-04-27 17:12:24 UTC (rev 3881)
@@ -27,10 +27,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- </dependency>
<dependency>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/pollen-persistence/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/pollen-persistence/src/license/THIRD-PARTY.properties 2014-04-27 16:47:39 UTC (rev 3880)
+++ trunk/pollen-persistence/src/license/THIRD-PARTY.properties 2014-04-27 17:12:24 UTC (rev 3881)
@@ -1,13 +1,18 @@
# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
+# - AL 2.0
# - Apache License 2.0
+# - Apache License, version 2.0
# - BSD License
# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
# - Common Development and Distribution License
# - Common Public License Version 1.0
+# - Eclipse Distribution License (EDL), Version 1.0
+# - Eclipse Public License (EPL), Version 1.0
+# - Eclipse Public License, Version 1.0
# - GNU General Public License, Version 2 with the Classpath Exception
-# - GNU Lesser General Public License, version 2.1
+# - GNU Lesser General Public License, Version 2.1
# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - Lesser General Public License (LGPL) v 3.0
# - Lesser General Public License (LPGL)
@@ -15,13 +20,13 @@
# - MIT License
# - MPL 1.1
# - New BSD License
+# - Public Domain
# - The Apache Software License, Version 2.0
-# - The H2 License, Version 1.0
# - The MIT License
-# - license.txt
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Sun Jun 02 18:32:57 CEST 2013
+#Sun Apr 27 18:43:51 CEST 2014
+commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=BSD License
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java 2014-04-27 16:47:39 UTC (rev 3880)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java 2014-04-27 17:12:24 UTC (rev 3881)
@@ -1,5 +1,26 @@
package org.chorem.pollen.persistence;
+/*
+ * #%L
+ * Pollen :: Persistence
+ * %%
+ * Copyright (C) 2009 - 2014 CodeLutin
+ * %%
+ * 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 org.nuiton.topia.persistence.TopiaPersistenceContext;
import org.nuiton.topia.persistence.support.TopiaHibernateSupport;
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenTopiaPersistenceContext.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenTopiaPersistenceContext.java 2014-04-27 16:47:39 UTC (rev 3880)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenTopiaPersistenceContext.java 2014-04-27 17:12:24 UTC (rev 3881)
@@ -1,5 +1,26 @@
package org.chorem.pollen.persistence;
+/*
+ * #%L
+ * Pollen :: Persistence
+ * %%
+ * Copyright (C) 2009 - 2014 CodeLutin
+ * %%
+ * 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 org.nuiton.topia.persistence.TopiaIdFactory;
import org.nuiton.topia.persistence.internal.HibernateProvider;
import org.nuiton.topia.persistence.internal.TopiaHibernateSessionRegistry;
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUsers.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUsers.java 2014-04-27 16:47:39 UTC (rev 3880)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUsers.java 2014-04-27 17:12:24 UTC (rev 3881)
@@ -1,5 +1,26 @@
package org.chorem.pollen.persistence.entity;
+/*
+ * #%L
+ * Pollen :: Persistence
+ * %%
+ * Copyright (C) 2009 - 2014 CodeLutin
+ * %%
+ * 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%
+ */
+
/**
* Created on 4/25/14.
*
Modified: trunk/pollen-rest-api/pom.xml
===================================================================
--- trunk/pollen-rest-api/pom.xml 2014-04-27 16:47:39 UTC (rev 3880)
+++ trunk/pollen-rest-api/pom.xml 2014-04-27 17:12:24 UTC (rev 3881)
@@ -24,7 +24,6 @@
<artifactId>pollen-persistence</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pollen-services</artifactId>
@@ -32,10 +31,19 @@
</dependency>
<dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.debux.webmotion</groupId>
<artifactId>webmotion</artifactId>
</dependency>
-
<dependency>
<groupId>org.debux.webmotion</groupId>
<artifactId>webmotion-unittest</artifactId>
@@ -45,6 +53,10 @@
<groupId>org.nuiton.web</groupId>
<artifactId>nuiton-web</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ </dependency>
<dependency>
<groupId>javax</groupId>
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java 2014-04-27 16:47:39 UTC (rev 3880)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java 2014-04-27 17:12:24 UTC (rev 3881)
@@ -1,5 +1,26 @@
package org.chorem.pollen.rest.api;
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * %%
+ * Copyright (C) 2009 - 2014 CodeLutin
+ * %%
+ * 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 org.chorem.pollen.services.PollenSecurityContext;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.service.AuthService;
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java 2014-04-27 16:47:39 UTC (rev 3880)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java 2014-04-27 17:12:24 UTC (rev 3881)
@@ -1,5 +1,26 @@
package org.chorem.pollen.rest.api;
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * %%
+ * Copyright (C) 2009 - 2014 CodeLutin
+ * %%
+ * 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 org.apache.commons.lang3.SystemUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2014-04-27 16:47:39 UTC (rev 3880)
+++ trunk/pollen-services/pom.xml 2014-04-27 17:12:24 UTC (rev 3881)
@@ -24,7 +24,16 @@
<dependency>
<groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ </dependency>
+ <!--dependency>
+ <groupId>org.nuiton.topia</groupId>
<artifactId>topia-junit</artifactId>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
@@ -54,6 +63,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
<!--dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
1
0
27 Apr '14
Jenkins build became unstable: pollen-ci » Pollen :: Rest Api #9
by admin+ci-chorem.org@codelutin.com 27 Apr '14
by admin+ci-chorem.org@codelutin.com 27 Apr '14
27 Apr '14
Author: tchemit
Date: 2014-04-27 18:47:39 +0200 (Sun, 27 Apr 2014)
New Revision: 3880
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3880
Log:
technical stack is nearly ok
Added:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenTopiaPersistenceContext.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
Removed:
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenApplicationContext.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiServiceContext.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServices.java
trunk/pollen-rest-api/src/test/resources/pollen.properties
Modified:
trunk/pollen-rest-api/pom.xml
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java
trunk/pollen-rest-api/src/main/resources/mapping
trunk/pollen-rest-api/src/main/webapp/WEB-INF/web.xml
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
trunk/pollen-services/pom.xml
trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
trunk/pom.xml
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -0,0 +1,15 @@
+package org.chorem.pollen.persistence;
+
+import org.nuiton.topia.persistence.TopiaPersistenceContext;
+import org.nuiton.topia.persistence.support.TopiaHibernateSupport;
+
+/**
+ * Created on 4/27/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public interface PollenPersistenceContext extends TopiaPersistenceContext, PollenTopiaDaoSupplier {
+
+ TopiaHibernateSupport getHibernateSupport();
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenTopiaPersistenceContext.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenTopiaPersistenceContext.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenTopiaPersistenceContext.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -0,0 +1,20 @@
+package org.chorem.pollen.persistence;
+
+import org.nuiton.topia.persistence.TopiaIdFactory;
+import org.nuiton.topia.persistence.internal.HibernateProvider;
+import org.nuiton.topia.persistence.internal.TopiaHibernateSessionRegistry;
+import org.nuiton.topia.persistence.support.TopiaListenableSupport;
+
+public class PollenTopiaPersistenceContext extends AbstractPollenTopiaPersistenceContext {
+
+ public PollenTopiaPersistenceContext(HibernateProvider hibernateProvider,
+ TopiaListenableSupport listenableSupport,
+ TopiaIdFactory topiaIdFactory,
+ TopiaHibernateSessionRegistry sessionRegistry) {
+ super(hibernateProvider,
+ listenableSupport,
+ topiaIdFactory,
+ sessionRegistry);
+ }
+
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenTopiaPersistenceContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-rest-api/pom.xml
===================================================================
--- trunk/pollen-rest-api/pom.xml 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/pom.xml 2014-04-27 16:47:39 UTC (rev 3880)
@@ -92,16 +92,6 @@
</dependency>
<dependency>
- <groupId>org.nuiton.jpa</groupId>
- <artifactId>nuiton-jpa-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.nuiton.jpa</groupId>
- <artifactId>nuiton-jpa-junit</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
</dependency>
Deleted: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenApplicationContext.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenApplicationContext.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenApplicationContext.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -1,166 +0,0 @@
-package org.chorem.pollen.rest.api;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.PropertyConfigurator;
-import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
-import org.chorem.pollen.services.DefaultPollenServiceContext;
-import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.config.PollenServiceConfig;
-import org.nuiton.i18n.I18n;
-import org.nuiton.i18n.init.DefaultI18nInitializer;
-import org.nuiton.i18n.init.I18nInitializer;
-
-import java.io.Closeable;
-import java.io.File;
-import java.util.Locale;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenApplicationContext implements Closeable {
-
- private static Log log = LogFactory.getLog(PollenApplicationContext.class);
-
- protected static final String APPLICATION_CONTEXT_PARAMETER = "pollen_PollenApplicationContext";
-
- protected static PollenTopiaApplicationContext topiaApplicationContext;
-
- protected static PollenServiceConfig applicationConfig;
-
- public static PollenServiceConfig getApplicationConfig() {
- if (applicationConfig == null) {
- applicationConfig = new PollenServiceConfig();
- }
- return applicationConfig;
- }
-
- public static PollenTopiaApplicationContext getTopiaApplicationContext() {
- if (topiaApplicationContext == null) {
- topiaApplicationContext = new PollenTopiaApplicationContext(getApplicationConfig().getTopiaProperties());
- }
- return topiaApplicationContext;
- }
-
- public static void setTopiaApplicationContext(PollenTopiaApplicationContext topiaApplicationContext) {
- PollenApplicationContext.topiaApplicationContext = topiaApplicationContext;
- }
-
- public PollenTopiaPersistenceContext newPersistenceContext() {
-
- PollenTopiaPersistenceContext persistenceContext = getTopiaApplicationContext().newPersistenceContext();
-
- return persistenceContext;
-
- }
-
- public PollenServiceContext newServiceContext(PollenTopiaPersistenceContext persistenceContext, Locale locale) {
-
- DefaultPollenServiceContext newServiceContext =
- new DefaultPollenServiceContext();
-
- PollenServiceConfig applicationConfig = getApplicationConfig();
-
- newServiceContext.setPollenServiceConfig(applicationConfig);
-
- newServiceContext.setPersistenceContext(persistenceContext);
-
- newServiceContext.setLocale(locale);
-
- return newServiceContext;
-
- }
-
- @Override
- public void close() {
-
- if (topiaApplicationContext != null) {
-
- if (log.isInfoEnabled()) {
- log.info("stopping Pollen, will close entity manager factory");
- }
-
- topiaApplicationContext.closeContext();
-
- }
-
- }
-
- public void init() {
-
- if (getApplicationConfig().isLogConfigurationProvided()) {
-
- File log4jConfigurationFile = getApplicationConfig().getLogConfigurationFile();
-
- String log4jConfigurationFileAbsolutePath = log4jConfigurationFile.getAbsolutePath();
-
- if (log4jConfigurationFile.exists()) {
-
- if (log.isInfoEnabled()) {
- log.info("will use logging configuration " + log4jConfigurationFileAbsolutePath);
- }
-
- // reset logger configuration
- LogManager.resetConfiguration();
-
- // use generate log config file
- PropertyConfigurator.configure(log4jConfigurationFileAbsolutePath);
-
- log = LogFactory.getLog(PollenApplicationContext.class);
-
- } else {
- if (log.isWarnEnabled()) {
- log.warn("there is no file " + log4jConfigurationFileAbsolutePath + ". Default logging configuration will be used.");
- }
- }
-
- } else {
- log.info("will use default logging configuration");
- }
-
- I18nInitializer initializer = new DefaultI18nInitializer("pollen");
- // to show none translated sentences
- initializer.setMissingKeyReturnNull(true);
-
- I18n.init(initializer, Locale.FRANCE);
-
-// PollenTopiaPersistenceContext persistenceContext = newPersistenceContext();
-//
-// PollenServiceContext serviceContext = newServiceContext(persistenceContext, Locale.FRANCE);
-//
-// InitWaoService initWaoService = serviceContext.newService(InitWaoService.class);
-//
-// initWaoService.init();
-//
-// persistenceContext.closeContext();
-
- }
-}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -25,14 +25,20 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import com.google.gson.*;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonNull;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.HttpContext;
import org.debux.webmotion.server.mapping.Mapping;
import org.debux.webmotion.server.render.Render;
-import org.nuiton.jpa.api.JpaEntity;
+import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.ObjectUtil;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -97,7 +103,7 @@
Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
@Override
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
- if(src == null) {
+ if (src == null) {
return JsonNull.INSTANCE;
}
return new JsonPrimitive(src.getTime());
@@ -124,20 +130,20 @@
// single object
- if (model instanceof JpaEntity) {
+ if (model instanceof TopiaEntity) {
// entity need to transform it
- JpaEntity jpaEntity = (JpaEntity) model;
+ TopiaEntity topiaEntity = (TopiaEntity) model;
- PollenEntityBinder<JpaEntity> binder = BinderFactory.newBinder(jpaEntity.getClass(), jpaEntity.getClass(), null, PollenEntityBinder.class);
- Map<String, Object> map = binder.obtainProperties(jpaEntity);
+ PollenEntityBinder<TopiaEntity> binder = BinderFactory.newBinder(topiaEntity.getClass(), topiaEntity.getClass(), null, PollenEntityBinder.class);
+ Map<String, Object> map = binder.obtainProperties(topiaEntity);
Map<String, Object> result = Maps.newTreeMap();
for (Map.Entry<String, Object> entry : map.entrySet()) {
String propertyName = entry.getKey();
Object propertyValue = entry.getValue();
- if (propertyValue instanceof JpaEntity) {
+ if (propertyValue instanceof TopiaEntity) {
result.put(propertyName, toMap(propertyValue));
continue;
}
@@ -149,7 +155,7 @@
if (includeCollection != null) {
for (String propertyName : includeCollection) {
- Iterable<?> collectionValue = binder.getCollectionValue(jpaEntity, propertyName);
+ Iterable<?> collectionValue = binder.getCollectionValue(topiaEntity, propertyName);
result.put(propertyName, toMap(collectionValue));
}
@@ -160,7 +166,7 @@
return model;
}
- protected static class PollenEntityBinder<E extends JpaEntity> extends Binder<E, E> {
+ protected static class PollenEntityBinder<E extends TopiaEntity> extends Binder<E, E> {
/** Logger. */
private static final Log log =
@@ -190,7 +196,7 @@
*
* @param source the bean to read
* @return the map of properties obtained indexed by their property name,
- * or an empty map is the given {@code from} is {@code null}.
+ * or an empty map is the given {@code from} is {@code null}.
* @since 2.3
*/
public Map<String, Object> obtainProperties(E source) {
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java (from rev 3879, trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenApplicationContext.java)
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -0,0 +1,216 @@
+package org.chorem.pollen.rest.api;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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 com.google.common.base.Preconditions;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.PropertyConfigurator;
+import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.services.DefaultPollenServiceContext;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.exception.EntityNotFoundException;
+import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
+import org.chorem.pollen.services.service.PollenUserService;
+import org.nuiton.i18n.I18n;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
+import org.nuiton.i18n.init.I18nInitializer;
+
+import java.io.Closeable;
+import java.io.File;
+import java.util.Locale;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenRestApiApplicationContext implements Closeable {
+
+ private static Log log = LogFactory.getLog(PollenRestApiApplicationContext.class);
+
+ protected static PollenRestApiApplicationContext applicationContext;
+
+ public static PollenRestApiApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
+
+ public static void setApplicationContext(PollenRestApiApplicationContext applicationContext) {
+ PollenRestApiApplicationContext.applicationContext = applicationContext;
+ }
+
+ protected AtomicBoolean started;
+
+ protected AtomicBoolean closed;
+
+ protected PollenTopiaApplicationContext topiaApplicationContext;
+
+ protected PollenServiceConfig applicationConfig;
+
+ public static PollenRestApiApplicationContext newApplicationContext() {
+ PollenServiceConfig applicationConfig = new PollenServiceConfig();
+ PollenTopiaApplicationContext pollenTopiaApplicationContext = new PollenTopiaApplicationContext(applicationConfig.getTopiaProperties());
+ PollenRestApiApplicationContext result = new PollenRestApiApplicationContext(applicationConfig, pollenTopiaApplicationContext);
+ return result;
+ }
+
+ protected PollenRestApiApplicationContext(PollenServiceConfig applicationConfig, PollenTopiaApplicationContext topiaApplicationContext) {
+
+ Preconditions.checkNotNull(applicationConfig, "Configuration can not be null!");
+ Preconditions.checkNotNull(topiaApplicationContext, "topiaApplicationContext can not be null!");
+
+ this.applicationConfig = applicationConfig;
+ this.topiaApplicationContext = topiaApplicationContext;
+ this.started = new AtomicBoolean(false);
+ this.closed = new AtomicBoolean(false);
+ }
+
+ public PollenTopiaApplicationContext getTopiaApplicationContext() {
+ return topiaApplicationContext;
+ }
+
+ public PollenServiceConfig getApplicationConfig() {
+ return applicationConfig;
+ }
+
+ public PollenTopiaPersistenceContext newPersistenceContext() {
+
+ PollenTopiaPersistenceContext persistenceContext = topiaApplicationContext.newPersistenceContext();
+ return persistenceContext;
+
+ }
+
+ public PollenServiceContext newServiceContext(PollenPersistenceContext persistenceContext, Locale locale) {
+
+ DefaultPollenServiceContext newServiceContext = new DefaultPollenServiceContext();
+ newServiceContext.setPollenServiceConfig(applicationConfig);
+ newServiceContext.setTopiaApplicationContext(topiaApplicationContext);
+ newServiceContext.setPersistenceContext(persistenceContext);
+ newServiceContext.setLocale(locale);
+ return newServiceContext;
+
+ }
+
+ @Override
+ public void close() {
+
+ if (closed.get()) {
+
+ if (log.isWarnEnabled()) {
+ log.warn("Already closed");
+ }
+ return;
+ }
+
+ if (!started.get()) {
+
+ if (log.isWarnEnabled()) {
+ log.warn("Not started");
+ }
+ return;
+ }
+
+ if (topiaApplicationContext != null) {
+
+ if (log.isInfoEnabled()) {
+ log.info("stopping Pollen, will close persistence context");
+ }
+ topiaApplicationContext.closeContext();
+ }
+
+ closed.set(true);
+ started.set(false);
+ }
+
+ public void init() {
+
+ if (started.get()) {
+
+ if (log.isWarnEnabled()) {
+ log.warn("Already started!");
+ }
+ return;
+ }
+
+ Preconditions.checkState(applicationConfig != null, "No configuration initialized!");
+ Preconditions.checkState(topiaApplicationContext != null, "No topiaApplicationContext initialized!");
+
+ if (applicationConfig.isLogConfigurationProvided()) {
+
+ File log4jConfigurationFile = applicationConfig.getLogConfigurationFile();
+
+ String log4jConfigurationFileAbsolutePath = log4jConfigurationFile.getAbsolutePath();
+
+ if (log4jConfigurationFile.exists()) {
+
+ if (log.isInfoEnabled()) {
+ log.info("will use logging configuration " + log4jConfigurationFileAbsolutePath);
+ }
+
+ // reset logger configuration
+ LogManager.resetConfiguration();
+
+ // use generate log config file
+ PropertyConfigurator.configure(log4jConfigurationFileAbsolutePath);
+
+ log = LogFactory.getLog(PollenRestApiApplicationContext.class);
+
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("there is no file " + log4jConfigurationFileAbsolutePath + ". Default logging configuration will be used.");
+ }
+ }
+
+ } else {
+ log.info("will use default logging configuration");
+ }
+
+ I18nInitializer initializer = new DefaultI18nInitializer("pollen-i18n");
+ // to show none translated sentences
+ initializer.setMissingKeyReturnNull(true);
+
+ I18n.init(initializer, Locale.FRANCE);
+
+ PollenTopiaPersistenceContext persistenceContext = newPersistenceContext();
+
+ try {
+ PollenServiceContext serviceContext = newServiceContext(persistenceContext, Locale.FRANCE);
+ serviceContext.newService(PollenUserService.class).createDefaultUsers();
+ } catch (InvalidPollenUserFormException e) {
+ //Can't happen
+ } catch (EntityNotFoundException e) {
+ //Can't happen
+ } finally {
+ persistenceContext.closeContext();
+ }
+
+ started.set(true);
+ }
+}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java (from rev 3879, trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java)
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -0,0 +1,124 @@
+package org.chorem.pollen.rest.api;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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 org.apache.commons.beanutils.Converter;
+import org.debux.webmotion.server.WebMotionServerListener;
+import org.debux.webmotion.server.call.Call;
+import org.debux.webmotion.server.call.HttpContext;
+import org.debux.webmotion.server.call.ServerContext;
+import org.debux.webmotion.server.handler.ExecutorParametersInjectorHandler;
+import org.debux.webmotion.server.mapping.Mapping;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Type;
+import java.util.Date;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenRestApiApplicationListener implements WebMotionServerListener {
+
+ @Override
+ public void onStart(Mapping mapping, ServerContext serverContext) {
+
+ // ---
+ // init converters
+ // ---
+
+ serverContext.addConverter(new Converter() {
+ @Override
+ public Object convert(Class type, Object value) {
+ Object result = null;
+ if (value != null) {
+ if (value.getClass().isAssignableFrom(Date.class)) {
+ result = value;
+ } else {
+ Object o = ((Object[]) value)[0];
+ String sTime = o.toString();
+ Long time = Long.parseLong(sTime);
+ result = new Date(time);
+ }
+ }
+ return result;
+ }
+
+ }, Date.class);
+
+ // ---
+ // init injectors
+ // ---
+
+ serverContext.addInjector(new ExecutorParametersInjectorHandler.Injector() {
+ @Override
+ public PollenRestApiRequestContext getValue(Mapping m, Call call, String name, Class<?> type, Type generic) {
+ PollenRestApiRequestContext result = null;
+ if (PollenRestApiRequestContext.class.isAssignableFrom(type)) {
+ HttpContext httpContext = call.getContext();
+ HttpServletRequest request = httpContext.getRequest();
+
+ result = PollenRestApiRequestFilter.getRequestContext(request);
+ }
+ return result;
+ }
+ });
+
+ // ---
+ // init application context
+ // ---
+
+ PollenRestApiApplicationContext applicationContext =
+ PollenRestApiApplicationContext.getApplicationContext();
+
+ if (applicationContext == null) {
+
+ // create application context
+ applicationContext = PollenRestApiApplicationContext.newApplicationContext();
+ PollenRestApiApplicationContext.setApplicationContext(applicationContext);
+ applicationContext.init();
+ }
+
+ // push it in context
+ PollenRestApiRequestFilter.setApplicationContext(
+ serverContext.getServletContext(), applicationContext);
+ }
+
+ @Override
+ public void onStop(ServerContext serverContext) {
+
+ // Get application context
+ PollenRestApiApplicationContext applicationContext =
+ PollenRestApiRequestFilter.getApplicationContext(
+ serverContext.getServletContext());
+
+ // close it (and all underlined resources)
+ if (applicationContext != null) {
+ applicationContext.close();
+ }
+ }
+
+}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java (from rev 3879, trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiServiceContext.java)
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -0,0 +1,78 @@
+package org.chorem.pollen.rest.api;
+
+import org.chorem.pollen.services.PollenSecurityContext;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.service.AuthService;
+import org.chorem.pollen.services.service.ChoiceService;
+import org.chorem.pollen.services.service.CommentService;
+import org.chorem.pollen.services.service.FavoriteListService;
+import org.chorem.pollen.services.service.FixturesService;
+import org.chorem.pollen.services.service.PollService;
+import org.chorem.pollen.services.service.PollenUserService;
+import org.chorem.pollen.services.service.SecurityService;
+import org.chorem.pollen.services.service.VoteCountingService;
+import org.chorem.pollen.services.service.VoteService;
+import org.chorem.pollen.services.service.VoterListService;
+
+/**
+ * Created on 4/25/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenRestApiRequestContext {
+
+ protected PollenServiceContext serviceContext;
+
+ public void setServiceContext(PollenServiceContext serviceContext) {
+ this.serviceContext = serviceContext;
+ }
+
+ public void setSecurityContext(PollenSecurityContext securityContext) {
+ serviceContext.setSecurityContext(securityContext);
+ }
+
+ public AuthService getAuthService() {
+ return serviceContext.newService(AuthService.class);
+ }
+
+ public ChoiceService getChoiceService() {
+ return serviceContext.newService(ChoiceService.class);
+ }
+
+ public CommentService getCommentService() {
+ return serviceContext.newService(CommentService.class);
+ }
+
+ public FavoriteListService getFavoriteListService() {
+ return serviceContext.newService(FavoriteListService.class);
+ }
+
+ public PollService getPollService() {
+ return serviceContext.newService(PollService.class);
+ }
+
+ public PollenUserService getPollenUserService() {
+ return serviceContext.newService(PollenUserService.class);
+ }
+
+ public VoteCountingService getVoteCountingService() {
+ return serviceContext.newService(VoteCountingService.class);
+ }
+
+ public VoterListService getVoterListService() {
+ return serviceContext.newService(VoterListService.class);
+ }
+
+ public VoteService getVoteService() {
+ return serviceContext.newService(VoteService.class);
+ }
+
+ public FixturesService getFixturesService() {
+ return serviceContext.newService(FixturesService.class);
+ }
+
+ public SecurityService getSecurityService() {
+ return serviceContext.newService(SecurityService.class);
+ }
+}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java (from rev 3879, trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java)
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -0,0 +1,134 @@
+package org.chorem.pollen.rest.api;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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 org.apache.commons.lang3.StringUtils;
+import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.entity.SessionToken;
+import org.chorem.pollen.services.PollenSecurityContext;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.exception.InvalidSessionTokenException;
+import org.debux.webmotion.server.WebMotionFilter;
+import org.debux.webmotion.server.call.HttpContext;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Locale;
+
+/**
+ * Inject {@link PollenRestApiRequestContext} in services.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenRestApiRequestFilter extends WebMotionFilter {
+
+ protected static final String APPLICATION_CONTEXT_PARAMETER = "pollen_PollenApplicationContext";
+
+ protected static final String REQUEST_POLLEN_REQUEST_CONTEXT = "pollen_PollenRequestContext";
+
+ protected static final String REQUEST_POLLEN_CONNECTED_USER = "pollen_PollenConnectedUser";
+
+ public static final String REQUEST_AUTH_PARAMETER = "auth";
+
+ public static PollenRestApiApplicationContext getApplicationContext(ServletContext servletContext) {
+ PollenRestApiApplicationContext result = (PollenRestApiApplicationContext)
+ servletContext.getAttribute(APPLICATION_CONTEXT_PARAMETER);
+ return result;
+ }
+
+ public static PollenRestApiRequestContext getRequestContext(HttpServletRequest request) {
+ PollenRestApiRequestContext result = (PollenRestApiRequestContext)
+ request.getAttribute(REQUEST_POLLEN_REQUEST_CONTEXT);
+ return result;
+ }
+
+ public static SessionToken getSessionToken(HttpServletRequest request) {
+ SessionToken result = (SessionToken)
+ request.getAttribute(REQUEST_POLLEN_CONNECTED_USER);
+ return result;
+ }
+
+ public static void setApplicationContext(ServletContext servletContext,
+ PollenRestApiApplicationContext applicationContext) {
+ servletContext.setAttribute(APPLICATION_CONTEXT_PARAMETER, applicationContext);
+ }
+
+ public static void setRequestContext(HttpServletRequest request,
+ PollenRestApiRequestContext serviceContext) {
+ request.setAttribute(REQUEST_POLLEN_REQUEST_CONTEXT, serviceContext);
+ }
+
+ public static void setSessionToken(HttpServletRequest request,
+ SessionToken sessionToken) {
+ request.setAttribute(REQUEST_POLLEN_CONNECTED_USER, sessionToken);
+ }
+
+ public void inject(HttpContext context) throws InvalidSessionTokenException {
+
+ PollenRestApiApplicationContext applicationContext =
+ getApplicationContext(context.getServletContext());
+
+ PollenPersistenceContext persistenceContext =
+ PollenTopiaTransactionFilter.getPersistenceContext(context.getRequest());
+
+ //FIXME Reuse user locale
+ PollenServiceContext serviceContext =
+ applicationContext.newServiceContext(persistenceContext, Locale.FRANCE);
+
+ PollenRestApiRequestContext requestContext = new PollenRestApiRequestContext();
+ requestContext.setServiceContext(serviceContext);
+
+ setRequestContext(context.getRequest(), requestContext);
+
+ addSecurityContext(context, requestContext);
+
+ doProcess();
+
+ HttpServletResponse response = context.getResponse();
+ response.addHeader(HttpContext.HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "*");
+ response.addHeader(HttpContext.HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
+ }
+
+ protected void addSecurityContext(HttpContext context,
+ PollenRestApiRequestContext serviceContext) throws InvalidSessionTokenException {
+
+ String[] strings = context.getParameters().get(REQUEST_AUTH_PARAMETER);
+
+ String authParam = strings == null || strings.length < 1 ? null : strings[0];
+
+ SessionToken sessionToken = null;
+
+ if (StringUtils.isNotBlank(authParam)) {
+
+ // find out the userId from this auth
+
+ sessionToken = serviceContext.getAuthService().getUserByAuth(authParam);
+ }
+ PollenSecurityContext securityContext =
+ PollenSecurityContext.newContext(sessionToken);
+ serviceContext.setSecurityContext(securityContext);
+ }
+}
Deleted: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiServiceContext.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiServiceContext.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiServiceContext.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -1,78 +0,0 @@
-package org.chorem.pollen.rest.api;
-
-import org.chorem.pollen.services.PollenSecurityContext;
-import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.service.AuthService;
-import org.chorem.pollen.services.service.ChoiceService;
-import org.chorem.pollen.services.service.CommentService;
-import org.chorem.pollen.services.service.FavoriteListService;
-import org.chorem.pollen.services.service.FixturesService;
-import org.chorem.pollen.services.service.PollService;
-import org.chorem.pollen.services.service.PollenUserService;
-import org.chorem.pollen.services.service.SecurityService;
-import org.chorem.pollen.services.service.VoteCountingService;
-import org.chorem.pollen.services.service.VoteService;
-import org.chorem.pollen.services.service.VoterListService;
-
-/**
- * Created on 4/25/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenRestApiServiceContext {
-
- protected PollenServiceContext serviceContext;
-
- public void setServiceContext(PollenServiceContext serviceContext) {
- this.serviceContext = serviceContext;
- }
-
- public void setSecurityContext(PollenSecurityContext securityContext) {
- serviceContext.setSecurityContext(securityContext);
- }
-
- public AuthService getAuthService() {
- return serviceContext.newService(AuthService.class);
- }
-
- public ChoiceService getChoiceService() {
- return serviceContext.newService(ChoiceService.class);
- }
-
- public CommentService getCommentService() {
- return serviceContext.newService(CommentService.class);
- }
-
- public FavoriteListService getFavoriteListService() {
- return serviceContext.newService(FavoriteListService.class);
- }
-
- public PollService getPollService() {
- return serviceContext.newService(PollService.class);
- }
-
- public PollenUserService getPollenUserService() {
- return serviceContext.newService(PollenUserService.class);
- }
-
- public VoteCountingService getVoteCountingService() {
- return serviceContext.newService(VoteCountingService.class);
- }
-
- public VoterListService getVoterListService() {
- return serviceContext.newService(VoterListService.class);
- }
-
- public VoteService getVoteService() {
- return serviceContext.newService(VoteService.class);
- }
-
- public FixturesService getFixturesService() {
- return serviceContext.newService(FixturesService.class);
- }
-
- public SecurityService getSecurityService() {
- return serviceContext.newService(SecurityService.class);
- }
-}
Deleted: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -1,92 +0,0 @@
-package org.chorem.pollen.rest.api;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 org.apache.commons.lang3.StringUtils;
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
-import org.chorem.pollen.persistence.entity.SessionToken;
-import org.chorem.pollen.services.PollenSecurityContext;
-import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.exception.InvalidSessionTokenException;
-import org.debux.webmotion.server.WebMotionFilter;
-import org.debux.webmotion.server.call.HttpContext;
-
-import javax.servlet.http.HttpServletResponse;
-import java.util.Locale;
-
-/**
- * Inject le service context dans les controlleurs.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenServiceContextFilter extends WebMotionFilter {
-
- public static final String REQUEST_AUTH_PARAMETER = "auth";
-
- public void inject(HttpContext context) throws InvalidSessionTokenException {
-
- PollenApplicationContext applicationContext =
- PollenServices.getApplicationContext(context.getServletContext());
-
- PollenTopiaPersistenceContext persistenceContext =
- PollenServices.getPersistenceContext(context.getRequest());
-
- PollenServiceContext serviceContext =
- applicationContext.newServiceContext(persistenceContext, Locale.FRANCE);
-
- PollenRestApiServiceContext apiContext = new PollenRestApiServiceContext();
- apiContext.setServiceContext(serviceContext);
-
- PollenServices.setServiceContext(context.getRequest(), apiContext);
-
- addSecurityContext(context, apiContext);
-
- doProcess();
-
- HttpServletResponse response = context.getResponse();
- response.addHeader(HttpContext.HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "*");
- response.addHeader(HttpContext.HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
- }
-
- protected void addSecurityContext(HttpContext context,
- PollenRestApiServiceContext serviceContext) throws InvalidSessionTokenException {
-
- String[] strings = context.getParameters().get(REQUEST_AUTH_PARAMETER);
-
- String authParam = strings == null || strings.length < 1 ? null : strings[0];
-
- SessionToken sessionToken = null;
-
- if (StringUtils.isNotBlank(authParam)) {
-
- // find out the userId from this auth
-
- sessionToken = serviceContext.getAuthService().getUserByAuth(authParam);
- }
- PollenSecurityContext securityContext =
- PollenSecurityContext.newContext(sessionToken);
- serviceContext.setSecurityContext(securityContext);
- }
-}
Deleted: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -1,126 +0,0 @@
-package org.chorem.pollen.rest.api;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 org.apache.commons.beanutils.Converter;
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
-import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
-import org.chorem.pollen.services.service.PollenUserService;
-import org.debux.webmotion.server.WebMotionServerListener;
-import org.debux.webmotion.server.call.Call;
-import org.debux.webmotion.server.call.HttpContext;
-import org.debux.webmotion.server.call.ServerContext;
-import org.debux.webmotion.server.handler.ExecutorParametersInjectorHandler;
-import org.debux.webmotion.server.mapping.Mapping;
-
-import javax.servlet.http.HttpServletRequest;
-import java.lang.reflect.Type;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenServiceListener implements WebMotionServerListener {
-
- @Override
- public void onStart(Mapping mapping, ServerContext serverContext) {
- serverContext.addConverter(new Converter() {
- @Override
- public Object convert(Class type, Object value) {
- Object result = null;
- if (value != null) {
- if (value.getClass().isAssignableFrom(Date.class)) {
- result = value;
- } else {
- Object o = ((Object[]) value)[0];
- String sTime = o.toString();
- Long time = Long.parseLong(sTime);
- result = new Date(time);
- }
- }
- return result;
- }
-
- }, Date.class);
- serverContext.addInjector(new PollenServiceContextInjector());
-
- // Create application context
- PollenApplicationContext applicationContext =
- new PollenApplicationContext();
-
- // push it in context
- PollenServices.setApplicationContext(
- serverContext.getServletContext(), applicationContext);
-
- PollenTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext();
-
- try {
- PollenServiceContext serviceContext =
- applicationContext.newServiceContext(persistenceContext, Locale.FRANCE);
- serviceContext.newService(PollenUserService.class).createDefaultUsers();
- } catch (InvalidPollenUserFormException e) {
- //Can't happen
- } catch (EntityNotFoundException e) {
- //Can't happen
- } finally {
- persistenceContext.closeContext();
- }
- }
-
- @Override
- public void onStop(ServerContext serverContext) {
-
- // Get application context
- PollenApplicationContext applicationContext =
- PollenServices.getApplicationContext(
- serverContext.getServletContext());
-
- // close it (and all underlined resources)
- if (applicationContext != null) {
- applicationContext.close();
- }
- }
-
- protected static class PollenServiceContextInjector implements ExecutorParametersInjectorHandler.Injector {
- @Override
- public PollenRestApiServiceContext getValue(Mapping mapping, Call call, String name, Class<?> type, Type generic) {
- PollenRestApiServiceContext result = null;
- if (PollenServiceContext.class.isAssignableFrom(type)) {
- HttpContext httpContext = call.getContext();
- HttpServletRequest request = httpContext.getRequest();
-
- result = PollenServices.getServiceContext(request);
- }
- return result;
- }
- }
-
-
-}
Deleted: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServices.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServices.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServices.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -1,89 +0,0 @@
-package org.chorem.pollen.rest.api;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
-import org.chorem.pollen.persistence.entity.SessionToken;
-import org.nuiton.web.filter.JpaTransactionFilter;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenServices {
-
- protected static final String APPLICATION_CONTEXT_PARAMETER = "pollen_PollenApplicationContext";
-
- protected static final String REQUEST_POLLEN_SERVICE_CONTEXT = "pollen_PollenServiceContext";
-
- protected static final String REQUEST_POLLEN_CONNECTED_USER = "pollen_PollenConnectedUser";
-
- protected static final String REQUEST_ENTITY_MANAGER = JpaTransactionFilter.JPA_TRANSACTION_REQUEST_ATTRIBUTE;
-
- public static PollenApplicationContext getApplicationContext(ServletContext servletContext) {
- PollenApplicationContext result = (PollenApplicationContext)
- servletContext.getAttribute(APPLICATION_CONTEXT_PARAMETER);
- return result;
- }
-
- public static void setApplicationContext(ServletContext servletContext,
- PollenApplicationContext applicationContext) {
- servletContext.setAttribute(APPLICATION_CONTEXT_PARAMETER, applicationContext);
- }
-
-
- public static PollenRestApiServiceContext getServiceContext(HttpServletRequest request) {
- PollenRestApiServiceContext result = (PollenRestApiServiceContext)
- request.getAttribute(REQUEST_POLLEN_SERVICE_CONTEXT);
- return result;
- }
-
- public static void setServiceContext(HttpServletRequest request,
- PollenRestApiServiceContext serviceContext) {
- request.setAttribute(REQUEST_POLLEN_SERVICE_CONTEXT, serviceContext);
- }
-
-
- public static PollenTopiaPersistenceContext getPersistenceContext(HttpServletRequest request) {
- PollenTopiaPersistenceContext result = (PollenTopiaPersistenceContext)
- request.getAttribute(REQUEST_ENTITY_MANAGER);
- return result;
- }
-
- public static SessionToken getSessionToken(HttpServletRequest request) {
- SessionToken result = (SessionToken)
- request.getAttribute(REQUEST_POLLEN_CONNECTED_USER);
- return result;
- }
-
- public static void setSessionToken(HttpServletRequest request,
- SessionToken sessionToken) {
- request.setAttribute(REQUEST_POLLEN_CONNECTED_USER, sessionToken);
- }
-}
\ No newline at end of file
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -23,9 +23,9 @@
* #L%
*/
-import com.google.common.base.Preconditions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.web.filter.TypedTopiaTransactionFilter;
@@ -34,20 +34,18 @@
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
-public class PollenTopiaTransactionFilter extends TypedTopiaTransactionFilter<PollenTopiaPersistenceContext> {
+public class PollenTopiaTransactionFilter extends TypedTopiaTransactionFilter<PollenPersistenceContext> {
private static final Log log =
LogFactory.getLog(PollenTopiaTransactionFilter.class);
- protected PollenApplicationContext applicationContext;
-
- protected PollenTopiaTransactionFilter() {
- super(PollenTopiaPersistenceContext.class);
+ public PollenTopiaTransactionFilter() {
+ super(PollenPersistenceContext.class);
}
@Override
- protected PollenTopiaPersistenceContext beginTransaction(ServletRequest request) throws TopiaException {
- PollenApplicationContext applicationContext = getApplicationContext(request);
+ protected PollenPersistenceContext beginTransaction(ServletRequest request) throws TopiaException {
+ PollenRestApiApplicationContext applicationContext = PollenRestApiRequestFilter.getApplicationContext(request.getServletContext());
PollenTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext();
return persistenceContext;
}
@@ -62,14 +60,4 @@
}
}
- protected PollenApplicationContext getApplicationContext(ServletRequest request) {
- if (applicationContext == null) {
- applicationContext = PollenServices.getApplicationContext(
- request.getServletContext());
-
- Preconditions.checkNotNull(applicationContext, "Could not find application context at ServletContext#pollen_PollenApplicationContext");
- }
- return applicationContext;
- }
-
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.SessionToken;
-import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.UserInvalidPasswordException;
import org.debux.webmotion.server.WebMotionController;
@@ -37,15 +37,15 @@
*/
public class AuthService extends WebMotionController {
- public SessionToken login(PollenRestApiServiceContext context, String login, String password) throws UserInvalidPasswordException, EntityNotFoundException {
+ public SessionToken login(PollenRestApiRequestContext context, String login, String password) throws UserInvalidPasswordException, EntityNotFoundException {
return context.getAuthService().login(login, password);
}
- public void lostPassword(PollenRestApiServiceContext context, String login) throws EntityNotFoundException {
+ public void lostPassword(PollenRestApiRequestContext context, String login) throws EntityNotFoundException {
context.getAuthService().lostPassword(login);
}
- public void logout(PollenRestApiServiceContext context, String login, String token) throws EntityNotFoundException {
+ public void logout(PollenRestApiRequestContext context, String login, String token) throws EntityNotFoundException {
context.getAuthService().logout(login, token);
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.Choice;
-import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidChoiceFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -39,28 +39,28 @@
*/
public class ChoiceService extends WebMotionController {
- public List<Choice> getChoices(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ public List<Choice> getChoices(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject((String) null);
List<Choice> choices = context.getChoiceService().getChoices(pollId);
return choices;
}
- public Choice getChoice(PollenRestApiServiceContext context, String pollId, String choiceId) throws EntityNotFoundException {
+ public Choice getChoice(PollenRestApiRequestContext context, String pollId, String choiceId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(choiceId);
return context.getChoiceService().getChoice(pollId, choiceId);
}
- public Choice addChoice(PollenRestApiServiceContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
+ public Choice addChoice(PollenRestApiRequestContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getChoiceService().addChoice(pollId, choice);
}
- public Choice editChoice(PollenRestApiServiceContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
+ public Choice editChoice(PollenRestApiRequestContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
context.getSecurityService().prepareSubject(choice);
return context.getChoiceService().editChoice(pollId, choice);
}
- public void deleteChoice(PollenRestApiServiceContext context, String pollId, String choiceId) throws EntityNotFoundException {
+ public void deleteChoice(PollenRestApiRequestContext context, String pollId, String choiceId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(choiceId);
context.getChoiceService().deleteChoice(pollId, choiceId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.Comment;
-import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidCommentFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -39,28 +39,28 @@
*/
public class CommentService extends WebMotionController {
- public List<Comment> getComments(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ public List<Comment> getComments(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
List<Comment> comments = context.getCommentService().getComments(pollId);
return comments;
}
- public Comment getComment(PollenRestApiServiceContext context, String pollId, String commentId) throws EntityNotFoundException {
+ public Comment getComment(PollenRestApiRequestContext context, String pollId, String commentId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(commentId);
return context.getCommentService().getComment(pollId, commentId);
}
- public Comment addComment(PollenRestApiServiceContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
+ public Comment addComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getCommentService().addComment(pollId, comment);
}
- public Comment editComment(PollenRestApiServiceContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
+ public Comment editComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
context.getSecurityService().prepareSubject(comment);
return context.getCommentService().editComment(pollId, comment);
}
- public void deleteComment(PollenRestApiServiceContext context, String pollId, String commentId) throws EntityNotFoundException {
+ public void deleteComment(PollenRestApiRequestContext context, String pollId, String commentId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(commentId);
context.getCommentService().deleteComment(pollId, commentId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -25,7 +25,7 @@
import org.chorem.pollen.persistence.entity.FavoriteList;
import org.chorem.pollen.persistence.entity.FavoriteListMember;
-import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.FavoriteListImportException;
import org.chorem.pollen.services.exception.InvalidFavoriteListFormException;
@@ -43,53 +43,53 @@
*/
public class FavoriteListService extends WebMotionController {
- public List<FavoriteList> getFavoriteLists(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
+ public List<FavoriteList> getFavoriteLists(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
List<FavoriteList> favoriteLists = context.getFavoriteListService().getFavoriteLists(userId);
return favoriteLists;
}
- public FavoriteList getFavoriteList(PollenRestApiServiceContext context, String userId, String favoriteListId) throws EntityNotFoundException {
+ public FavoriteList getFavoriteList(PollenRestApiRequestContext context, String userId, String favoriteListId) throws EntityNotFoundException {
return context.getFavoriteListService().getFavoriteList(userId, favoriteListId);
}
- public FavoriteList createFavoriteList(PollenRestApiServiceContext context, String userId, FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
+ public FavoriteList createFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
return context.getFavoriteListService().createFavoriteList(userId, favoriteList);
}
- public FavoriteList editFavoriteList(PollenRestApiServiceContext context, String userId, FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
+ public FavoriteList editFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
return context.getFavoriteListService().editFavoriteList(userId, favoriteList);
}
- public void deleteFavoriteList(PollenRestApiServiceContext context, String userId, String favoriteListId) throws EntityNotFoundException {
+ public void deleteFavoriteList(PollenRestApiRequestContext context, String userId, String favoriteListId) throws EntityNotFoundException {
context.getFavoriteListService().deleteFavoriteList(userId, favoriteListId);
}
- public int importFavoriteListMembersFromCsv(PollenRestApiServiceContext context, String userId, String favoriteListId, File csvFile) throws EntityNotFoundException, FavoriteListImportException {
+ public int importFavoriteListMembersFromCsv(PollenRestApiRequestContext context, String userId, String favoriteListId, File csvFile) throws EntityNotFoundException, FavoriteListImportException {
return context.getFavoriteListService().importFavoriteListMembersFromCsv(userId, favoriteListId, csvFile);
}
- public int importFavoriteListMembersFromLdap(PollenRestApiServiceContext context, String userId, String favoriteListId, String ldap) throws EntityNotFoundException, FavoriteListImportException {
+ public int importFavoriteListMembersFromLdap(PollenRestApiRequestContext context, String userId, String favoriteListId, String ldap) throws EntityNotFoundException, FavoriteListImportException {
return context.getFavoriteListService().importFavoriteListMembersFromLdap(userId, favoriteListId, ldap);
}
- public List<FavoriteListMember> getMembers(PollenRestApiServiceContext context, String userId, String favoriteListId) throws EntityNotFoundException {
+ public List<FavoriteListMember> getMembers(PollenRestApiRequestContext context, String userId, String favoriteListId) throws EntityNotFoundException {
List<FavoriteListMember> members = context.getFavoriteListService().getFavoriteListMembers(userId, favoriteListId);
return members;
}
- public FavoriteListMember getMember(PollenRestApiServiceContext context, String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
+ public FavoriteListMember getMember(PollenRestApiRequestContext context, String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
return context.getFavoriteListService().getFavoriteListMember(userId, favoriteListId, memberId);
}
- public FavoriteListMember addMember(PollenRestApiServiceContext context, String userId, String favoriteListId, FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
+ public FavoriteListMember addMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
return context.getFavoriteListService().addFavoriteListMember(userId, favoriteListId, member);
}
- public FavoriteListMember editMember(PollenRestApiServiceContext context, String userId, String favoriteListId, FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
+ public FavoriteListMember editMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
return context.getFavoriteListService().editFavoriteListMember(userId, favoriteListId, member);
}
- public void removeMember(PollenRestApiServiceContext context, String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
+ public void removeMember(PollenRestApiRequestContext context, String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
context.getFavoriteListService().removeFavoriteListMember(userId, favoriteListId, memberId);
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -25,7 +25,7 @@
import org.chorem.pollen.persistence.entity.ChoiceType;
import org.chorem.pollen.persistence.entity.Poll;
-import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -41,60 +41,60 @@
*/
public class PollService extends WebMotionController {
- public Poll getNewPoll(PollenRestApiServiceContext context, String userId, ChoiceType choiceType) throws EntityNotFoundException {
+ public Poll getNewPoll(PollenRestApiRequestContext context, String userId, ChoiceType choiceType) throws EntityNotFoundException {
return context.getPollService().getNewPoll(userId, choiceType);
}
- public Set<Poll> getPolls(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
+ public Set<Poll> getPolls(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
Set<Poll> polls = context.getPollService().getPolls(userId);
return polls;
}
- public Set<Poll> getCreatedPolls(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
+ public Set<Poll> getCreatedPolls(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
Set<Poll> polls = context.getPollService().getCreatedPolls(userId);
return polls;
}
- public Set<Poll> getInvitedPolls(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
+ public Set<Poll> getInvitedPolls(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
Set<Poll> polls = context.getPollService().getInvitedPolls(userId);
return polls;
}
- public Set<Poll> getParticipatedPolls(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
+ public Set<Poll> getParticipatedPolls(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
Set<Poll> polls = context.getPollService().getParticipatedPolls(userId);
return polls;
}
- public Poll getPoll(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ public Poll getPoll(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject((String) null);
return context.getPollService().getPoll(pollId);
}
- public Poll createPoll(PollenRestApiServiceContext context, String userId, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
+ public Poll createPoll(PollenRestApiRequestContext context, String userId, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
return context.getPollService().createPoll(userId, poll);
}
- public Poll editPoll(PollenRestApiServiceContext context, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
+ public Poll editPoll(PollenRestApiRequestContext context, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
context.getSecurityService().prepareSubject(poll);
return context.getPollService().editPoll(poll);
}
- public void deletePoll(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ public void deletePoll(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
context.getPollService().deletePoll(pollId);
}
- public Poll clonePoll(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ public Poll clonePoll(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
return context.getPollService().clonePoll(pollId);
}
- public File closePoll(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ public File closePoll(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
return context.getPollService().closePoll(pollId);
}
- public File exportPoll(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ public File exportPoll(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
return context.getPollService().exportPoll(pollId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.PollenUser;
-import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
@@ -41,34 +41,34 @@
*/
public class PollenUserService extends WebMotionController {
- public List<PollenUser> getUsers(PollenRestApiServiceContext context) {
+ public List<PollenUser> getUsers(PollenRestApiRequestContext context) {
List<PollenUser> users = context.getPollenUserService().getUsers();
return users;
}
- public PollenUser getUser(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
+ public PollenUser getUser(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
return context.getPollenUserService().getUser(userId);
}
- public PollenUser createUser(PollenRestApiServiceContext context,
+ public PollenUser createUser(PollenRestApiRequestContext context,
PollenUser user,
boolean generatePassword) throws EntityNotFoundException, InvalidPollenUserFormException {
return context.getPollenUserService().createUser(user, generatePassword);
}
- public PollenUser editUser(PollenRestApiServiceContext context,
+ public PollenUser editUser(PollenRestApiRequestContext context,
PollenUser user) throws EntityNotFoundException, InvalidPollenUserFormException {
return context.getPollenUserService().editUser(user);
}
- public void validateUserEmail(PollenRestApiServiceContext context,
+ public void validateUserEmail(PollenRestApiRequestContext context,
String userId,
String token) throws EntityNotFoundException, UserInvalidEmailActivationTokenException {
context.getPollenUserService().validateUserEmail(userId, token);
}
- public void changePassword(PollenRestApiServiceContext context,
+ public void changePassword(PollenRestApiRequestContext context,
String userId,
String oldPassword,
String newPassword) throws EntityNotFoundException, UserInvalidPasswordException {
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -23,7 +23,7 @@
* #L%
*/
-import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.PollResult;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.debux.webmotion.server.WebMotionController;
@@ -36,7 +36,7 @@
*/
public class VoteCountingService extends WebMotionController {
- public PollResult getResult(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ public PollResult getResult(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
return context.getVoteCountingService().getResult(pollId);
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.Vote;
-import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidVoteFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -39,28 +39,28 @@
*/
public class VoteService extends WebMotionController {
- public List<Vote> getVotes(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ public List<Vote> getVotes(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
List<Vote> votes = context.getVoteService().getVotes(pollId);
return votes;
}
- public Vote getVote(PollenRestApiServiceContext context, String pollId, String voteId) throws EntityNotFoundException {
+ public Vote getVote(PollenRestApiRequestContext context, String pollId, String voteId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(voteId);
return context.getVoteService().getVote(pollId, voteId);
}
- public Vote addVote(PollenRestApiServiceContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
+ public Vote addVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getVoteService().addVote(pollId, vote);
}
- public Vote editVote(PollenRestApiServiceContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
+ public Vote editVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
context.getSecurityService().prepareSubject(vote);
return context.getVoteService().editVote(pollId, vote);
}
- public void deleteVote(PollenRestApiServiceContext context, String pollId, String voteId) throws EntityNotFoundException {
+ public void deleteVote(PollenRestApiRequestContext context, String pollId, String voteId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(voteId);
context.getVoteService().deleteVote(pollId, voteId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -25,7 +25,7 @@
import org.chorem.pollen.persistence.entity.VoterList;
import org.chorem.pollen.persistence.entity.VoterListMember;
-import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidVoterListFormException;
import org.chorem.pollen.services.exception.InvalidVoterListMemberFormException;
@@ -42,58 +42,58 @@
*/
public class VoterListService extends WebMotionController {
- public VoterList importFavoriteList(PollenRestApiServiceContext context, String userId, String pollId, String favoriteListId) throws EntityNotFoundException {
+ public VoterList importFavoriteList(PollenRestApiRequestContext context, String userId, String pollId, String favoriteListId) throws EntityNotFoundException {
return context.getVoterListService().importFavoriteList(userId, pollId, favoriteListId);
}
- public List<VoterList> getVoterLists(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ public List<VoterList> getVoterLists(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
List<VoterList> voterLists = context.getVoterListService().getVoterLists(pollId);
return voterLists;
}
- public VoterList getVoterList(PollenRestApiServiceContext context, String pollId, String voterListId) throws EntityNotFoundException {
+ public VoterList getVoterList(PollenRestApiRequestContext context, String pollId, String voterListId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(voterListId);
return context.getVoterListService().getVoterList(pollId, voterListId);
}
- public VoterList createVoterList(PollenRestApiServiceContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
+ public VoterList createVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getVoterListService().addVoterList(pollId, voterList);
}
- public VoterList editVoterList(PollenRestApiServiceContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
+ public VoterList editVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
context.getSecurityService().prepareSubject(voterList);
return context.getVoterListService().editVoterList(pollId, voterList);
}
- public void deleteVoterList(PollenRestApiServiceContext context, String pollId, String voterListId) throws EntityNotFoundException {
+ public void deleteVoterList(PollenRestApiRequestContext context, String pollId, String voterListId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(voterListId);
context.getVoterListService().deleteVoterList(pollId, voterListId);
}
- public Set<VoterListMember> getMembers(PollenRestApiServiceContext context, String pollId, String voterListId) throws EntityNotFoundException {
+ public Set<VoterListMember> getMembers(PollenRestApiRequestContext context, String pollId, String voterListId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(voterListId);
Set<VoterListMember> members = context.getVoterListService().getVoterListMembers(pollId, voterListId);
return members;
}
- public VoterListMember getMember(PollenRestApiServiceContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException {
+ public VoterListMember getMember(PollenRestApiRequestContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(memberId);
return context.getVoterListService().getVoterListMember(pollId, voterListId, memberId);
}
- public VoterListMember addMember(PollenRestApiServiceContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
+ public VoterListMember addMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
context.getSecurityService().prepareSubject(member);
return context.getVoterListService().addVoterListMember(pollId, voterListId, member);
}
- public VoterListMember editMember(PollenRestApiServiceContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
+ public VoterListMember editMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
context.getSecurityService().prepareSubject(member);
return context.getVoterListService().editVoterListMember(pollId, voterListId, member);
}
- public void deleteMember(PollenRestApiServiceContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException {
+ public void deleteMember(PollenRestApiRequestContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(memberId);
context.getVoterListService().deleteVoterListMember(pollId, voterListId, memberId);
}
Modified: trunk/pollen-rest-api/src/main/resources/mapping
===================================================================
--- trunk/pollen-rest-api/src/main/resources/mapping 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/resources/mapping 2014-04-27 16:47:39 UTC (rev 3880)
@@ -2,11 +2,11 @@
package.filters=org.chorem.pollen.rest.api
package.actions=org.chorem.pollen.rest.api.v1
package.errors=org.chorem.pollen.rest.api.v1
-server.listener.class=org.chorem.pollen.rest.api.PollenServiceListener
+server.listener.class=org.chorem.pollen.rest.api.PollenRestApiApplicationListener
default.render=org.chorem.pollen.rest.api.PollenRender
[filters]
-* /* PollenServiceContextFilter.inject
+* /* PollenRestApiRequestFilter.inject
#- une fois un object lié à PollenUser, c'est immuable.
Modified: trunk/pollen-rest-api/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/pollen-rest-api/src/main/webapp/WEB-INF/web.xml 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/main/webapp/WEB-INF/web.xml 2014-04-27 16:47:39 UTC (rev 3880)
@@ -31,14 +31,14 @@
<display-name>Pollen REST Api</display-name>
<filter>
- <filter-name>jpaTransaction</filter-name>
+ <filter-name>topiaTransaction</filter-name>
<filter-class>
- org.chorem.pollen.rest.api.PollenJpaTransactionFilter
+ org.chorem.pollen.rest.api.PollenTopiaTransactionFilter
</filter-class>
</filter>
<filter-mapping>
- <filter-name>jpaTransaction</filter-name>
+ <filter-name>topiaTransaction</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -23,25 +23,17 @@
* #L%
*/
-import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.services.PollenFixtures;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.service.FixturesService;
import org.debux.webmotion.unittest.WebMotionJUnit;
-import org.hibernate.cfg.Environment;
import org.junit.After;
+import org.junit.Before;
-import java.io.File;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Locale;
-import java.util.Map;
-import java.util.UUID;
/**
* TODO
@@ -54,25 +46,23 @@
/** Logger. */
private static final Log log = LogFactory.getLog(AbstractPollenRestApiTest.class);
- protected PollenApplicationContext applicationContext;
+ protected PollenFixtures fixtures;
- protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
+ @Before
+ public void launchServer() throws Exception {
- protected PollenFixtures fixtures;
+ PollenRestApiApplicationContext applicationContext = FakePollenRestApiApplicationContext.newApplicationContext();
+ applicationContext.init();
+ PollenRestApiApplicationContext.setApplicationContext(applicationContext);
+ super.launchServer();
+ }
+
@After
public void tearDown() {
- for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
+ PollenRestApiApplicationContext applicationContext = PollenRestApiApplicationContext.getApplicationContext();
- if (log.isTraceEnabled()) {
- log.trace("closing transaction " + openedTransaction);
- }
-
- openedTransaction.closeContext();
-
- }
-
if (applicationContext != null) {
if (log.isTraceEnabled()) {
@@ -82,117 +72,13 @@
}
}
- protected PollenTopiaApplicationContext newTopiaApplicationContext(String dataBase) {
-
- Map<String, String> hibernateH2Config = new HashMap<>();
-
- hibernateH2Config.putAll(PollenApplicationContext.getApplicationConfig().getTopiaProperties());
-
- hibernateH2Config.put(Environment.DRIVER, org.h2.Driver.class.getName());
- hibernateH2Config.put(Environment.DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
- hibernateH2Config.put(Environment.USER, "sa");
- hibernateH2Config.put(Environment.PASS, "sa");
- hibernateH2Config.put(Environment.HBM2DDL_AUTO, "update");
-
- File tempDirFile = SystemUtils.getJavaIoTmpDir();
-
- File databaseFile = new File(tempDirFile, dataBase);
-
- String h2dataPath = databaseFile.getAbsolutePath() + File.separator + "h2data";
-
- String jdbcUrl = "jdbc:h2:file:" + h2dataPath;
-
- hibernateH2Config.put(Environment.URL, jdbcUrl);
-
- if (log.isTraceEnabled()) {
- log.trace("will store H2 data in " + h2dataPath);
- log.trace("allTopiaParameters = " + hibernateH2Config);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("jdbc url is\n" + jdbcUrl);
- }
-
- PollenTopiaApplicationContext applicationContext = new PollenTopiaApplicationContext(hibernateH2Config);
-
- if (log.isTraceEnabled()) {
- log.trace("created root context " + applicationContext);
- }
-
- return applicationContext;
- }
-
- public PollenApplicationContext getApplicationContext() {
- if (applicationContext == null) {
-
- // prepare db
-
- String databaseName = UUID.randomUUID().toString();
-
- PollenTopiaApplicationContext pollenTopiaApplicationContext = newTopiaApplicationContext(databaseName);
-
- PollenApplicationContext.setTopiaApplicationContext(pollenTopiaApplicationContext);
-
- applicationContext =
- new PollenApplicationContext() {
-
-
- @Override
- public PollenServiceContext newServiceContext(PollenTopiaPersistenceContext persistenceContext, Locale locale) {
-
- FakePollenServiceContext serviceContext = new FakePollenServiceContext();
- serviceContext.setPersistenceContext(persistenceContext);
- serviceContext.setPollenServiceConfig(applicationConfig);
-
- return serviceContext;
-
- }
-
- @Override
- public PollenTopiaPersistenceContext newPersistenceContext() {
- PollenTopiaPersistenceContext pollenTopiaPersistenceContext = super.newPersistenceContext();
- openedTransactions.add(pollenTopiaPersistenceContext);
- return pollenTopiaPersistenceContext;
- }
- };
- }
- return applicationContext;
- }
-
- protected PollenTopiaPersistenceContext newPersistenceContext() {
-
- if (applicationContext == null) {
-
- applicationContext = getApplicationContext();
- }
-
- PollenTopiaPersistenceContext persistenceContext;
-
- persistenceContext = applicationContext.newPersistenceContext();
-
- if (log.isTraceEnabled()) {
- log.trace("opened transaction " + persistenceContext);
- }
-
- openedTransactions.add(persistenceContext);
-
- return persistenceContext;
-
- }
-
- protected PollenServiceContext getServiceContext() {
-
- PollenTopiaPersistenceContext entityManager = getApplicationContext().newPersistenceContext();
-
- PollenServiceContext result = applicationContext.newServiceContext(entityManager, Locale.FRANCE);
- return result;
- }
-
protected void loadFixtures(String fixturesSetName) {
+ PollenRestApiApplicationContext applicationContext = PollenRestApiApplicationContext.getApplicationContext();
+ PollenTopiaPersistenceContext entityManager = applicationContext.newPersistenceContext();
+ PollenServiceContext pollenServiceContext = applicationContext.newServiceContext(entityManager, Locale.FRANCE);
- FixturesService fixturesService = getServiceContext().newService(FixturesService.class);
-
+ FixturesService fixturesService = pollenServiceContext.newService(FixturesService.class);
fixtures = fixturesService.loadFixtures(fixturesSetName);
}
@@ -203,8 +89,4 @@
}
-// @Before
-// public void launchServer() throws Exception {
-// runServer();
-// }
}
Added: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java (rev 0)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -0,0 +1,123 @@
+package org.chorem.pollen.rest.api;
+
+import org.apache.commons.lang3.SystemUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.hibernate.cfg.Environment;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Created on 4/27/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class FakePollenRestApiApplicationContext extends PollenRestApiApplicationContext {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(FakePollenRestApiApplicationContext.class);
+
+ protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
+
+ public static PollenRestApiApplicationContext newApplicationContext() {
+ PollenServiceConfig applicationConfig = new PollenServiceConfig();
+ PollenTopiaApplicationContext pollenTopiaApplicationContext = newTopiaApplicationContext(applicationConfig, UUID.randomUUID().toString());
+ PollenRestApiApplicationContext result = new FakePollenRestApiApplicationContext(applicationConfig, pollenTopiaApplicationContext);
+ return result;
+ }
+
+ public FakePollenRestApiApplicationContext(PollenServiceConfig applicationConfig, PollenTopiaApplicationContext pollenTopiaApplicationContext) {
+
+ super(applicationConfig, pollenTopiaApplicationContext);
+ }
+
+ @Override
+ public PollenServiceContext newServiceContext(PollenPersistenceContext persistenceContext, Locale locale) {
+
+ FakePollenServiceContext serviceContext = new FakePollenServiceContext();
+ serviceContext.setPersistenceContext(persistenceContext);
+ serviceContext.setPollenServiceConfig(getApplicationConfig());
+ serviceContext.setTopiaApplicationContext(getTopiaApplicationContext());
+ serviceContext.setLocale(locale);
+
+ return serviceContext;
+ }
+
+ @Override
+ public PollenTopiaPersistenceContext newPersistenceContext() {
+ PollenTopiaPersistenceContext pollenTopiaPersistenceContext = super.newPersistenceContext();
+ openedTransactions.add(pollenTopiaPersistenceContext);
+ return pollenTopiaPersistenceContext;
+ }
+
+ @Override
+ public void close() {
+ if (!closed.get()) {
+
+ for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("closing transaction " + openedTransaction);
+ }
+
+ if (!openedTransaction.isClosed()) {
+ openedTransaction.closeContext();
+ }
+ }
+ openedTransactions.clear();
+ }
+ super.close();
+ }
+
+ protected static PollenTopiaApplicationContext newTopiaApplicationContext(PollenServiceConfig applicationConfig, String dataBase) {
+
+ Map<String, String> hibernateH2Config = new HashMap<>();
+
+ hibernateH2Config.putAll(applicationConfig.getTopiaProperties());
+
+ hibernateH2Config.put(Environment.DRIVER, org.h2.Driver.class.getName());
+ hibernateH2Config.put(Environment.DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
+ hibernateH2Config.put(Environment.USER, "sa");
+ hibernateH2Config.put(Environment.PASS, "sa");
+ hibernateH2Config.put(Environment.HBM2DDL_AUTO, "update");
+
+ File tempDirFile = SystemUtils.getJavaIoTmpDir();
+
+ File databaseFile = new File(tempDirFile, dataBase);
+
+ String h2dataPath = databaseFile.getAbsolutePath() + File.separator + "h2data";
+
+ String jdbcUrl = "jdbc:h2:file:" + h2dataPath;
+
+ hibernateH2Config.put(Environment.URL, jdbcUrl);
+
+ if (log.isTraceEnabled()) {
+ log.trace("will store H2 data in " + h2dataPath);
+ log.trace("allTopiaParameters = " + hibernateH2Config);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("jdbc url is\n" + jdbcUrl);
+ }
+
+ PollenTopiaApplicationContext applicationContext = new PollenTopiaApplicationContext(hibernateH2Config);
+
+ if (log.isTraceEnabled()) {
+ log.trace("created root context " + applicationContext);
+ }
+
+ return applicationContext;
+ }
+}
Property changes on: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/pollen-rest-api/src/test/resources/pollen.properties
===================================================================
--- trunk/pollen-rest-api/src/test/resources/pollen.properties 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-rest-api/src/test/resources/pollen.properties 2014-04-27 16:47:39 UTC (rev 3880)
@@ -1,31 +0,0 @@
-###
-# #%L
-# Pollen :: Rest Api
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2009 - 2013 CodeLutin
-# %%
-# 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%
-###
-javax.persistence.jdbc.driver=org.h2.Driver
-javax.persistence.jdbc.url=jdbc:h2:file:target/pollen/h2data
-javax.persistence.jdbc.user=sa
-javax.persistence.jdbc.password=
-hibernate.dialect=org.hibernate.dialect.H2Dialect
-hibernate.hbm2ddl.auto=update
-hibernate.show_sql=false
-hibernate.format_sql=true
-hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/pom.xml 2014-04-27 16:47:39 UTC (rev 3880)
@@ -83,16 +83,6 @@
</dependency>
<dependency>
- <groupId>org.nuiton.jpa</groupId>
- <artifactId>nuiton-jpa-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.nuiton.jpa</groupId>
- <artifactId>nuiton-jpa-junit</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
</dependency>
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -28,7 +28,8 @@
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
import org.nuiton.util.StringUtil;
@@ -42,17 +43,19 @@
protected PollenServiceConfig pollenServiceConfig;
- protected PollenTopiaPersistenceContext persistenceContext;
+ protected PollenPersistenceContext persistenceContext;
protected PollenSecurityContext securityContext;
protected Locale locale;
+ private PollenTopiaApplicationContext topiaApplicationContext;
+
public void setPollenServiceConfig(PollenServiceConfig pollenServiceConfig) {
this.pollenServiceConfig = pollenServiceConfig;
}
- public void setPersistenceContext(PollenTopiaPersistenceContext persistenceContext) {
+ public void setPersistenceContext(PollenPersistenceContext persistenceContext) {
this.persistenceContext = persistenceContext;
}
@@ -60,6 +63,15 @@
this.securityContext = securityContext;
}
+ public void setTopiaApplicationContext(PollenTopiaApplicationContext topiaApplicationContext) {
+ this.topiaApplicationContext = topiaApplicationContext;
+ }
+
+ @Override
+ public PollenTopiaApplicationContext getTopiaApplicationContext() {
+ return topiaApplicationContext;
+ }
+
public void setLocale(Locale locale) {
this.locale = locale;
}
@@ -90,7 +102,7 @@
}
@Override
- public PollenTopiaPersistenceContext getPersistenceContext() {
+ public PollenPersistenceContext getPersistenceContext() {
return persistenceContext;
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -23,7 +23,8 @@
* #L%
*/
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
import java.util.Date;
@@ -43,8 +44,10 @@
void setSecurityContext(PollenSecurityContext securityContext);
- PollenTopiaPersistenceContext getPersistenceContext();
+ PollenTopiaApplicationContext getTopiaApplicationContext();
+ PollenPersistenceContext getPersistenceContext();
+
PollenServiceConfig getPollenServiceConfig();
<E extends PollenService> E newService(Class<E> serviceClass);
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -37,19 +37,37 @@
protected final Class<? extends TopiaEntity> entityType;
- protected final String entityId;
+ protected final String property;
+ protected final String propertyValue;
+
public EntityNotFoundException(Class<? extends TopiaEntity> entityType,
- String entityId) {
+ String propertyValue) {
+ this(entityType, TopiaEntity.PROPERTY_TOPIA_ID, propertyValue);
+ }
+
+ public EntityNotFoundException(Class<? extends TopiaEntity> entityType,
+ String property,
+ String propertyValue) {
this.entityType = entityType;
- this.entityId = entityId;
+ this.property = property;
+ this.propertyValue = propertyValue;
}
public Class<? extends TopiaEntity> getEntityType() {
return entityType;
}
- public String getEntityId() {
- return entityId;
+ public String getProperty() {
+ return property;
}
+
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+ @Override
+ public String getMessage() {
+ return "Could not find entity (property: " + property + " = " + propertyValue + ") of type: " + entityType;
+ }
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -57,7 +57,7 @@
}
// Create a new session Token
- SessionTokenTopiaDao dao = getPersistenceContext().getSessionTokenDao();
+ SessionTokenTopiaDao dao = getSessionTokenDao();
SessionToken sessionToken = dao.newInstance();
String token = serviceContext.generateToken();
@@ -67,7 +67,7 @@
sessionToken.setCreationDate(serviceContext.getNow());
dao.create(sessionToken);
- getPersistenceContext().commit();
+ commit();
return sessionToken;
}
@@ -75,8 +75,6 @@
public void lostPassword(String login) throws EntityNotFoundException {
Preconditions.checkNotNull(login);
- PollenUserTopiaDao dao = getPersistenceContext().getPollenUserDao();
-
PollenUser user = getUserService().getUserByLogin(login);
// Generate a new password
@@ -84,7 +82,7 @@
String encodedPassword = serviceContext.encodePassword(newPassword);
user.setPassword(encodedPassword);
// dao.update(user);
- getPersistenceContext().commit();
+ commit();
//TODO Notifiy Password changed
if (log.isDebugEnabled()) {
@@ -98,19 +96,18 @@
getUserService().getUserByLogin(login);
+ SessionTokenTopiaDao dao = getSessionTokenDao();
- SessionTokenTopiaDao dao = getPersistenceContext().getSessionTokenDao();
-
SessionToken sessionToken = dao.findByTopiaId(token);
checkEntityExists(SessionToken.class, sessionToken, token);
dao.delete(sessionToken);
- getPersistenceContext().commit();
+ commit();
}
public SessionToken getUserByAuth(String authParam) throws InvalidSessionTokenException {
- SessionToken sessionToken = getPersistenceContext().getSessionTokenDao().findByTopiaId(authParam);
+ SessionToken sessionToken = getSessionTokenDao().findByTopiaId(authParam);
if (sessionToken == null) {
throw new InvalidSessionTokenException();
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -75,8 +75,8 @@
Choice result = saveChoice(poll, choice);
- getPersistenceContext().getPollDao().update(poll);
- getPersistenceContext().commit();
+ getPollDao().update(poll);
+ commit();
//TODO Notify Choice added
return result;
}
@@ -92,8 +92,8 @@
Choice result = saveChoice(poll, choice);
- getPersistenceContext().getChoiceDao().update(choice);
- getPersistenceContext().commit();
+ getChoiceDao().update(choice);
+ commit();
//TODO Notify Choice edited
return result;
}
@@ -108,8 +108,8 @@
poll.removeChoice(choice);
- getPersistenceContext().getPollDao().update(poll);
- getPersistenceContext().commit();
+ getPollDao().update(poll);
+ commit();
//TODO Notify Choice deleted
}
@@ -123,7 +123,7 @@
protected Choice saveChoice(Poll poll,
Choice choice) throws EntityNotFoundException {
- ChoiceTopiaDao choiceDao = getPersistenceContext().getChoiceDao();
+ ChoiceTopiaDao choiceDao = getChoiceDao();
boolean choiceExists = choice.isPersisted();
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -32,7 +32,6 @@
import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidCommentFormException;
-import org.nuiton.jpa.api.JpaEntities;
import java.util.List;
@@ -71,8 +70,8 @@
Comment result = saveComment(poll, comment);
- getPersistenceContext().getPollDao().update(poll);
- getPersistenceContext().commit();
+ getPollDao().update(poll);
+ commit();
return result;
}
@@ -88,8 +87,8 @@
Comment result = saveComment(poll, comment);
- getPersistenceContext().getCommentDao().update(comment);
- getPersistenceContext().commit();
+ getCommentDao().update(comment);
+ commit();
return result;
}
@@ -105,8 +104,8 @@
poll.removeComment(comment);
- getPersistenceContext().getPollDao().update(poll);
- getPersistenceContext().commit();
+ getPollDao().update(poll);
+ commit();
}
protected Comment getComment(Poll poll, String commentId) throws EntityNotFoundException {
@@ -144,7 +143,7 @@
toSave = getComment(poll, comment.getTopiaId());
} else {
- toSave = getPersistenceContext().getCommentDao().newInstance();
+ toSave = getCommentDao().newInstance();
toSave.setPostDate(serviceContext.getNow());
// -- author -- //
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -94,13 +94,13 @@
checkFavoriteListForm(user, favoriteList);
- FavoriteList toSave = getPersistenceContext().getFavoriteListDao().newInstance();
+ FavoriteList toSave = getFavoriteListDao().newInstance();
copyFavoriteList(favoriteList, toSave);
user.addFavoriteList(toSave);
- getPersistenceContext().getPollenUserDao().update(user);
+ getPollenUserDao().update(user);
- getPersistenceContext().commit();
+ commit();
return toSave;
}
@@ -120,8 +120,8 @@
copyFavoriteList(favoriteList, toSave);
- getPersistenceContext().getFavoriteListDao().update(toSave);
- getPersistenceContext().commit();
+ getFavoriteListDao().update(toSave);
+ commit();
return toSave;
}
@@ -135,8 +135,8 @@
user.removeFavoriteList(persisted);
- getPersistenceContext().getPollenUserDao().update(user);
- getPersistenceContext().commit();
+ getPollenUserDao().update(user);
+ commit();
}
public List<FavoriteListMember> getFavoriteListMembers(String userId, String favoriteListId) throws EntityNotFoundException {
@@ -178,13 +178,13 @@
checkFavoriteListMemberForm(favoriteList, member);
FavoriteListMember newMember =
- getPersistenceContext().getFavoriteListMemberDao().newInstance();
+ getFavoriteListMemberDao().newInstance();
copyFavoriteListMember(member, newMember);
favoriteList.addFavoriteListMember(newMember);
- getPersistenceContext().getFavoriteListDao().update(favoriteList);
+ getFavoriteListDao().update(favoriteList);
- getPersistenceContext().commit();
+ commit();
return newMember;
}
@@ -209,9 +209,9 @@
copyFavoriteListMember(member, toSave);
- getPersistenceContext().getFavoriteListMemberDao().update(toSave);
+ getFavoriteListMemberDao().update(toSave);
- getPersistenceContext().commit();
+ commit();
return toSave;
}
@@ -230,8 +230,8 @@
favoriteList.removeFavoriteListMember(member);
- getPersistenceContext().getFavoriteListDao().update(favoriteList);
- getPersistenceContext().commit();
+ getFavoriteListDao().update(favoriteList);
+ commit();
}
public int importFavoriteListMembersFromCsv(String userId,
@@ -307,7 +307,7 @@
throw new FavoriteListImportException(error, null);
}
- FavoriteListMember member = getPersistenceContext().getFavoriteListMemberDao().newInstance();
+ FavoriteListMember member = getFavoriteListMemberDao().newInstance();
member.setName(memberName);
member.setEmail(email);
@@ -326,9 +326,9 @@
IOUtils.closeQuietly(reader);
}
- getPersistenceContext().getFavoriteListDao().update(favoriteList);
+ getFavoriteListDao().update(favoriteList);
- getPersistenceContext().commit();
+ commit();
return result;
}
@@ -403,7 +403,7 @@
throw new FavoriteListImportException(error, null);
}
- FavoriteListMember member = getPersistenceContext().getFavoriteListMemberDao().newInstance();
+ FavoriteListMember member = getFavoriteListMemberDao().newInstance();
member.setName(memberName);
member.setEmail(email);
@@ -414,9 +414,9 @@
throw new FavoriteListImportException("LDAP", ex);
}
- getPersistenceContext().getFavoriteListDao().update(favoriteList);
+ getFavoriteListDao().update(favoriteList);
- getPersistenceContext().commit();
+ commit();
return result;
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -27,13 +27,12 @@
import com.google.common.collect.Maps;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.PollenUserTopiaDao;
import org.chorem.pollen.services.PollenFixtures;
-import javax.persistence.EntityManager;
-import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Map;
@@ -73,13 +72,15 @@
log.info("will restore database with fixture set");
}
- PollenTopiaPersistenceContext persistenceContext = serviceContext.getPersistenceContext();
+ PollenPersistenceContext persistenceContext = serviceContext.getPersistenceContext();
if (cleanDatabase) {
- //FIXME
- //persistenceContext.clearDatabase();
+ PollenTopiaApplicationContext topiaApplicationContext = serviceContext.getTopiaApplicationContext();
+ topiaApplicationContext.dropSchema();
+ topiaApplicationContext.createSchema();
+
}
PollenUserTopiaDao userDao = persistenceContext.getPollenUserDao();
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -53,7 +53,7 @@
public class PollService extends PollenServiceSupport {
public Set<Poll> getPolls(String userId) throws EntityNotFoundException {
- return Sets.newHashSet(getPersistenceContext().getPollDao().findAll());
+ return Sets.newHashSet(getPollDao().findAll());
}
public Set<Poll> getCreatedPolls(String userId) throws EntityNotFoundException {
@@ -61,7 +61,7 @@
getUserService().getUser(userId);
- return getPersistenceContext().getPollDao().findAllCreated(userId);
+ return getPollDao().findAllCreated(userId);
}
public Set<Poll> getInvitedPolls(String userId) throws EntityNotFoundException {
@@ -69,7 +69,7 @@
getUserService().getUser(userId);
- return getPersistenceContext().getPollDao().findAllInvited(userId);
+ return getPollDao().findAllInvited(userId);
}
public Set<Poll> getParticipatedPolls(String userId) throws EntityNotFoundException {
@@ -77,20 +77,20 @@
getUserService().getUser(userId);
- return getPersistenceContext().getPollDao().findAllParticipated(userId);
+ return getPollDao().findAllParticipated(userId);
}
public Poll getPoll(String pollId) throws EntityNotFoundException {
Preconditions.checkNotNull(pollId);
checkPermission(PermissionVerb.readPoll, pollId);
- Poll result = getPersistenceContext().getPollDao().findByTopiaId(pollId);
+ Poll result = getPollDao().findByTopiaId(pollId);
checkEntityExists(Poll.class, result, pollId);
return result;
}
public Poll getNewPoll(String userId, ChoiceType choiceType) throws EntityNotFoundException {
- Poll result = getPersistenceContext().getPollDao().newInstance();
+ Poll result = getPollDao().newInstance();
result.setChoiceType(choiceType);
@@ -104,7 +104,7 @@
// -- creator -- //
- PollenPrincipal creator = getPersistenceContext().getPollenPrincipalDao().newInstance();
+ PollenPrincipal creator = getPollenPrincipalDao().newInstance();
result.setCreator(creator);
if (userId != null) {
@@ -128,8 +128,8 @@
Poll pollToPersist = savePoll(userId, poll);
- getPersistenceContext().getPollDao().create(pollToPersist);
- getPersistenceContext().commit();
+ getPollDao().create(pollToPersist);
+ commit();
return pollToPersist;
}
@@ -143,8 +143,8 @@
Poll toSave = savePoll(null, poll);
- getPersistenceContext().getPollDao().update(toSave);
- getPersistenceContext().commit();
+ getPollDao().update(toSave);
+ commit();
return toSave;
}
@@ -157,8 +157,8 @@
Poll poll = getPoll(pollId);
- getPersistenceContext().getPollDao().delete(poll);
- getPersistenceContext().commit();
+ getPollDao().delete(poll);
+ commit();
if (poll.getCreator().getEmail() != null) {
@@ -173,7 +173,7 @@
Poll poll = getPoll(pollId);
//TODO
- getPersistenceContext().commit();
+ commit();
return null;
}
@@ -183,7 +183,7 @@
Poll poll = getPoll(pollId);
//TODO
- getPersistenceContext().commit();
+ commit();
return null;
}
@@ -205,7 +205,7 @@
toSave = getPoll(poll.getTopiaId());
} else {
- PollTopiaDao dao = getPersistenceContext().getPollDao();
+ PollTopiaDao dao = getPollDao();
toSave = dao.newInstance();
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -27,7 +27,19 @@
import com.google.common.collect.Multimap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.entity.ChoiceTopiaDao;
+import org.chorem.pollen.persistence.entity.CommentTopiaDao;
+import org.chorem.pollen.persistence.entity.FavoriteListMemberTopiaDao;
+import org.chorem.pollen.persistence.entity.FavoriteListTopiaDao;
+import org.chorem.pollen.persistence.entity.PollTopiaDao;
+import org.chorem.pollen.persistence.entity.PollenPrincipalTopiaDao;
+import org.chorem.pollen.persistence.entity.PollenUserTopiaDao;
+import org.chorem.pollen.persistence.entity.SessionTokenTopiaDao;
+import org.chorem.pollen.persistence.entity.VoteToChoiceTopiaDao;
+import org.chorem.pollen.persistence.entity.VoteTopiaDao;
+import org.chorem.pollen.persistence.entity.VoterListMemberTopiaDao;
+import org.chorem.pollen.persistence.entity.VoterListTopiaDao;
import org.chorem.pollen.services.PollenService;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
@@ -73,7 +85,7 @@
return serviceContext.getCleanMail(email);
}
- protected PollenTopiaPersistenceContext getPersistenceContext() {
+ protected PollenPersistenceContext getPersistenceContext() {
return serviceContext.getPersistenceContext();
}
@@ -81,6 +93,8 @@
return serviceContext.getPollenServiceConfig();
}
+ // -- Services -- //
+
protected AuthService getAuthService() {
return newService(AuthService.class);
}
@@ -125,6 +139,64 @@
return serviceContext.newService(serviceClass);
}
+ // -- delegate persistenceContext method -- //
+
+ protected ChoiceTopiaDao getChoiceDao() {
+ return getPersistenceContext().getChoiceDao();
+ }
+
+ protected CommentTopiaDao getCommentDao() {
+ return getPersistenceContext().getCommentDao();
+ }
+
+ protected FavoriteListTopiaDao getFavoriteListDao() {
+ return getPersistenceContext().getFavoriteListDao();
+ }
+
+ protected FavoriteListMemberTopiaDao getFavoriteListMemberDao() {
+ return getPersistenceContext().getFavoriteListMemberDao();
+ }
+
+ protected PollTopiaDao getPollDao() {
+ return getPersistenceContext().getPollDao();
+ }
+
+ protected PollenPrincipalTopiaDao getPollenPrincipalDao() {
+ return getPersistenceContext().getPollenPrincipalDao();
+ }
+
+ protected PollenUserTopiaDao getPollenUserDao() {
+ return getPersistenceContext().getPollenUserDao();
+ }
+
+ protected SessionTokenTopiaDao getSessionTokenDao() {
+ return getPersistenceContext().getSessionTokenDao();
+ }
+
+ protected VoteTopiaDao getVoteDao() {
+ return getPersistenceContext().getVoteDao();
+ }
+
+ protected VoteToChoiceTopiaDao getVoteToChoiceDao() {
+ return getPersistenceContext().getVoteToChoiceDao();
+ }
+
+ protected VoterListTopiaDao getVoterListDao() {
+ return getPersistenceContext().getVoterListDao();
+ }
+
+ protected VoterListMemberTopiaDao getVoterListMemberDao() {
+ return getPersistenceContext().getVoterListMemberDao();
+ }
+
+ public void commit() {
+ getPersistenceContext().commit();
+ }
+
+ public void rollback() {
+ getPersistenceContext().rollback();
+ }
+
// -- check method -- //
protected void checkPermission(PermissionVerb verb, String id) {
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -47,14 +47,14 @@
public class PollenUserService extends PollenServiceSupport implements PollenService {
public List<PollenUser> getUsers() {
- return getPersistenceContext().getPollenUserDao().findAll();
+ return getPollenUserDao().findAll();
}
public PollenUser getUser(String userId) throws EntityNotFoundException {
Preconditions.checkNotNull(userId);
try {
- PollenUser result = getPersistenceContext().getPollenUserDao().findByTopiaId(userId);
+ PollenUser result = getPollenUserDao().findByTopiaId(userId);
return result;
} catch (TopiaNoResultException e) {
throw new EntityNotFoundException(PollenUser.class, userId);
@@ -64,10 +64,10 @@
public PollenUser getUserByLogin(String login) throws EntityNotFoundException {
Preconditions.checkNotNull(login);
try {
- PollenUser result = getPersistenceContext().getPollenUserDao().forLoginEquals(login).findAny();
+ PollenUser result = getPollenUserDao().forLoginEquals(login).findAny();
return result;
} catch (TopiaNoResultException e) {
- throw new EntityNotFoundException(PollenUser.class, login);
+ throw new EntityNotFoundException(PollenUser.class, PollenUser.PROPERTY_LOGIN, login);
}
}
@@ -78,8 +78,8 @@
PollenUser result = savePollenUser(user, generatePassword);
- getPersistenceContext().getPollenUserDao().create(result);
- getPersistenceContext().commit();
+ getPollenUserDao().create(result);
+ commit();
//TODO Notify user created
return result;
}
@@ -91,8 +91,8 @@
PollenUser result = savePollenUser(user, false);
- getPersistenceContext().getPollenUserDao().update(result);
- getPersistenceContext().commit();
+ getPollenUserDao().update(result);
+ commit();
//TODO Notify user edited
return result;
}
@@ -116,8 +116,8 @@
String newEncodedPassword = serviceContext.encodePassword(newPassword);
user.setPassword(newEncodedPassword);
- getPersistenceContext().getPollenUserDao().update(user);
- getPersistenceContext().commit();
+ getPollenUserDao().update(user);
+ commit();
//TODO Notify PasswordChanged
}
@@ -139,20 +139,23 @@
// reset token in database
user.setEmailActivationToken(null);
- getPersistenceContext().getPollenUserDao().update(user);
- getPersistenceContext().commit();
+ getPollenUserDao().update(user);
+ commit();
}
public void createDefaultUsers() throws EntityNotFoundException, InvalidPollenUserFormException {
- PollenUser user = getPersistenceContext().getPollenUserDao().newInstance();
+ if (getPollenUserDao().count() == 0) {
- user.setAdministrator(true);
- String login = "admin";
- user.setLogin(login);
- user.setEmail("admin(a)pollen.org");
- user.setPassword("admin");
- createUser(user, false);
+ PollenUser user = getPollenUserDao().newInstance();
+
+ user.setAdministrator(true);
+ String login = "admin";
+ user.setLogin(login);
+ user.setEmail("admin(a)pollen.org");
+ user.setPassword("admin");
+ createUser(user, false);
+ }
}
protected void checkPollenUserForm(PollenUser user) throws EntityNotFoundException, InvalidPollenUserFormException {
@@ -162,7 +165,7 @@
boolean userExists = user.isPersisted();
PollenUser persisted = userExists ? getUser(user.getTopiaId()) : null;
- PollenUserTopiaDao dao = getPersistenceContext().getPollenUserDao();
+ PollenUserTopiaDao dao = getPollenUserDao();
String userLogin = user.getLogin();
String userEmail = getCleanMail(user.getEmail());
@@ -234,7 +237,7 @@
}
} else {
- toSave = getPersistenceContext().getPollenUserDao().newInstance();
+ toSave = getPollenUserDao().newInstance();
// add a emailValidationToken
emailValidationToken = generateToken();
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -28,17 +28,13 @@
import com.google.common.collect.Sets;
import org.apache.shiro.subject.Subject;
import org.chorem.pollen.persistence.entity.Choice;
-import org.chorem.pollen.persistence.entity.ChoiceTopiaDao;
import org.chorem.pollen.persistence.entity.Comment;
-import org.chorem.pollen.persistence.entity.CommentTopiaDao;
import org.chorem.pollen.persistence.entity.Poll;
-import org.chorem.pollen.persistence.entity.PollTopiaDao;
import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.chorem.pollen.persistence.entity.PollenPrincipalTopiaDao;
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.Polls;
import org.chorem.pollen.persistence.entity.Vote;
-import org.chorem.pollen.persistence.entity.VoteTopiaDao;
import org.chorem.pollen.persistence.entity.VoterListMember;
import org.chorem.pollen.services.PollenSecurityContext;
import org.nuiton.topia.persistence.TopiaEntity;
@@ -248,42 +244,6 @@
return result;
}
- protected CommentTopiaDao commentDao;
-
- protected VoteTopiaDao voteDao;
-
- protected ChoiceTopiaDao choiceDao;
-
- protected PollTopiaDao pollDao;
-
- protected CommentTopiaDao getCommentDao() {
- if (commentDao == null) {
- commentDao = getPersistenceContext().getCommentDao();
- }
- return commentDao;
- }
-
- protected VoteTopiaDao getVoteDao() {
- if (voteDao == null) {
- voteDao = getPersistenceContext().getVoteDao();
- }
- return voteDao;
- }
-
- protected ChoiceTopiaDao getChoiceDao() {
- if (choiceDao == null) {
- choiceDao = getPersistenceContext().getChoiceDao();
- }
- return choiceDao;
- }
-
- protected PollTopiaDao getPollDao() {
- if (pollDao == null) {
- pollDao = getPersistenceContext().getPollDao();
- }
- return pollDao;
- }
-
protected String createSubjectPermission(String people, PermissionVerb verb, TopiaEntity entity) {
return people + ":" + verb.name() + ":" + entity.getTopiaId();
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -73,8 +73,8 @@
Vote result = saveVote(poll, vote);
- getPersistenceContext().getPollDao().update(poll);
- getPersistenceContext().commit();
+ getPollDao().update(poll);
+ commit();
//TODO Notify vote added
return result;
}
@@ -89,8 +89,8 @@
Vote result = saveVote(poll, vote);
- getPersistenceContext().getVoteDao().update(vote);
- getPersistenceContext().commit();
+ getVoteDao().update(vote);
+ commit();
//TODO Notify vote edited
return result;
}
@@ -107,8 +107,8 @@
poll.removeVote(vote);
- getPersistenceContext().getPollDao().update(poll);
- getPersistenceContext().commit();
+ getPollDao().update(poll);
+ commit();
//TODO Notify vote deleted
}
@@ -147,7 +147,7 @@
toSave = getVote(poll, vote.getTopiaId());
} else {
- toSave = getPersistenceContext().getVoteDao().newInstance();
+ toSave = getVoteDao().newInstance();
// toSave.setPostDate(serviceContext.getNow());
// -- author -- //
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -59,14 +59,14 @@
FavoriteList favoriteList = getFavoriteListService().getFavoriteList(userId, favoriteListId);
- VoterListTopiaDao dao = getPersistenceContext().getVoterListDao();
+ VoterListTopiaDao dao = getVoterListDao();
VoterList result = dao.newInstance();
result.setName(favoriteList.getName());
result.setWeight(1d);
VoterListMemberTopiaDao voterListMemberDao =
- getPersistenceContext().getVoterListMemberDao();
+ getVoterListMemberDao();
for (FavoriteListMember favoriteListMember : favoriteList.getFavoriteListMember()) {
@@ -78,8 +78,8 @@
poll.addVoterList(result);
- getPersistenceContext().getPollDao().update(poll);
- getPersistenceContext().commit();
+ getPollDao().update(poll);
+ commit();
return result;
}
@@ -112,8 +112,8 @@
VoterList result = saveVoterList(poll, voterList);
- getPersistenceContext().getPollDao().update(poll);
- getPersistenceContext().commit();
+ getPollDao().update(poll);
+ commit();
return result;
}
@@ -127,8 +127,8 @@
VoterList result = saveVoterList(poll, voterList);
- getPersistenceContext().getVoterListDao().update(voterList);
- getPersistenceContext().commit();
+ getVoterListDao().update(voterList);
+ commit();
return result;
}
@@ -142,8 +142,8 @@
poll.removeVoterList(voterList);
- getPersistenceContext().getPollDao().update(poll);
- getPersistenceContext().commit();
+ getPollDao().update(poll);
+ commit();
}
public Set<VoterListMember> getVoterListMembers(String pollId, String voterListId) throws EntityNotFoundException {
@@ -180,8 +180,8 @@
VoterListMember result = saveVoterListMember(voterList, member);
- getPersistenceContext().getVoterListDao().update(voterList);
- getPersistenceContext().commit();
+ getVoterListDao().update(voterList);
+ commit();
return result;
}
@@ -198,8 +198,8 @@
VoterListMember result = saveVoterListMember(voterList, member);
- getPersistenceContext().getVoterListMemberDao().update(member);
- getPersistenceContext().commit();
+ getVoterListMemberDao().update(member);
+ commit();
return result;
}
@@ -213,9 +213,9 @@
VoterListMember member = getVoterListMember(voterList, memberId);
voterList.removeVoterListMember(member);
-// getPersistenceContext().getVoterListDao().merge(voterList);
+// getVoterListDao().merge(voterList);
- getPersistenceContext().commit();
+ commit();
}
protected VoterList getVoterList(Poll poll, String voterListId) throws EntityNotFoundException {
@@ -245,7 +245,7 @@
toSave = getVoterList(poll, voterList.getTopiaId());
} else {
VoterListTopiaDao voterListDao =
- getPersistenceContext().getVoterListDao();
+ getVoterListDao();
toSave = voterListDao.newInstance();
poll.addVoterList(toSave);
@@ -275,7 +275,7 @@
} else {
VoterListMemberTopiaDao voterListMemberDao =
- getPersistenceContext().getVoterListMemberDao();
+ getVoterListMemberDao();
toSave = voterListMemberDao.newInstance();
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-04-27 16:47:39 UTC (rev 3880)
@@ -34,18 +34,12 @@
import org.chorem.pollen.services.config.PollenServiceConfig;
import org.chorem.pollen.services.exception.AbstractInvalidFormException;
import org.chorem.pollen.services.service.FixturesService;
-import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.internal.SessionFactoryServiceRegistryImpl;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.After;
import org.junit.Assert;
import org.nuiton.util.DateUtil;
-import javax.persistence.EntityManager;
import java.io.File;
-import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -179,6 +173,7 @@
PollenTopiaPersistenceContext persistenceContext = newPersistenceContext();
serviceContext.setPersistenceContext(persistenceContext);
serviceContext.setDate(DateUtil.createDate(2, 11, 2009));
+ serviceContext.setTopiaApplicationContext(getApplicationContext());
}
return serviceContext;
@@ -189,8 +184,6 @@
FixturesService fixturesService = getServiceContext().newService(FixturesService.class);
fixtures = fixturesService.loadFixtures(fixturesSetName);
-
-// getServiceContext().getPersistenceContext().getHibernateSupport().getHibernateSession().clear();
}
protected <E> E fixture(String id) {
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-04-26 19:20:22 UTC (rev 3879)
+++ trunk/pom.xml 2014-04-27 16:47:39 UTC (rev 3880)
@@ -283,36 +283,6 @@
</dependency>
<dependency>
- <groupId>org.nuiton.jpa</groupId>
- <artifactId>nuiton-jpa-api</artifactId>
- <version>${nuitonJpaVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>org.hibernate.javax.persistence</groupId>
- <artifactId>hibernate-jpa-2.0-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.nuiton.jpa</groupId>
- <artifactId>nuiton-jpa-hibernate</artifactId>
- <version>${nuitonJpaVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>org.hibernate.javax.persistence</groupId>
- <artifactId>hibernate-jpa-2.0-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.nuiton.jpa</groupId>
- <artifactId>nuiton-jpa-junit</artifactId>
- <version>${nuitonJpaVersion}</version>
- </dependency>
-
- <dependency>
<groupId>com.esotericsoftware.yamlbeans</groupId>
<artifactId>yamlbeans</artifactId>
<version>1.06</version>
1
0
r3879 - in trunk/pollen-persistence/src/main: java/org/chorem/pollen/persistence/entity xmi
by tchemit@users.chorem.org 26 Apr '14
by tchemit@users.chorem.org 26 Apr '14
26 Apr '14
Author: tchemit
Date: 2014-04-26 21:20:22 +0200 (Sat, 26 Apr 2014)
New Revision: 3879
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3879
Log:
refs #885
Removed:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollImpl.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java
trunk/pollen-persistence/src/main/xmi/pollen.properties
Deleted: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollImpl.java 2014-04-25 17:14:38 UTC (rev 3878)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollImpl.java 2014-04-26 19:20:22 UTC (rev 3879)
@@ -1,107 +0,0 @@
-package org.chorem.pollen.persistence.entity;
-
-/*
- * #%L
- * Pollen :: Persistence
- * $Id$
- * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-persistence/src/main/java/org… $
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 com.google.common.collect.Sets;
-
-import java.util.Date;
-import java.util.Set;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollImpl extends PollAbstract {
-
- private static final long serialVersionUID = 1L;
-
- //FIXME Remove this
- public boolean isFreePoll() {
- return Polls.isPollFree(this);
- }
-
- //FIXME Remove this
- public boolean isRestrictedPoll() {
- return Polls.isPollRestricted(this);
- }
-
- //FIXME Remove this
- public boolean isGroupPoll() {
- return Polls.isPollGroup(this);
- }
-
- //FIXME Remove this
- public boolean isStarted(Date currentDate) {
- return beginDate == null || beginDate.before(currentDate);
- }
-
- //FIXME Remove this
- public boolean isRunning(Date currentDate) {
- return !isClosed() &&
- isStarted(currentDate) &&
- !isFinished(currentDate);
- }
-
- //FIXME Remove this
- public boolean isFinished(Date currentDate) {
- return endDate != null && currentDate.after(endDate);
- }
-
- //FIXME Remove this
- public boolean isAddChoiceStarted(Date currentDate) {
- return isChoiceAddAllowed() &&
- (beginChoiceDate == null || beginChoiceDate.before(currentDate));
- }
-
- //FIXME Remove this
- public boolean isAddChoiceRunning(Date currentDate) {
- return isChoiceAddAllowed() &&
- !isClosed() &&
- !isFinished(currentDate) &&
- isAddChoiceStarted(currentDate) &&
- !isAddChoiceFinished(currentDate);
- }
-
- //FIXME Remove this
- public boolean isAddChoiceFinished(Date currentDate) {
- return !isChoiceAddAllowed() ||
- (endChoiceDate != null && endChoiceDate.before(currentDate));
- }
-
- //FIXME Remove this
- public Set<VoterListMember> getAllVoters() {
- Set<VoterListMember> result = Sets.newHashSet();
- if (!isVoterListEmpty()) {
- for (VoterList list : getVoterList()) {
-
- if (!list.isVoterListMemberEmpty()) {
- result.addAll(list.getVoterListMember());
- }
- }
- }
- return result;
- }
-}
Deleted: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java 2014-04-25 17:14:38 UTC (rev 3878)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java 2014-04-26 19:20:22 UTC (rev 3879)
@@ -1,40 +0,0 @@
-package org.chorem.pollen.persistence.entity;
-
-/*
- * #%L
- * Pollen :: Persistence
- * $Id$
- * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-persistence/src/main/java/org… $
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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%
- */
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenUserImpl extends PollenUserAbstract {
-
- private static final long serialVersionUID = 1L;
-
- public boolean isEmailActivated() {
- return emailActivationToken == null;
- }
-
-}
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java 2014-04-25 17:14:38 UTC (rev 3878)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java 2014-04-26 19:20:22 UTC (rev 3879)
@@ -54,6 +54,37 @@
return beginDate == null || beginDate.before(currentDate);
}
+ public boolean isRunning(Poll poll, Date currentDate) {
+ return !poll.isClosed() &&
+ isStarted(poll, currentDate) &&
+ !isFinished(poll, currentDate);
+ }
+
+ public boolean isFinished(Poll poll, Date currentDate) {
+ Date endDate = poll.getEndDate();
+ return endDate != null && currentDate.after(endDate);
+ }
+
+ public boolean isAddChoiceStarted(Poll poll, Date currentDate) {
+ Date beginChoiceDate = poll.getBeginChoiceDate();
+ return poll.isChoiceAddAllowed() &&
+ (beginChoiceDate == null || beginChoiceDate.before(currentDate));
+ }
+
+ public boolean isAddChoiceRunning(Poll poll, Date currentDate) {
+ return poll.isChoiceAddAllowed() &&
+ !poll.isClosed() &&
+ !isFinished(poll, currentDate) &&
+ isAddChoiceStarted(poll, currentDate) &&
+ !isAddChoiceFinished(poll, currentDate);
+ }
+
+ public boolean isAddChoiceFinished(Poll poll, Date currentDate) {
+ Date endChoiceDate = poll.getEndChoiceDate();
+ return !poll.isChoiceAddAllowed() ||
+ (endChoiceDate != null && endChoiceDate.before(currentDate));
+ }
+
public static Set<VoterListMember> getAllVoters(Poll poll) {
Set<VoterListMember> result = Sets.newHashSet();
if (poll.isVoterListNotEmpty()) {
Modified: trunk/pollen-persistence/src/main/xmi/pollen.properties
===================================================================
--- trunk/pollen-persistence/src/main/xmi/pollen.properties 2014-04-25 17:14:38 UTC (rev 3878)
+++ trunk/pollen-persistence/src/main/xmi/pollen.properties 2014-04-26 19:20:22 UTC (rev 3879)
@@ -25,7 +25,7 @@
model.tagValue.constantPrefix=PROPERTY_
model.tagValue.useEnumerationName=true
model.tagValue.indexForeignKeys=true
-model.tagValue.String=string
+model.tagValue.hibernateAttributeType.String=string
org.chorem.pollen.persistence.entity.Poll.attribute.choice.stereotype=ordered
org.chorem.pollen.persistence.entity.Poll.attribute.voterList.stereotype=ordered
1
0
r3878 - in trunk/pollen-ui-angular/src/main/webapp: . js js/controllers js/libs partials
by garandel@users.chorem.org 25 Apr '14
by garandel@users.chorem.org 25 Apr '14
25 Apr '14
Author: garandel
Date: 2014-04-25 19:14:38 +0200 (Fri, 25 Apr 2014)
New Revision: 3878
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3878
Log:
un template pour creation/edition/vote de sondage
Added:
trunk/pollen-ui-angular/src/main/webapp/js/controllers/
trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
Removed:
trunk/pollen-ui-angular/src/main/webapp/js/controllers.js
trunk/pollen-ui-angular/src/main/webapp/js/libs/bootstrap-datetimepicker.min.js
trunk/pollen-ui-angular/src/main/webapp/partials/poll-create.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll-detail.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll-form.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll-list.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll-vote.html
Modified:
trunk/pollen-ui-angular/src/main/webapp/index.html
trunk/pollen-ui-angular/src/main/webapp/js/app.js
Modified: trunk/pollen-ui-angular/src/main/webapp/index.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/index.html 2014-04-25 15:34:32 UTC (rev 3877)
+++ trunk/pollen-ui-angular/src/main/webapp/index.html 2014-04-25 17:14:38 UTC (rev 3878)
@@ -27,12 +27,11 @@
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-resource.min…"></script>
- <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.10.0.js"></script>
+ <script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.10.0/ui-bootst…"></script>
<script src="js/libs/ckeditor/ckeditor.js"></script>
- <script src="js/libs/ckeditor/adapters/jquery.js"></script>
<script src="js/app.js"></script>
- <script src="js/controllers.js"></script>
+ <script src="js/controllers/pollCtrl.js"></script>
<script src="js/services.js"></script>
</head>
<body>
Modified: trunk/pollen-ui-angular/src/main/webapp/js/app.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-25 15:34:32 UTC (rev 3877)
+++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-25 17:14:38 UTC (rev 3878)
@@ -22,11 +22,8 @@
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/', {templateUrl: 'partials/home.html', controller: "HomeCtrl"})
- .when('/poll/create', {templateUrl: 'partials/poll-create.html', controller: "PollCreateCtrl"})
- .when('/poll/vote', {templateUrl: 'partials/poll-vote.html', controller :"PollVoteCtrl"})
- .when('/polls', {templateUrl: 'partials/poll-list.html', controller: "PollListCtrl"})
- .when('/polls/form', {templateUrl: 'partials/poll-form.html', controller: "PollFormCtrl"})
- .when('/polls/:pollId', {templateUrl: 'partials/poll-detail.html', controller: "PollDetailCtrl"})
+ .when('/poll/create', {templateUrl: 'partials/poll.html', controller: "PollCreateCtrl"})
+ .when('/poll/vote', {templateUrl: 'partials/poll.html', controller :"PollVoteCtrl"})
.otherwise({redirectTo: '/'});
}]).config(['$httpProvider', function($httpProvider) {
@@ -36,12 +33,12 @@
}])
.directive('focusMe', function($timeout) {
return {
- link: function(scope, element, attrs) {
- scope.$watch(attrs.focusMe, function(value) {
+ link: function($scope, element, attrs) {
+ $scope.$watch(attrs.focusMe, function(value) {
if(value === true) {
$timeout(function() {
element[0].focus();
- scope[attrs.focusMe] = true;
+ $scope[attrs.focusMe] = true;
});
}
});
@@ -49,11 +46,27 @@
};
})
+.directive('editMe', function() {
+ return {
+ restrict:'A',
+ link: function ($scope, element, attrs) {
+ element.bind('click', function () {
+ if ($scope.gvar.editMode) {
+ $scope.$apply(function () {
+ $scope[attrs.editMe] = true;
+ $scope.gvar.saved = false;
+ });
+ }
+ });
+ }
+ };
+})
+
.directive('ckEditor', function () {
return {
require: '?ngModel',
- link: function ($scope, elm, attr, ngModel) {
- var ck = CKEDITOR.replace(elm[0]);
+ link: function ($scope, element, attrs, ngModel) {
+ var ck = CKEDITOR.replace(element[0]);
ck.on('pasteState', function () {
$scope.$apply(function () {
Copied: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js (from rev 3876, trunk/pollen-ui-angular/src/main/webapp/js/controllers.js)
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js (rev 0)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-25 17:14:38 UTC (rev 3878)
@@ -0,0 +1,157 @@
+/*
+ * #%L
+ * Pollen :: UI (Angular)
+ * %%
+ * Copyright (C) 2009 - 2014 CodeLutin
+ * %%
+ * 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%
+ */
+angular.module('pollenControllers', []).controller('HomeCtrl', ['$scope', '$http', function ($scope, $http) {
+
+}])
+.controller('PollCreateCtrl', ['$scope', '$http', '$sce', '$modal', '$filter', '$timeout', 'pollStorage', function ($scope, $http, $sce, $modal, $filter, $timeout, pollStorage) {
+ function initPoll() {
+ return {
+ title :'',
+ description : '',
+ choices : []
+ };
+ }
+
+ function initChoice() {
+ return {
+ name: '',
+ type: 'text'
+ };
+ }
+
+ $scope.gvar = {saved:false, editMode:true};
+ $scope.$watch('gvar.saved', function() {
+ $timeout(function () {
+ $scope.gvar.saved = false;
+ }, 5000);
+ })
+
+ $scope.poll = pollStorage.get();
+ if (JSON.stringify($scope.poll) == "{}") {
+ $scope.poll = initPoll();
+ }
+
+ $scope.voteChoices = $scope.poll.choices;
+
+ $scope.addChoice = function () {
+ var index = $scope.poll.choices.push(initChoice());
+ var choice = $scope.poll.choices[index-1];
+ var modalInstance = $modal.open({
+ templateUrl : 'popupChoice.html',
+ controller : PollPopChoiceCtrl,
+ resolve : {
+ title : function () { return 'Add Choice';},
+ choice : function () { return choice; }
+ }
+ });
+ modalInstance.result.then(function (ch) {
+ deleteChoice(ch);
+ });
+
+ }
+
+ $scope.editChoice = function (choice) {
+ var modalInstance = $modal.open({
+ templateUrl : 'popupChoice.html',
+ controller : PollPopChoiceCtrl,
+ resolve : {
+ title : function () { return 'Edit Choice';},
+ choice : function () { return choice; }
+ }
+ });
+
+ modalInstance.result.then(function (ch) {
+ deleteChoice(ch);
+ });
+ }
+
+ var deleteChoice = function (ch) {
+ var index = $scope.poll.choices.indexOf(ch);
+ if (index > -1) {
+ $scope.poll.choices.splice(index,1);
+ }
+ }
+
+ $scope.save = function () {
+ pollStorage.put($scope.poll);
+ $scope.gvar.saved = true;
+ }
+
+ $scope.reset = function () {
+ $scope.poll = initPoll();
+ pollStorage.put({});
+ }
+
+ $scope.toHTML = function (data) {
+ return $sce.trustAsHtml(data);
+ }
+
+ var PollPopChoiceCtrl = function ($scope, $filter, $modalInstance, title, choice) {
+ $scope.title = title;
+ $scope.choice = choice;
+
+ $scope.saveChoice = function () {
+ $modalInstance.close();
+ }
+
+ $scope.deleteChoice = function (ch) {
+ $modalInstance.close(ch);
+ }
+
+ }
+}])
+
+.controller('PollVoteCtrl', ['$scope', '$filter', '$sce', '$timeout', 'pollStorage', function ($scope, $filter, $sce, $timeout, pollStorage) {
+ $scope.gvar = {saved:false, editMode:false};
+ $scope.$watch('gvar.saved', function() {
+ $timeout(function () {
+ $scope.gvar.saved = false;
+ }, 5000);
+ })
+ $scope.poll = pollStorage.get();
+ $scope.voteName = "";
+ $scope.voteChoices = [];
+ for (var i = 0; i < $scope.poll.choices.length; ++i) {
+ if ($scope.poll.choices[i].type == 'text') {
+ $scope.voteChoices.push({name:$scope.poll.choices[i].name, value:false});
+ }
+ else if ($scope.poll.choices[i].type == 'date') {
+ $scope.voteChoices.push({name: $filter('date')($scope.poll.choices[i].date,'dd/MM/yyyy') , value:false});
+ }
+ }
+
+ $scope.vote = function () {
+ var data = {};
+ data.name = $scope.voteName;
+ data.choices = angular.copy($scope.voteChoices);
+ if (!angular.isDefined($scope.poll.votants)) {
+ $scope.poll.votants = [];
+ }
+ $scope.poll.votants.push(data);
+ pollStorage.put($scope.poll);
+ $scope.gvar.saved = true;
+ }
+
+ $scope.toHTML = function (data) {
+ return $sce.trustAsHtml(data);
+ }
+}])
+;
\ No newline at end of file
Deleted: trunk/pollen-ui-angular/src/main/webapp/js/controllers.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers.js 2014-04-25 15:34:32 UTC (rev 3877)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers.js 2014-04-25 17:14:38 UTC (rev 3878)
@@ -1,204 +0,0 @@
-/*
- * #%L
- * Pollen :: UI (Angular)
- * %%
- * Copyright (C) 2009 - 2014 CodeLutin
- * %%
- * 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%
- */
-angular.module('pollenControllers', []).controller('HomeCtrl', ['$scope', '$http', function ($scope, $http) {
-
-}])
-.controller('PollCreateCtrl', ['$scope', '$http', '$sce', '$modal', '$filter', 'pollStorage', function ($scope, $http, $sce, $modal, $filter, pollStorage) {
- function initPoll() {
- return {
- title :'Click Me for Editing',
- description : '',
- choices : []
- };
- }
-
- function initChoice() {
- return {
- name: '',
- type: 'text'
- };
- }
-
- $scope.gvar = {};
- $scope.poll = pollStorage.get();
- if (JSON.stringify($scope.poll) == "{}") {
- $scope.poll = initPoll();
- }
-
- $scope.addChoice = function () {
- var index = $scope.poll.choices.push(initChoice());
- var choice = $scope.poll.choices[index-1];
- var modalInstance = $modal.open({
- templateUrl : 'popupChoice.html',
- controller : PollPopChoiceCtrl,
- resolve : {
- title : function () { return 'Add Choice';},
- choice : function () { return choice; }
- }
- });
- modalInstance.result.then(function (ch) {
- deleteChoice(ch);
- });
-
- }
-
- $scope.editChoice = function (choice) {
- var modalInstance = $modal.open({
- templateUrl : 'popupChoice.html',
- controller : PollPopChoiceCtrl,
- resolve : {
- title : function () { return 'Edit Choice';},
- choice : function () { return choice; }
- }
- });
-
- modalInstance.result.then(function (ch) {
- deleteChoice(ch);
- });
- }
-
- var deleteChoice = function (ch) {
- var index = $scope.poll.choices.indexOf(ch);
- if (index > -1) {
- $scope.poll.choices.splice(index,1);
- }
- }
-
- $scope.save = function () {
- pollStorage.put($scope.poll);
- $scope.gvar.saved = true;
- }
-
- $scope.reset = function () {
- $scope.poll = initPoll();
- pollStorage.put({});
- }
-
- $scope.toHTML = function (data) {
- return $sce.trustAsHtml(data);
- }
-
- var PollPopChoiceCtrl = function ($scope, $filter, $modalInstance, title, choice) {
- $scope.title = title;
- $scope.choice = choice;
-
- $scope.saveChoice = function () {
- $modalInstance.close();
- }
-
- $scope.deleteChoice = function (ch) {
- $modalInstance.close(ch);
- }
-
- }
-}])
-
-.controller('PollVoteCtrl', ['$scope', '$filter', '$sce', 'pollStorage', function ($scope, $filter, $sce, pollStorage) {
- $scope.gvar = {saved:false};
- $scope.poll = pollStorage.get();
- $scope.voteName = "Name";
- $scope.voteChoices = [];
- for (var i = 0; i < $scope.poll.choices.length; ++i) {
- if ($scope.poll.choices[i].type == 'text') {
- $scope.voteChoices.push({name:$scope.poll.choices[i].name, value:false});
- }
- else if ($scope.poll.choices[i].type == 'date') {
- $scope.voteChoices.push({name: $filter('date')($scope.poll.choices[i].date,'dd/MM/yyyy') , value:false});
- }
- }
-
- $scope.vote = function () {
- var data = {};
- data.name = $scope.voteName;
- data.choices = angular.copy($scope.voteChoices);
- if (typeof $scope.poll.votants == "undefined") {
- $scope.poll.votants = [];
- }
- $scope.poll.votants.push(data);
- pollStorage.put($scope.poll);
- $scope.gvar.saved = true;
- }
-
- $scope.toHTML = function (data) {
- return $sce.trustAsHtml(data);
- }
-}])
-.controller('PollFormCtrl', ['$scope', '$http', function ($scope, $http) {
- $http.get('http://localhost:8080/pollen/v1/polls/new?choiceType=TEXT').success(function(data) {
- data.choices = [{}, {}];
- $scope.poll = data;
- $scope.step = 1;
- });
-
- $scope.prev = function() {
- $scope.step--;
- }
-
- $scope.next = function() {
- $scope.step++;
- }
-
- $scope.addChoice = function() {
- $scope.poll.choices.push({});
- }
-
-}]).controller('PollListCtrl', ['$scope', '$http', function ($scope, $http) {
- $http.get('http://localhost:8080/pollen/v1/polls').success(function(data) {
- $scope.polls = data;
- });
-
-}]).controller('PollDetailCtrl', ['$scope', '$http', function ($scope, $http, $routeParams) {
- $http({url: "http://localhost:8080/pollen/v1/polls/" + $routeParams.pollId, method: "GET"}).success(function(data) {
- $scope.poll = data;
- });
-
- $http({url: "http://localhost:8080/pollen/v1/polls/" + $routeParams.pollId + "/choices", method: "GET"}).success(function(data) {
- $scope.choices = data;
- });
-
- $http({url: "http://localhost:8080/pollen/v1/polls/" + $routeParams.pollId + "/comments", method: "GET"}).success(function(data) {
- $scope.comments = data;
- }).error(function() {
- $scope.comments = [];
- });
-
- $http({url: "http://localhost:8080/pollen/v1/polls/" + $routeParams.pollId + "/votes", method: "GET"}).success(function(data) {
- $scope.votes = data;
- }).error(function() {
- $scope.votes = [];
- });
-
- $scope.author = "";
- $scope.text = "";
-
- $scope.addComment = function() {
- var comment = {
- author: this.author,
- text: this.text,
- postDate: new Date().getTime()
- };
- this.comments.push(comment);
- this.author = "";
- this.text = "";
- }
-
-}]);
-
Deleted: trunk/pollen-ui-angular/src/main/webapp/js/libs/bootstrap-datetimepicker.min.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/libs/bootstrap-datetimepicker.min.js 2014-04-25 15:34:32 UTC (rev 3877)
+++ trunk/pollen-ui-angular/src/main/webapp/js/libs/bootstrap-datetimepicker.min.js 2014-04-25 17:14:38 UTC (rev 3878)
@@ -1,26 +0,0 @@
-/**
- * @license
- * =========================================================
- * bootstrap-datetimepicker.js
- * http://www.eyecon.ro/bootstrap-datepicker
- * =========================================================
- * Copyright 2012 Stefan Petre
- *
- * Contributions:
- * - Andrew Rowls
- * - Thiago de Arruda
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * =========================================================
- */
-(function($){var smartPhone=window.orientation!=undefined;var DateTimePicker=function(element,options){this.id=dpgId++;this.init(element,options)};var dateToDate=function(dt){if(typeof dt==="string"){return new Date(dt)}return dt};DateTimePicker.prototype={constructor:DateTimePicker,init:function(element,options){var icon;if(!(options.pickTime||options.pickDate))throw new Error("Must choose at least one picker");this.options=options;this.$element=$(element);this.language=options.language in dates?options.language:"en";this.pickDate=options.pickDate;this.pickTime=options.pickTime;this.isInput=this.$element.is("input");this.component=false;if(this.$element.find(".input-append")||this.$element.find(".input-prepend"))this.component=this.$element.find(".add-on");this.format=options.format;if(!this.format){if(this.isInput)this.format=this.$element.data("format");else this.format=this.$element.find("input").data("format");if(!this.format)this.format="MM/dd/yyyy"}this._compileFormat();if(this.component){icon=this.component.find("i")}if(this.pickTime){if(icon&&icon.length)this.timeIcon=icon.data("time-icon");if(!this.timeIcon)this.timeIcon="icon-time";icon.addClass(this.timeIcon)}if(this.pickDate){if(icon&&icon.length)this.dateIcon=icon.data("date-icon");if(!this.dateIcon)this.dateIcon="icon-calendar";icon.removeClass(this.timeIcon);icon.addClass(this.dateIcon)}this.widget=$(getTemplate(this.timeIcon,options.pickDate,options.pickTime,options.pick12HourFormat,options.pickSeconds,options.collapse)).appendTo("body");this.minViewMode=options.minViewMode||this.$element.data("date-minviewmode")||0;if(typeof this.minViewMode==="string"){switch(this.minViewMode){case"months":this.minViewMode=1;break;case"years":this.minViewMode=2;break;default:this.minViewMode=0;break}}this.viewMode=options.viewMode||this.$element.data("date-viewmode")||0;if(typeof this.viewMode==="string"){switch(this.viewMode){case"months":this.viewMode=1;break;case"years":this.viewMode=2;break;default:this.viewMode=0;break}}this.startViewMode=this.viewMode;this.weekStart=options.weekStart||this.$element.data("date-weekstart")||0;this.weekEnd=this.weekStart===0?6:this.weekStart-1;this.setStartDate(options.startDate||this.$element.data("date-startdate"));this.setEndDate(options.endDate||this.$element.data("date-enddate"));this.fillDow();this.fillMonths();this.fillHours();this.fillMinutes();this.fillSeconds();this.update();this.showMode();this._attachDatePickerEvents()},show:function(e){this.widget.show();this.height=this.component?this.component.outerHeight():this.$element.outerHeight();this.place();this.$element.trigger({type:"show",date:this._date});this._attachDatePickerGlobalEvents();if(e){e.stopPropagation();e.preventDefault()}},disable:function(){this.$element.find("input").prop("disabled",true);this._detachDatePickerEvents()},enable:function(){this.$element.find("input").prop("disabled",false);this._attachDatePickerEvents()},hide:function(){var collapse=this.widget.find(".collapse");for(var i=0;i<collapse.length;i++){var collapseData=collapse.eq(i).data("collapse");if(collapseData&&collapseData.transitioning)return}this.widget.hide();this.viewMode=this.startViewMode;this.showMode();this.set();this.$element.trigger({type:"hide",date:this._date});this._detachDatePickerGlobalEvents()},set:function(){var formatted="";if(!this._unset)formatted=this.formatDate(this._date);if(!this.isInput){if(this.component){var input=this.$element.find("input");input.val(formatted);this._resetMaskPos(input)}this.$element.data("date",formatted)}else{this.$element.val(formatted);this._resetMaskPos(this.$element)}},setValue:function(newDate){if(!newDate){this._unset=true}else{this._unset=false}if(typeof newDate==="string"){this._date=this.parseDate(newDate)}else if(newDate){this._date=new Date(newDate)}this.set();this.viewDate=UTCDate(this._date.getUTCFullYear(),this._date.getUTCMonth(),1,0,0,0,0);this.fillDate();this.fillTime()},getDate:function(){if(this._unset)return null;return new Date(this._date.valueOf())},setDate:function(date){if(!date)this.setValue(null);else this.setValue(date.valueOf())},setStartDate:function(date){if(date instanceof Date){this.startDate=date}else if(typeof date==="string"){this.startDate=new UTCDate(date);if(!this.startDate.getUTCFullYear()){this.startDate=-Infinity}}else{this.startDate=-Infinity}if(this.viewDate){this.update()}},setEndDate:function(date){if(date instanceof Date){this.endDate=date}else if(typeof date==="string"){this.endDate=new UTCDate(date);if(!this.endDate.getUTCFullYear()){this.endDate=Infinity}}else{this.endDate=Infinity}if(this.viewDate){this.update()}},getLocalDate:function(){if(this._unset)return null;var d=this._date;return new Date(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate(),d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds())},setLocalDate:function(localDate){if(!localDate)this.setValue(null);else this.setValue(Date.UTC(localDate.getFullYear(),localDate.getMonth(),localDate.getDate(),localDate.getHours(),localDate.getMinutes(),localDate.getSeconds(),localDate.getMilliseconds()))},place:function(){var position="absolute";var offset=this.component?this.component.offset():this.$element.offset();this.width=this.component?this.component.outerWidth():this.$element.outerWidth();offset.top=offset.top+this.height;var $window=$(window);if(this.options.width!=undefined){this.widget.width(this.options.width)}if(this.options.orientation=="left"){this.widget.addClass("left-oriented");offset.left=offset.left-this.widget.width()+20}if(this._isInFixed()){position="fixed";offset.top-=$window.scrollTop();offset.left-=$window.scrollLeft()}if($window.width()<offset.left+this.widget.outerWidth()){offset.right=$window.width()-offset.left-this.width;offset.left="auto";this.widget.addClass("pull-right")}else{offset.right="auto";this.widget.removeClass("pull-right")}this.widget.css({position:position,top:offset.top,left:offset.left,right:offset.right})},notifyChange:function(){this.$element.trigger({type:"changeDate",date:this.getDate(),localDate:this.getLocalDate()})},update:function(newDate){var dateStr=newDate;if(!dateStr){if(this.isInput){dateStr=this.$element.val()}else{dateStr=this.$element.find("input").val()}if(dateStr){this._date=this.parseDate(dateStr)}if(!this._date){var tmp=new Date;this._date=UTCDate(tmp.getFullYear(),tmp.getMonth(),tmp.getDate(),tmp.getHours(),tmp.getMinutes(),tmp.getSeconds(),tmp.getMilliseconds())}}this.viewDate=UTCDate(this._date.getUTCFullYear(),this._date.getUTCMonth(),1,0,0,0,0);this.fillDate();this.fillTime()},fillDow:function(){var dowCnt=this.weekStart;var html=$("<tr>");while(dowCnt<this.weekStart+7){html.append('<th class="dow">'+dates[this.language].daysMin[dowCnt++%7]+"</th>")}this.widget.find(".datepicker-days thead").append(html)},fillMonths:function(){var html="";var i=0;while(i<12){html+='<span class="month">'+dates[this.language].monthsShort[i++]+"</span>"}this.widget.find(".datepicker-months td").append(html)},fillDate:function(){var year=this.viewDate.getUTCFullYear();var month=this.viewDate.getUTCMonth();var currentDate=UTCDate(this._date.getUTCFullYear(),this._date.getUTCMonth(),this._date.getUTCDate(),0,0,0,0);var startYear=typeof this.startDate==="object"?this.startDate.getUTCFullYear():-Infinity;var startMonth=typeof this.startDate==="object"?this.startDate.getUTCMonth():-1;var endYear=typeof this.endDate==="object"?this.endDate.getUTCFullYear():Infinity;var endMonth=typeof this.endDate==="object"?this.endDate.getUTCMonth():12;this.widget.find(".datepicker-days").find(".disabled").removeClass("disabled");this.widget.find(".datepicker-months").find(".disabled").removeClass("disabled");this.widget.find(".datepicker-years").find(".disabled").removeClass("disabled");this.widget.find(".datepicker-days th:eq(1)").text(dates[this.language].months[month]+" "+year);var prevMonth=UTCDate(year,month-1,28,0,0,0,0);var day=DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(),prevMonth.getUTCMonth());prevMonth.setUTCDate(day);prevMonth.setUTCDate(day-(prevMonth.getUTCDay()-this.weekStart+7)%7);if(year==startYear&&month<=startMonth||year<startYear){this.widget.find(".datepicker-days th:eq(0)").addClass("disabled")}if(year==endYear&&month>=endMonth||year>endYear){this.widget.find(".datepicker-days th:eq(2)").addClass("disabled")}var nextMonth=new Date(prevMonth.valueOf());nextMonth.setUTCDate(nextMonth.getUTCDate()+42);nextMonth=nextMonth.valueOf();var html=[];var row;var clsName;while(prevMonth.valueOf()<nextMonth){if(prevMonth.getUTCDay()===this.weekStart){row=$("<tr>");html.push(row)}clsName="";if(prevMonth.getUTCFullYear()<year||prevMonth.getUTCFullYear()==year&&prevMonth.getUTCMonth()<month){clsName+=" old"}else if(prevMonth.getUTCFullYear()>year||prevMonth.getUTCFullYear()==year&&prevMonth.getUTCMonth()>month){clsName+=" new"}if(prevMonth.valueOf()===currentDate.valueOf()){clsName+=" active"}if(prevMonth.valueOf()+864e5<=this.startDate){clsName+=" disabled"}if(prevMonth.valueOf()>this.endDate){clsName+=" disabled"}row.append('<td class="day'+clsName+'">'+prevMonth.getUTCDate()+"</td>");prevMonth.setUTCDate(prevMonth.getUTCDate()+1)}this.widget.find(".datepicker-days tbody").empty().append(html);var currentYear=this._date.getUTCFullYear();var months=this.widget.find(".datepicker-months").find("th:eq(1)").text(year).end().find("span").removeClass("active");if(currentYear===year){months.eq(this._date.getUTCMonth()).addClass("active")}if(currentYear-1<startYear){this.widget.find(".datepicker-months th:eq(0)").addClass("disabled")}if(currentYear+1>endYear){this.widget.find(".datepicker-months th:eq(2)").addClass("disabled")}for(var i=0;i<12;i++){if(year==startYear&&startMonth>i||year<startYear){$(months[i]).addClass("disabled")}else if(year==endYear&&endMonth<i||year>endYear){$(months[i]).addClass("disabled")}}html="";year=parseInt(year/10,10)*10;var yearCont=this.widget.find(".datepicker-years").find("th:eq(1)").text(year+"-"+(year+9)).end().find("td");this.widget.find(".datepicker-years").find("th").removeClass("disabled");if(startYear>year){this.widget.find(".datepicker-years").find("th:eq(0)").addClass("disabled")}if(endYear<year+9){this.widget.find(".datepicker-years").find("th:eq(2)").addClass("disabled")}year-=1;for(var i=-1;i<11;i++){html+='<span class="year'+(i===-1||i===10?" old":"")+(currentYear===year?" active":"")+(year<startYear||year>endYear?" disabled":"")+'">'+year+"</span>";year+=1}yearCont.html(html)},fillHours:function(){var table=this.widget.find(".timepicker .timepicker-hours table");table.parent().hide();var html="";if(this.options.pick12HourFormat){var current=1;for(var i=0;i<3;i+=1){html+="<tr>";for(var j=0;j<4;j+=1){var c=current.toString();html+='<td class="hour">'+padLeft(c,2,"0")+"</td>";current++}html+="</tr>"}}else{var current=0;for(var i=0;i<6;i+=1){html+="<tr>";for(var j=0;j<4;j+=1){var c=current.toString();html+='<td class="hour">'+padLeft(c,2,"0")+"</td>";current++}html+="</tr>"}}table.html(html)},fillMinutes:function(){var table=this.widget.find(".timepicker .timepicker-minutes table");table.parent().hide();var html="";var current=0;for(var i=0;i<5;i++){html+="<tr>";for(var j=0;j<4;j+=1){var c=current.toString();html+='<td class="minute">'+padLeft(c,2,"0")+"</td>";current+=3}html+="</tr>"}table.html(html)},fillSeconds:function(){var table=this.widget.find(".timepicker .timepicker-seconds table");table.parent().hide();var html="";var current=0;for(var i=0;i<5;i++){html+="<tr>";for(var j=0;j<4;j+=1){var c=current.toString();html+='<td class="second">'+padLeft(c,2,"0")+"</td>";current+=3}html+="</tr>"}table.html(html)},fillTime:function(){if(!this._date)return;var timeComponents=this.widget.find(".timepicker span[data-time-component]");var table=timeComponents.closest("table");var is12HourFormat=this.options.pick12HourFormat;var hour=this._date.getUTCHours();var period="AM";if(is12HourFormat){if(hour>=12)period="PM";if(hour===0)hour=12;else if(hour!=12)hour=hour%12;this.widget.find(".timepicker [data-action=togglePeriod]").text(period)}hour=padLeft(hour.toString(),2,"0");var minute=padLeft(this._date.getUTCMinutes().toString(),2,"0");var second=padLeft(this._date.getUTCSeconds().toString(),2,"0");timeComponents.filter("[data-time-component=hours]").text(hour);timeComponents.filter("[data-time-component=minutes]").text(minute);timeComponents.filter("[data-time-component=seconds]").text(second)},click:function(e){e.stopPropagation();e.preventDefault();this._unset=false;var target=$(e.target).closest("span, td, th");if(target.length===1){if(!target.is(".disabled")){switch(target[0].nodeName.toLowerCase()){case"th":switch(target[0].className){case"switch":this.showMode(1);break;case"prev":case"next":var vd=this.viewDate;var navFnc=DPGlobal.modes[this.viewMode].navFnc;var step=DPGlobal.modes[this.viewMode].navStep;if(target[0].className==="prev")step=step*-1;vd["set"+navFnc](vd["get"+navFnc]()+step);this.fillDate();this.set();break}break;case"span":if(target.is(".month")){var month=target.parent().find("span").index(target);this.viewDate.setUTCMonth(month)}else{var year=parseInt(target.text(),10)||0;this.viewDate.setUTCFullYear(year)}if(this.viewMode!==0){this._date=UTCDate(this.viewDate.getUTCFullYear(),this.viewDate.getUTCMonth(),this.viewDate.getUTCDate(),this._date.getUTCHours(),this._date.getUTCMinutes(),this._date.getUTCSeconds(),this._date.getUTCMilliseconds());this.notifyChange()}this.showMode(-1);this.fillDate();this.set();break;case"td":if(target.is(".day")){var day=parseInt(target.text(),10)||1;var month=this.viewDate.getUTCMonth();var year=this.viewDate.getUTCFullYear();if(target.is(".old")){if(month===0){month=11;year-=1}else{month-=1}}else if(target.is(".new")){if(month==11){month=0;year+=1}else{month+=1}}this._date=UTCDate(year,month,day,this._date.getUTCHours(),this._date.getUTCMinutes(),this._date.getUTCSeconds(),this._date.getUTCMilliseconds());this.viewDate=UTCDate(year,month,Math.min(28,day),0,0,0,0);this.fillDate();this.set();this.notifyChange()}break}}}},actions:{incrementHours:function(e){this._date.setUTCHours(this._date.getUTCHours()+1)},incrementMinutes:function(e){this._date.setUTCMinutes(this._date.getUTCMinutes()+1)},incrementSeconds:function(e){this._date.setUTCSeconds(this._date.getUTCSeconds()+1)},decrementHours:function(e){this._date.setUTCHours(this._date.getUTCHours()-1)},decrementMinutes:function(e){this._date.setUTCMinutes(this._date.getUTCMinutes()-1)},decrementSeconds:function(e){this._date.setUTCSeconds(this._date.getUTCSeconds()-1)},togglePeriod:function(e){var hour=this._date.getUTCHours();if(hour>=12)hour-=12;else hour+=12;this._date.setUTCHours(hour)},showPicker:function(){this.widget.find(".timepicker > div:not(.timepicker-picker)").hide();this.widget.find(".timepicker .timepicker-picker").show()},showHours:function(){this.widget.find(".timepicker .timepicker-picker").hide();this.widget.find(".timepicker .timepicker-hours").show()},showMinutes:function(){this.widget.find(".timepicker .timepicker-picker").hide();this.widget.find(".timepicker .timepicker-minutes").show()},showSeconds:function(){this.widget.find(".timepicker .timepicker-picker").hide();this.widget.find(".timepicker .timepicker-seconds").show()},selectHour:function(e){var tgt=$(e.target);var value=parseInt(tgt.text(),10);if(this.options.pick12HourFormat){var current=this._date.getUTCHours();if(current>=12){if(value!=12)value=(value+12)%24}else{if(value===12)value=0;else value=value%12}}this._date.setUTCHours(value);this.actions.showPicker.call(this)},selectMinute:function(e){var tgt=$(e.target);var value=parseInt(tgt.text(),10);this._date.setUTCMinutes(value);this.actions.showPicker.call(this)},selectSecond:function(e){var tgt=$(e.target);var value=parseInt(tgt.text(),10);this._date.setUTCSeconds(value);this.actions.showPicker.call(this)}},doAction:function(e){e.stopPropagation();e.preventDefault();if(!this._date)this._date=UTCDate(1970,0,0,0,0,0,0);var action=$(e.currentTarget).data("action");var rv=this.actions[action].apply(this,arguments);this.set();this.fillTime();this.notifyChange();return rv},stopEvent:function(e){e.stopPropagation();e.preventDefault()},keydown:function(e){var self=this,k=e.which,input=$(e.target);if(k==8||k==46){setTimeout(function(){self._resetMaskPos(input)})}},keypress:function(e){var k=e.which;if(k==8||k==46){return}var input=$(e.target);var c=String.fromCharCode(k);var val=input.val()||"";val+=c;var mask=this._mask[this._maskPos];if(!mask){return false}if(mask.end!=val.length){return}if(!mask.pattern.test(val.slice(mask.start))){val=val.slice(0,val.length-1);while((mask=this._mask[this._maskPos])&&mask.character){val+=mask.character;this._maskPos++}val+=c;if(mask.end!=val.length){input.val(val);return false}else{if(!mask.pattern.test(val.slice(mask.start))){input.val(val.slice(0,mask.start));return false}else{input.val(val);this._maskPos++;return false}}}else{this._maskPos++}},change:function(e){var input=$(e.target);var val=input.val();if(this._formatPattern.test(val)){this.update();this.setValue(this._date.getTime());this.notifyChange();this.set()}else if(val&&val.trim()){this.setValue(this._date.getTime());if(this._date)this.set();else input.val("")}else{if(this._date){this.setValue(null);this.notifyChange();this._unset=true}}this._resetMaskPos(input)},showMode:function(dir){if(dir){this.viewMode=Math.max(this.minViewMode,Math.min(2,this.viewMode+dir))}this.widget.find(".datepicker > div").hide().filter(".datepicker-"+DPGlobal.modes[this.viewMode].clsName).show()},destroy:function(){this._detachDatePickerEvents();this._detachDatePickerGlobalEvents();this.widget.remove();this.$element.removeData("datetimepicker");this.component.removeData("datetimepicker")},formatDate:function(d){return this.format.replace(formatReplacer,function(match){var methodName,property,rv,len=match.length;if(match==="ms")len=1;property=dateFormatComponents[match].property;if(property==="Hours12"){rv=d.getUTCHours();if(rv===0)rv=12;else if(rv!==12)rv=rv%12}else if(property==="Period12"){if(d.getUTCHours()>=12)return"PM";else return"AM"}else{methodName="get"+property;rv=d[methodName]()}if(methodName==="getUTCMonth")rv=rv+1;if(methodName==="getUTCYear")rv=rv+1900-2e3;return padLeft(rv.toString(),len,"0")})},parseDate:function(str){var match,i,property,methodName,value,parsed={};if(!(match=this._formatPattern.exec(str)))return null;for(i=1;i<match.length;i++){property=this._propertiesByIndex[i];if(!property)continue;value=match[i];if(/^\d+$/.test(value))value=parseInt(value,10);parsed[property]=value}return this._finishParsingDate(parsed)},_resetMaskPos:function(input){var val=input.val();for(var i=0;i<this._mask.length;i++){if(this._mask[i].end>val.length){this._maskPos=i;break}else if(this._mask[i].end===val.length){this._maskPos=i+1;break}}},_finishParsingDate:function(parsed){var year,month,date,hours,minutes,seconds,milliseconds;year=parsed.UTCFullYear;if(parsed.UTCYear)year=2e3+parsed.UTCYear;if(!year)year=1970;if(parsed.UTCMonth)month=parsed.UTCMonth-1;else month=0;date=parsed.UTCDate||1;hours=parsed.UTCHours||0;minutes=parsed.UTCMinutes||0;seconds=parsed.UTCSeconds||0;milliseconds=parsed.UTCMilliseconds||0;if(parsed.Hours12){hours=parsed.Hours12}if(parsed.Period12){if(/pm/i.test(parsed.Period12)){if(hours!=12)hours=(hours+12)%24}else{hours=hours%12}}return UTCDate(year,month,date,hours,minutes,seconds,milliseconds)},_compileFormat:function(){var match,component,components=[],mask=[],str=this.format,propertiesByIndex={},i=0,pos=0;while(match=formatComponent.exec(str)){component=match[0];if(component in dateFormatComponents){i++;propertiesByIndex[i]=dateFormatComponents[component].property;components.push("\\s*"+dateFormatComponents[component].getPattern(this)+"\\s*");mask.push({pattern:new RegExp(dateFormatComponents[component].getPattern(this)),property:dateFormatComponents[component].property,start:pos,end:pos+=component.length})}else{components.push(escapeRegExp(component));mask.push({pattern:new RegExp(escapeRegExp(component)),character:component,start:pos,end:++pos})}str=str.slice(component.length)}this._mask=mask;this._maskPos=0;this._formatPattern=new RegExp("^\\s*"+components.join("")+"\\s*$");this._propertiesByIndex=propertiesByIndex},_attachDatePickerEvents:function(){var self=this;this.widget.on("click",".datepicker *",$.proxy(this.click,this));this.widget.on("click","[data-action]",$.proxy(this.doAction,this));this.widget.on("mousedown",$.proxy(this.stopEvent,this));if(this.pickDate&&this.pickTime){this.widget.on("click.togglePicker",".accordion-toggle",function(e){e.stopPropagation();var $this=$(this);var $parent=$this.closest("ul");var expanded=$parent.find(".collapse.in");var closed=$parent.find(".collapse:not(.in)");if(expanded&&expanded.length){var collapseData=expanded.data("collapse");if(collapseData&&collapseData.transitioning)return;expanded.collapse("hide");closed.collapse("show");$this.find("i").toggleClass(self.timeIcon+" "+self.dateIcon);self.$element.find(".add-on i").toggleClass(self.timeIcon+" "+self.dateIcon)}})}if(this.isInput){this.$element.on({focus:$.proxy(this.show,this),change:$.proxy(this.change,this)});if(this.options.maskInput){this.$element.on({keydown:$.proxy(this.keydown,this),keypress:$.proxy(this.keypress,this)})}}else{this.$element.on({change:$.proxy(this.change,this)},"input");if(this.options.maskInput){this.$element.on({keydown:$.proxy(this.keydown,this),keypress:$.proxy(this.keypress,this)},"input")}if(this.component){this.component.on("click",$.proxy(this.show,this))}else{this.$element.on("click",$.proxy(this.show,this))}}},_attachDatePickerGlobalEvents:function(){$(window).on("resize.datetimepicker"+this.id,$.proxy(this.place,this));if(!this.isInput){$(document).on("mousedown.datetimepicker"+this.id,$.proxy(this.hide,this))}},_detachDatePickerEvents:function(){this.widget.off("click",".datepicker *",this.click);this.widget.off("click","[data-action]");this.widget.off("mousedown",this.stopEvent);if(this.pickDate&&this.pickTime){this.widget.off("click.togglePicker")}if(this.isInput){this.$element.off({focus:this.show,change:this.change});if(this.options.maskInput){this.$element.off({keydown:this.keydown,keypress:this.keypress})}}else{this.$element.off({change:this.change},"input");if(this.options.maskInput){this.$element.off({keydown:this.keydown,keypress:this.keypress},"input")}if(this.component){this.component.off("click",this.show)}else{this.$element.off("click",this.show)}}},_detachDatePickerGlobalEvents:function(){$(window).off("resize.datetimepicker"+this.id);if(!this.isInput){$(document).off("mousedown.datetimepicker"+this.id)}},_isInFixed:function(){if(this.$element){var parents=this.$element.parents();var inFixed=false;for(var i=0;i<parents.length;i++){if($(parents[i]).css("position")=="fixed"){inFixed=true;break}}return inFixed}else{return false}}};$.fn.datetimepicker=function(option,val){return this.each(function(){var $this=$(this),data=$this.data("datetimepicker"),options=typeof option==="object"&&option;if(!data){$this.data("datetimepicker",data=new DateTimePicker(this,$.extend({},$.fn.datetimepicker.defaults,options)))}if(typeof option==="string")data[option](val)})};$.fn.datetimepicker.defaults={maskInput:false,pickDate:true,pickTime:true,pick12HourFormat:false,pickSeconds:true,startDate:-Infinity,endDate:Infinity,collapse:true};$.fn.datetimepicker.Constructor=DateTimePicker;var dpgId=0;var dates=$.fn.datetimepicker.dates={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}};var dateFormatComponents={dd:{property:"UTCDate",getPattern:function(){return"(0?[1-9]|[1-2][0-9]|3[0-1])\\b"}},MM:{property:"UTCMonth",getPattern:function(){return"(0?[1-9]|1[0-2])\\b"}},yy:{property:"UTCYear",getPattern:function(){return"(\\d{2})\\b"}},yyyy:{property:"UTCFullYear",getPattern:function(){return"(\\d{4})\\b"}},hh:{property:"UTCHours",getPattern:function(){return"(0?[0-9]|1[0-9]|2[0-3])\\b"}},mm:{property:"UTCMinutes",getPattern:function(){return"(0?[0-9]|[1-5][0-9])\\b"}},ss:{property:"UTCSeconds",getPattern:function(){return"(0?[0-9]|[1-5][0-9])\\b"}},ms:{property:"UTCMilliseconds",getPattern:function(){return"([0-9]{1,3})\\b"}},HH:{property:"Hours12",getPattern:function(){return"(0?[1-9]|1[0-2])\\b"}},PP:{property:"Period12",getPattern:function(){return"(AM|PM|am|pm|Am|aM|Pm|pM)\\b"}}};var keys=[];for(var k in dateFormatComponents)keys.push(k);keys[keys.length-1]+="\\b";keys.push(".");var formatComponent=new RegExp(keys.join("\\b|"));keys.pop();var formatReplacer=new RegExp(keys.join("\\b|"),"g");function escapeRegExp(str){return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function padLeft(s,l,c){if(l<s.length)return s;else return Array(l-s.length+1).join(c||" ")+s}function getTemplate(timeIcon,pickDate,pickTime,is12Hours,showSeconds,collapse){if(pickDate&&pickTime){return'<div class="bootstrap-datetimepicker-widget dropdown-menu">'+"<ul>"+"<li"+(collapse?' class="collapse in"':"")+">"+'<div class="datepicker">'+DPGlobal.template+"</div>"+"</li>"+'<li class="picker-switch accordion-toggle"><a><i class="'+timeIcon+'"></i></a></li>'+"<li"+(collapse?' class="collapse"':"")+">"+'<div class="timepicker">'+TPGlobal.getTemplate(is12Hours,showSeconds)+"</div>"+"</li>"+"</ul>"+"</div>"}else if(pickTime){return'<div class="bootstrap-datetimepicker-widget dropdown-menu">'+'<div class="timepicker">'+TPGlobal.getTemplate(is12Hours,showSeconds)+"</div>"+"</div>"}else{return'<div class="bootstrap-datetimepicker-widget dropdown-menu">'+'<div class="datepicker">'+DPGlobal.template+"</div>"+"</div>"}}function UTCDate(){return new Date(Date.UTC.apply(Date,arguments))}var DPGlobal={modes:[{clsName:"days",navFnc:"UTCMonth",navStep:1},{clsName:"months",navFnc:"UTCFullYear",navStep:1},{clsName:"years",navFnc:"UTCFullYear",navStep:10}],isLeapYear:function(year){return year%4===0&&year%100!==0||year%400===0},getDaysInMonth:function(year,month){return[31,DPGlobal.isLeapYear(year)?29:28,31,30,31,30,31,31,30,31,30,31][month]},headTemplate:"<thead>"+"<tr>"+'<th class="prev">‹</th>'+'<th colspan="5" class="switch"></th>'+'<th class="next">›</th>'+"</tr>"+"</thead>",contTemplate:'<tbody><tr><td colspan="7"></td></tr></tbody>'};DPGlobal.template='<div class="datepicker-days">'+'<table class="table-condensed">'+DPGlobal.headTemplate+"<tbody></tbody>"+"</table>"+"</div>"+'<div class="datepicker-months">'+'<table class="table-condensed">'+DPGlobal.headTemplate+DPGlobal.contTemplate+"</table>"+"</div>"+'<div class="datepicker-years">'+'<table class="table-condensed">'+DPGlobal.headTemplate+DPGlobal.contTemplate+"</table>"+"</div>";var TPGlobal={hourTemplate:'<span data-action="showHours" data-time-component="hours" class="timepicker-hour"></span>',minuteTemplate:'<span data-action="showMinutes" data-time-component="minutes" class="timepicker-minute"></span>',secondTemplate:'<span data-action="showSeconds" data-time-component="seconds" class="timepicker-second"></span>'};TPGlobal.getTemplate=function(is12Hours,showSeconds){return'<div class="timepicker-picker">'+'<table class="table-condensed"'+(is12Hours?' data-hour-format="12"':"")+">"+"<tr>"+'<td><a href="#" class="btn" data-action="incrementHours"><i class="icon-chevron-up"></i></a></td>'+'<td class="separator"></td>'+'<td><a href="#" class="btn" data-action="incrementMinutes"><i class="icon-chevron-up"></i></a></td>'+(showSeconds?'<td class="separator"></td>'+'<td><a href="#" class="btn" data-action="incrementSeconds"><i class="icon-chevron-up"></i></a></td>':"")+(is12Hours?'<td class="separator"></td>':"")+"</tr>"+"<tr>"+"<td>"+TPGlobal.hourTemplate+"</td> "+'<td class="separator">:</td>'+"<td>"+TPGlobal.minuteTemplate+"</td> "+(showSeconds?'<td class="separator">:</td>'+"<td>"+TPGlobal.secondTemplate+"</td>":"")+(is12Hours?'<td class="separator"></td>'+"<td>"+'<button type="button" class="btn btn-primary" data-action="togglePeriod"></button>'+"</td>":"")+"</tr>"+"<tr>"+'<td><a href="#" class="btn" data-action="decrementHours"><i class="icon-chevron-down"></i></a></td>'+'<td class="separator"></td>'+'<td><a href="#" class="btn" data-action="decrementMinutes"><i class="icon-chevron-down"></i></a></td>'+(showSeconds?'<td class="separator"></td>'+'<td><a href="#" class="btn" data-action="decrementSeconds"><i class="icon-chevron-down"></i></a></td>':"")+(is12Hours?'<td class="separator"></td>':"")+"</tr>"+"</table>"+"</div>"+'<div class="timepicker-hours" data-action="selectHour">'+'<table class="table-condensed">'+"</table>"+"</div>"+'<div class="timepicker-minutes" data-action="selectMinute">'+'<table class="table-condensed">'+"</table>"+"</div>"+(showSeconds?'<div class="timepicker-seconds" data-action="selectSecond">'+'<table class="table-condensed">'+"</table>"+"</div>":"")}})(window.jQuery);
\ No newline at end of file
Deleted: trunk/pollen-ui-angular/src/main/webapp/partials/poll-create.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-create.html 2014-04-25 15:34:32 UTC (rev 3877)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-create.html 2014-04-25 17:14:38 UTC (rev 3878)
@@ -1,129 +0,0 @@
-<!--
- ~
- ~ #%L
- ~ Pollen :: UI (Angular)
- ~ %%
- ~ Copyright (C) 2009 - 2014 CodeLutin
- ~ %%
- ~ 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%
- ~
- -->
-<form>
- <alert type="'success'" ng-if="gvar.saved"> Sondage sauvegardé..</alert>
-
- <div class="pollTitle pollAnim" ng-click="showEditTitle = true; gvar.saved = false;">
- <h1 ng-hide="showEditTitle"> {{poll.title}} </h1>
-
- <h1 ng-show="showEditTitle"><input type="text" focus-me="showEditTitle" ng-model="poll.title" ng-exit="showEditTitle = false"/></h1>
- </div>
-
- <div ng-hide="showEditDesc" class="pollDesc pollAnim" ng-click="showEditDesc = true; gvar.saved = false;">
- <div> Description (Facultatif):</div>
- <div ng-bind-html="toHTML(poll.description)"></div>
- </div>
- <div ng-show="showEditDesc" class="pollDesc " ng-exit="showEditDesc = false;">
- <textarea id="descEditor" data-ck-editor ng-model="poll.description"></textarea>
-
- <input type="button" value="Return" class="btn btn-primary" ng-click="showEditDesc = false;"/>
- </div>
-
- <div id="poll">
- <table>
- <tr>
- <td class="pollChoice"> Votant</td>
- <td ng-repeat="choice in poll.choices" class="pollChoice pollAnim"
- ng-click="showEdit = true; gvar.saved = false;">
- <div ng-show="choice.type == 'text'">
- <div ng-hide="showEdit" title="{{choice.description}}">{{choice.name}}</div>
- <div ng-show="showEdit">
- <input type="text" ng-model="choice.name" focus-me="showEdit" ng-exit="showEdit = false"/>
- <input type="button" class="btn" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
- </div>
- </div>
- <div ng-show="choice.type == 'date'">
- <div ng-hide="showEdit" title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}}</div>
- <div ng-show="showEdit">
- <input type="text" ng-model="choice.date" focus-me="showEdit" datepicker-popup="dd/MM/yyyy" ng-exit="showEdit = false"/>
- <input type="button" class="btn" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
- </div>
- </div>
- </td>
- <td><input type="button" class="btn btn-default" value="+" ng-click="addChoice()"/></td>
- </tr>
- <tr>
- <td class="pollChoice"> Name</td>
- <td ng-repeat="choice in poll.choices" class="pollChoice">
- <input type="checkbox" name="{{choice.name}}" ng-model="value"/>
- </td>
- <td></td>
- </tr>
- </table>
- <input class="btn btn-primary" type="button" value="Save" ng-click="save()"/>
-
- <br/><br/><br/>
- <input type="button" value="reset" ng-click="reset();"/>
- </div>
-</form>
-
-<script type="text/ng-template" id="popupChoice.html">
- <form class="form-horizontal">
- <div class="modal-header">
- <h4 class="modal-title">{{title}}</h4>
- </div>
- <div class="modal-body">
-
- <div class="form-group">
- <label class="col-sm-4 control-label">Type de choix :</label>
-
- <div class="col-sm-8 btn-group">
- <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'text'">Text</button>
- <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'date'">Date</button>
- <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'picture'" disabled>Image</button>
- </div>
- </div>
-
- <div class="form-group" ng-if="choice.type == 'text'">
- <label for="popNameChoiceCheck" class="col-sm-4 control-label">Nom du Choix : </label>
-
- <div class="col-sm-6">
- <input id="popNameChoiceCheck" type="text" ng-model="choice.name" class="form-control"/>
- </div>
- </div>
-
- <div class="form-group" ng-if="choice.type == 'date'">
- <label for="popNameChoiceDate" class="col-sm-4 control-label">Date : </label>
-
- <div class="col-sm-6">
- <div class="right-inner-addon ">
- <i class="glyphicon glyphicon-calendar glyphicon-input"></i>
- <input id="popNameChoiceDate" class="form-control" datepicker-popup="dd/MM/yyyy" type="text" ng-model="choice.date" is-open="opened"/>
- </div>
- </div>
- </div>
- <div class="form-group">
- <label for="popDescChoice" class="col-sm-4 control-label">Description : </label>
-
- <div class="col-sm-6">
- <textarea id="popDescChoice" type="text" ng-model="choice.description" class="form-control"></textarea>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-danger" data-dismiss="modal" ng-click="deleteChoice(choice)">delete</button>
- <button type="button" class="btn btn-primary" ng-click="saveChoice()">Save</button>
- </div>
- </form>
-</script>
-
Deleted: trunk/pollen-ui-angular/src/main/webapp/partials/poll-detail.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-detail.html 2014-04-25 15:34:32 UTC (rev 3877)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-detail.html 2014-04-25 17:14:38 UTC (rev 3878)
@@ -1,186 +0,0 @@
-<!--
- #%L
- Pollen :: UI (Angular)
- %%
- Copyright (C) 2009 - 2014 CodeLutin
- %%
- 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%
- -->
-<div class="page-header">
-
- <h1>{{ poll.title }}</h1>
-
- <p>
- {{ poll.creator.name }}
- <!-- number of votes -->
- | <a id="voteSummary" class='link'><i class='icon-user'></i> {{ votes.length }}</a>
- <!-- number of comments-->
- | <a id="commentSummary" class='link'><i class='icon-comment'></i> {{ comments.length }}</a>
- <!--<!– poll dates –>-->
- <!--<% if (poll.attr('beginDate') && poll.attr('endDate')) { %>-->
- <!--| <i class='icon-time'></i> <%= pollen.common.date.fromTo(moment(poll.attr('beginDate')).format(pollen.common.format.dateTime.moment), moment(poll.attr('endDate')).format(pollen.common.format.dateTime.moment)) %>-->
- <!--<% } else if (poll.attr('beginDate')) { %>-->
- <!--| <i class='icon-time'></i> <%= pollen.common.date.from(moment(poll.attr('beginDate')).format(pollen.common.format.dateTime.moment)) %>-->
- <!--<% } else if (poll.attr('endDate')) { %>-->
- <!--| <i class='icon-time'></i> <%= pollen.common.date.to(moment(poll.attr('endDate')).format(pollen.common.format.dateTime.moment)) %>-->
- <!--<% } %>-->
- </p>
-
- <p>{{ poll.description }}</p>
-
-</div>
-
-<!-- alert if the poll is closed -->
-<div ng-show="poll.closed" class="alert fade in">
- <button type="button" class="close" data-dismiss="alert">×</button>
- <%== pollen.vote.poll.closed.alert %>
-</div>
-
-<!-- list of the choices -->
-<div class='well'>
-
- <h3><%= pollen.vote.choices.list.title %></h3>
-
- <ol>
- <li ng-repeat="choice in choices"><strong>{{ choice.name }}</strong> :
- {{ choice.description }} <em ng-show="!choice.description"> <%= pollen.choice.noDescription %></em></li>
- </ol>
-
- <div ng-show="poll.choiceAddAllowed && poll.beginChoiceDate <= moment().valueOf() && poll.endChoiceDate > moment().valueOf()">
-
- <!-- link to show/hide the new choice form -->
- <button class="collapsed btn btn-link" data-toggle="collapse" data-target="#addChoiceForm">
- <%= pollen.vote.choices.list.button.addChoice %> <i class="icon-collapse"></i>
- </button>
-
- <!-- form to add a new choice to the poll -->
- <form id="addChoiceForm" class="collapse form-horizontal">
- <div class="control-group">
- <label class="control-label" ><%= pollen.choice.name.placeholder %></label>
- <div class="controls">
- <input type="text" name="name" placeholder="<%= pollen.choice.name.placeholder %>"/>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" ><%= pollen.choice.description.placeholder %></label>
- <div class="controls">
- <textarea name="description" placeholder="<%= pollen.choice.description.placeholder %>"></textarea>
- </div>
- </div>
- <div class="control-group">
- <div class="controls">
- <button type="submit" class="btn btn-primary"><%= pollen.common.validate %></button>
- </div>
- </div>
- </form>
- </div>
-</div>
-
-<!-- table of the votes -->
-<form id="voteForm">
-
- <h2><%= pollen.vote.votes.list.title %></h2>
-
- <table id="voteTable" class="table table-bordered table-striped">
- <thead>
- <tr>
- <th><%= pollen.vote.votes.list.header.voter %></th>
- <th ng-repeat="choice in choices" data-container='body' data-placement='top' title='{{ choice.description }}'>
- {{ choice.name }}
- </th>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="vote in votes" >
- <td>{{ vote.voterListMember.name }}</td>
- <td ng-repeat="choice in choices" ng-init="voteChoice = vote.voteToChoices[choice.id]">
- <div ng-hide="voteChoice" class='choice voteBeforeChoice'></div>
- <div ng-show="voteChoice" ng-class='[choice, voteChoice.voteValue : selected]'>
- <span ng-show="voteChoice.voteValue">OK</span>
- </div>
- </td>
- </tr>
-
- <tr>
- <td>Resultats</td>
- <td ng-repeat="choice in choices" class='result'>
- {{ poll.results[choice.id] }}
- </td>
- </tr>
-
- <tr ng-hide="poll.closed">
- <td>
- <div class="control-group">
- <div class="controls">
- <input name="userName"
- type='text'
- value='{{ currentUser.name }}'
- placeholder='<%= pollen.vote.form.add.field.userName.placeholder %>'
- required/>
- </div>
- </div>
- </td>
- <td ng-repeat="choice in choices"><input name="{{ $index }}" type='checkbox'/></td>
- </tr>
- </tbody>
- </table>
-
- <div ng-hide="poll.closed" class="form-actions">
- <button type="submit" id="voteButton" class="btn btn-primary"><%= pollen.vote.form.add.button.vote %></button>
- </div>
-
-</form>
-
-<!-- Comments -->
-<div id="comments">
- <h2><%= pollen.vote.comments.list.title %></h2>
-
- <button class="collapsed btn btn-link" data-toggle="collapse" data-target="#addCommentForm">
- <%= pollen.vote.comments.list.button.addComment %> <i class="icon-collapse"></i>
- </button>
-
- <form id="addCommentForm" ng-submit="addComment()" class="collapse form-horizontal">
- <div class="control-group">
- <label class="control-label" ><%= pollen.vote.comments.add.field.userName.placeholder %></label>
- <div class="controls">
- <input type="text" name="author" ng-model="author" placeholder="<%= pollen.vote.comments.add.field.userName.placeholder %>"/>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" ><%= pollen.vote.comments.add.field.message.placeholder %></label>
- <div class="controls">
- <textarea name="text" ng-model="text" placeholder="<%= pollen.vote.comments.add.field.message.placeholder %>"></textarea>
- </div>
- </div>
- <div class="control-group">
- <div class="controls">
- <button type="submit" class="btn btn-primary"><%= pollen.common.validate %></button>
- </div>
- </div>
- </form>
-
- <div class='list alternate-colors'>
-
- <div ng-repeat="comment in comments">
- <p>
- {{ comment.text }}
- </p>
- <div class='footer'>
- <small>{{ comment.author }} | {{ moment(comment.postDate).format(pollen.common.format.dateTime.moment) }}</small>
- </div>
- </div>
-
- </div>
-</div>
\ No newline at end of file
Deleted: trunk/pollen-ui-angular/src/main/webapp/partials/poll-form.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-form.html 2014-04-25 15:34:32 UTC (rev 3877)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-form.html 2014-04-25 17:14:38 UTC (rev 3878)
@@ -1,345 +0,0 @@
-<!--
- #%L
- Pollen :: UI (Angular)
- %%
- Copyright (C) 2009 - 2014 CodeLutin
- %%
- 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%
- -->
-<h1>pollen.poll.form.create.title</h1>
-
-<ul class="breadcrumb">
- <li ng-class='{ active : step >= 1 }' step="1"><span class='step'>pollen.poll.form.create.step1</span> <span class="divider">/</span></li>
- <li ng-class='{ active : step >= 2 }' step="2"><span class='step'>pollen.poll.form.create.step2</span> <span class="divider">/</span></li>
- <li ng-class='{ active : step >= 3 }' step="3"><span class='step'>pollen.poll.form.create.step3</span> <span class="divider">/</span></li>
-</ul>
-
-<form id='pollCreationForm' class="form-horizontal" action="http://localhost:8080/pollen/v1/polls">
-
- <!-- Basic info step -->
- <div class='step1' ng-show="step == 1">
- <h3>pollen.poll.form.create.step1</h3>
-
- <div class="control-group">
- <label class="control-label" for="pollCreationFormTitle">pollen.poll.title.label</label>
- <div class="controls">
- <input type='text' name='title' id='pollCreationFormTitle' class="input-xxlarge"
- placeholder='pollen.poll.title.placeholder'
- ng-model='poll.title'/>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for='pollCreationFormDescription'>pollen.poll.description.label</label>
- <div class="controls">
- <textarea id='pollCreationFormDescription' class="input-xxlarge"
- name='description'
- placeholder="pollen.poll.description.placeholder"
- ng-model="poll.description"></textarea>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for='pollCreationFormCreatorName'>pollen.poll.creator.name.label</label>
- <div class="controls">
- <input type='text' name='creator.name' id='pollCreationFormCreatorName' class="input-xxlarge"
- placeholder='pollen.poll.creator.name.placeholder'
- ng-model='poll.creator.name'/>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for='pollCreationFormCreatorEmail'>pollen.poll.creator.email.label</label>
- <div class="controls">
- <input type='text' name='creator.email' id='pollCreationFormCreatorEmail' class="input-xxlarge"
- placeholder='pollen.poll.creator.email.placeholder'
- ng-model='poll.creator.email'/>
- </div>
- </div>
-
- <div class="form-actions">
- <button type="button" class="btn nextStep" ng-click="next()">pollen.poll.form.create.button.next</button>
- </div>
- </div>
-
- <!-- choices step -->
- <div class='step2' ng-show="step == 2">
- <h3>pollen.poll.form.create.step2</h3>
-
- <div class="control-group row-fluid" ng-repeat="choice in poll.choices">
- <label class="control-label span1" for='pollCreationFormCreatorName'>pollen.poll.choice.name.label</label>
- <div class="controls span3">
- <input type='text' name='name' class="input-block-level"
- placeholder='pollen.poll.choice.name.placeholder'
- ng-model="choice.name"/>
- </div>
-
- <label class="control-label span1" for='pollCreationFormCreatorName'>pollen.poll.choice.description.label</label>
- <div class="controls span7">
- <textarea name='description' class="input-block-level"
- placeholder="pollen.poll.choice.description.placeholder"
- ng-model="choice.description"></textarea>
- </div>
- </div>
-
- <div class="form-actions">
- <button type="button" class="btn prevStep" ng-click="prev()">pollen.poll.form.create.button.previous</button>
- <button type='button' class='btn addChoice' ng-click="addChoice()">pollen.poll.form.create.button.addChoice</button>
- <button type='submit' class="btn btn-primary">pollen.poll.form.create.button.save</button>
- <button type="button" class="btn nextStep" ng-click="next()">pollen.poll.form.create.button.next</button>
- </div>
-
- </div>
-
- <!-- Options step -->
- <div class='step3' ng-show="step == 3">
-
- <h3>pollen.poll.form.create.step3</h3>
-
- <!-- dates -->
- <fieldset>
- <legend>pollen.poll.form.create.legend.validityDates</legend>
-
- <div class="control-group">
- <label class="control-label" for='pollCreationFormBeginDate'>pollen.poll.beginDate.label</label>
- <div class="controls">
- <div class="input-append dateTimePicker">
- <input type="text" name='beginDate' id='pollCreationFormBeginDate'
- placeholder='pollen.poll.beginDate.placeholder'
- value='<%= poll.attr("beginDate") ? moment(poll.attr("beginDate")).format(pollen.common.format.dateTime.moment) : "" %>'/>
- <span class="add-on">
- <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
- </span>
- </div>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for='pollCreationFormEndDate'>pollen.poll.endDate.label</label>
- <div class="controls">
- <div class="input-append dateTimePicker">
- <input type="text" name='endDate' id='pollCreationFormEndDate'
- placeholder='<%= pollen.poll.endDate.placeholder %>'
- value='<%= poll.attr("endDate") ? moment(poll.attr("endDate")).format(pollen.common.format.dateTime.moment) : "" %>'/>
- <span class="add-on">
- <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
- </span>
- </div>
- </div>
- </div>
-
- </fieldset>
-
- <!-- choices -->
- <fieldset>
- <legend>pollen.poll.form.create.legend.choices</legend>
-
- <div class="control-group">
- <div class="controls">
- <label class="checkbox">
- <input type="checkbox" id='pollCreationFormChoiceAddAllowed' name="choiceAddAllowed"
- ng-model="poll.choiceAddAllowed"/>
- pollen.poll.choiceAddAllowed.label
- </label>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for='pollCreationFormAddChoiceBeginDate'>pollen.poll.addChoiceBeginDate.label</label>
- <div class="controls">
- <div class="input-append dateTimePicker addChoiceDate">
- <input type="text" name='addChoiceBeginDate' id='pollCreationFormAddChoiceBeginDate'
- placeholder='pollen.poll.addChoiceBeginDate.placeholder'
- value='<%= poll.attr("addChoiceBeginDate") ? moment(poll.attr("addChoiceBeginDate")).format(pollen.common.format.dateTime.moment) : "" %>'/>
- <span class="add-on">
- <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
- </span>
- </div>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for='pollCreationFormAddChoiceEndDate'>pollen.poll.addChoiceEndDate.label</label>
- <div class="controls">
- <div class="input-append dateTimePicker addChoiceDate">
- <input type="text" name='addChoiceEndDate' id='pollCreationFormAddChoiceEndDate'
- placeholder='<%= pollen.poll.addChoiceEndDate.placeholder %>'
- value='<%= poll.attr("addChoiceEndDate") ? moment(poll.attr("addChoiceEndDate")).format(pollen.common.format.dateTime.moment) : "" %>'/>
- <span class="add-on">
- <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
- </span>
- </div>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for='pollCreationFormMaxChoiceNumber'>pollen.poll.maxChoiceNumber.label</label>
- <div class="controls">
- <input type='number' name='maxChoiceNumber' id='pollCreationFormMaxChoiceNumber' class="input-mini"
- placeholder='<%= pollen.poll.maxChoiceNumber.placeholder %>'
- ng-model='poll.maxChoiceNumber'/>
- <span class="help-inline">pollen.poll.maxChoiceNumber.help</span>
- </div>
- </div>
-
- </fieldset>
-
- <!-- votes -->
- <fieldset>
- <legend>pollen.poll.form.create.legend.votes</legend>
-
- <div class="control-group">
- <label class="control-label" for="pollCreationFormCommentVisibility">pollen.poll.commentVisibility.label</label>
- <div class="controls">
- <select name='commentVisibility' id='pollCreationFormCommentVisibility'>
- <option value="EVERYBODY">pollen.poll.commentVisibility.everybody.label</option>
- <option value="VOTER">pollen.poll.commentVisibility.voter.label</option>
- <option value="NOBODY">pollen.poll.commentVisibility.nobody.label</option>
- </select>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for="pollCreationFormVoteVisibility">pollen.poll.voteVisibility.label</label>
- <div class="controls">
- <select name='voteVisibility' id='pollCreationFormVoteVisibility'>
- <option value="EVERYBODY">pollen.poll.voteVisibility.everybody.label</option>
- <option value="VOTER">pollen.poll.voteVisibility.voter.label</option>
- <option value="CREATOR">pollen.poll.voteVisibility.creator.label</option>
- <option value="ANONYMOUS">pollen.poll.voteVisibility.anonymous.label</option>
- </select>
- </div>
- </div>
-
- <div class="control-group">
- <div class="controls">
- <label class="checkbox">
- <input type="checkbox" id='pollCreationFormAnonymousVoteAllowed' name="anonymousVoteAllowed"
- ng-model='poll.anonymousVoteAllowed'/>
- pollen.poll.anonymousVoteAllowed.label
- </label>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for="pollCreationFormPollType">pollen.poll.pollType.label</label>
- <div class="controls">
- <select name='pollType' id='pollCreationFormPollType'>
- <option value="FREE">pollen.poll.pollType.free.label</option>
- <option value="RESTRICTED">pollen.poll.pollType.restricted.label</option>
- <option value="GROUP">pollen.poll.pollType.group.label</option>
- </select>
- </div>
- </div>
-
- <%
- if (poll.attr("pollType") == "RESTRICTED") {
- poll.voterList[0].each(function(voter) {
- %>
- <div class="control-group row-fluid">
- <label class="control-label span1"><%= pollen.poll.voter.name.label %></label>
- <div class="controls span3">
- <input type='text' name='name' class="input-block-level"
- placeholder='<%= pollen.poll.voter.name.placeholder %>'
- value="<%= voter.attr('name') %>"
- <%= (el) -> el.data('owner', voter) %>/>
- </div>
-
- <label class="control-label span1"><%= pollen.poll.voter.email.label %></label>
- <div class="controls span4">
- <input type='text' name='email' class="input-block-level"
- placeholder='<%= pollen.poll.voter.email.placeholder %>'
- value="<%= voter.attr('email') %>"
- <%= (el) -> el.data('owner', voter) %>/>
- </div>
-
- <label class="control-label span1"><%= pollen.poll.voter.weight.label %></label>
- <div class="controls span1">
- <input type='text' name='weight' class="input-block-level"
- placeholder='<%= pollen.poll.voter.weight.placeholder %>'
- value="<%= voter.attr('weight') %>"
- <%= (el) -> el.data('owner', voter) %>/>
- </div>
-
- <button type="button" class='btn btn-danger span1'><i class="icon-minus icon-white"></i></button>
- </div>
- <% }) %>
- <button type="button" class='btn btn-success span1'><i class="icon-plus icon-white"></i></button>
- <% } %>
-
-
- </fieldset>
-
- <!-- results -->
- <fieldset>
- <legend>pollen.poll.form.create.legend.results</legend>
-
- <div class="control-group">
- <label class="control-label" for="pollCreationFormVoteCountingType"><%= pollen.poll.voteCountingType.label %></label>
- <div class="controls">
- <select name='voteCountingType' id='pollCreationFormVoteCountingType' <%= (el) -> el.data('owner', poll) %>>
- <option value="1" <%= (el) -> el.data('description', 'normal') %>><%= pollen.choice.voteType.normal.label %></option>
- <option value="2" <%= (el) -> el.data('description', 'percentage') %>><%= pollen.choice.voteType.percentage.label %></option>
- <option value="3" <%= (el) -> el.data('description', 'condorcet') %>><%= pollen.choice.voteType.condorcet.label %></option>
- <option value="4" <%= (el) -> el.data('description', 'number') %>><%= pollen.choice.voteType.number.label %></option>
- <option value="5" <%= (el) -> el.data('description', 'borda') %>><%= pollen.choice.voteType.borda.label %></option>
- <option value="6" <%= (el) -> el.data('description', 'alternative') %>><%= pollen.choice.voteType.alternative.label %></option>
- <option value="7" <%= (el) -> el.data('description', 'coombs') %>><%= pollen.choice.voteType.coombs.label %></option>
- </select>
- <span id='pollCreationFormVoteCountingTypeHelp' class="help-block">pollen.choice.voteType.normal.description</span>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for="pollCreationFormResultVisibility">pollen.poll.resultVisibility.label</label>
- <div class="controls">
- <select name='resultVisibility' id='pollCreationFormResultVisibility'>
- <option value="EVERYBODY">pollen.poll.resultVisibility.everybody.label</option>
- <option value="VOTER">pollen.poll.resultVisibility.voter.label</option>
- <option value="CREATOR">pollen.poll.resultVisibility.creator.label</option>
- </select>
- </div>
- </div>
-
- <div class="control-group">
- <div class="controls">
- <label class="checkbox">
- <input type="checkbox" id='pollCreationFormContinuousResults' name="continuousResults"
- ng-model="poll.continuousResults"/>
- pollen.poll.continuousResults.label
- </label>
- </div>
- </div>
-
- </fieldset>
-
-
- <div class="form-actions">
- <button type="button" class="btn prevStep" ng-click="prev()">pollen.poll.form.create.button.previous</button>
- <button type='submit' class="btn btn-primary">pollen.poll.form.create.button.save</button>
- </div>
- </div>
-
-</form>
-
-<script>
- /*$(function() {
- $('.dateTimePicker').datetimepicker({
- language: 'fr_FR',
- pickSeconds: false,
- format: pollen.common.format.dateTime.input
- });
- });*/
-</script>
\ No newline at end of file
Deleted: trunk/pollen-ui-angular/src/main/webapp/partials/poll-list.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-list.html 2014-04-25 15:34:32 UTC (rev 3877)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-list.html 2014-04-25 17:14:38 UTC (rev 3878)
@@ -1,34 +0,0 @@
-<!--
- #%L
- Pollen :: UI (Angular)
- %%
- Copyright (C) 2009 - 2014 CodeLutin
- %%
- 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%
- -->
-<div class="container-fluid">
- <div class="row-fluid">
- <div class="span10">
- <!--Body content-->
-
- <ul class="polls">
- <li ng-repeat="poll in polls" class="thumbnail">
- <a href="#/polls/{{poll.id}}">{{poll.title}}</a>
- </li>
- </ul>
-
- </div>
- </div>
-</div>
\ No newline at end of file
Deleted: trunk/pollen-ui-angular/src/main/webapp/partials/poll-vote.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-vote.html 2014-04-25 15:34:32 UTC (rev 3877)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-vote.html 2014-04-25 17:14:38 UTC (rev 3878)
@@ -1,38 +0,0 @@
-<div class="alert alert-success" ng-show="gvar.saved"> Vote effectué.. </div>
-
-<div class="pollTitle">
- <h1> {{poll.title}} </h1>
-</div>
-<div class="pollDesc" ng-hide="poll.description == ''" >
- <div ng-bind-html="toHTML(poll.description)"> </div>
-</div>
-<div id="poll" >
- <table>
- <tr>
- <td class="pollChoice"> Votant </td>
- <td ng-repeat="choice in poll.choices" class="pollChoice">
- <div ng-if="choice.type == 'text'">
- <div title="{{choice.description}}">{{choice.name}}</div>
- </div>
- <div ng-if="choice.type == 'date'">
- <div title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}}</div>
- </div>
- </td>
- </tr>
- <tr ng-repeat="vote in poll.votants track by $index" class="pollAnim">
- <td class="pollChoice"> {{vote.name}}</td>
- <td ng-repeat="choice in vote.choices" class="pollChoice">
- <input type="checkbox" ng-model="choice.value" disabled/>
- </td>
- </tr>
- <tr ng-hide="gvar.saved">
- <td class="pollChoice pollAnim"> <input type="text" ng-model="voteName" /> </td>
- <td ng-repeat="choice in voteChoices" class="pollChoice pollAnim" >
- <input type="checkbox" name="{{choice.name}}" ng-model="choice.value" />
- </td>
- </tr>
- </table>
- <input class="btn btn-primary" type="button" value="Vote" ng-click="vote()" ng-hide="gvar.saved"/>
-
-</div>
-
Added: trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll.html (rev 0)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-25 17:14:38 UTC (rev 3878)
@@ -0,0 +1,142 @@
+<!--
+ ~
+ ~ #%L
+ ~ Pollen :: UI (Angular)
+ ~ %%
+ ~ Copyright (C) 2009 - 2014 CodeLutin
+ ~ %%
+ ~ 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%
+ ~
+ -->
+<form class="form-inline">
+ <alert type="'success'" ng-if="gvar.editMode && gvar.saved"> Sondage sauvegardé..</alert>
+ <alert type="'success'" ng-if="!gvar.editMode && gvar.saved"> Vote effectué.. </alert>
+
+ <div class="pollTitle pollAnim" edit-me="showEditTitle">
+ <h1 ng-hide="showEditTitle"> {{poll.title || 'Click Me for Editing'}} </h1>
+
+ <h1 ng-show="showEditTitle"><input type="text" class="form-control" focus-me="showEditTitle" ng-model="poll.title" ng-exit="showEditTitle = false"/></h1>
+ </div>
+
+ <div ng-hide="showEditDesc" class="pollDesc pollAnim" edit-me="showEditDesc">
+ <div> </div>
+ <div ng-bind-html="toHTML(poll.description || 'Description (Facultatif). Ce cadre disparait si aucune description n\'est mise')"></div>
+ </div>
+ <div ng-show="showEditDesc" class="pollDesc " ng-exit="showEditDesc = false;">
+ <textarea id="descEditor" data-ck-editor ng-model="poll.description"></textarea>
+
+ <input type="button" value="Return" class="btn btn-primary" ng-click="showEditDesc = false;"/>
+ </div>
+
+ <div id="poll">
+ <table>
+ <tr>
+ <td class="pollChoice"></td>
+ <td ng-repeat="choice in poll.choices" class="pollChoice pollAnim" edit-me="showEdit" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
+ <div ng-show="choice.type == 'text'">
+ <div ng-hide="showEdit" title="{{choice.description}}">{{choice.name}} <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-show="gvar.editMode && showEditHover" ng-click="editChoice(choice)" value="..."/></div>
+ <div ng-show="showEdit">
+ <input type="text" class="form-control" ng-model="choice.name" focus-me="showEdit" ng-exit="showEdit = false"/>
+ <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
+ </div>
+ </div>
+ <div ng-show="choice.type == 'date'">
+ <div ng-hide="showEdit || isOpen" title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}} <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
+ <div ng-show="showEdit || isOpen">
+ <input type="text" class="form-control" ng-model="choice.date" focus-me="showEdit" datepicker-popup="dd/MM/yyyy" is-open="isOpen" ng-exit="showEdit = false" />
+ <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
+ </div>
+ </div>
+ </td>
+ <td ng-if="gvar.editMode"><input type="button" class="btn btn-default" value="+" ng-click="addChoice()"/></td>
+ </tr>
+
+ <tr>
+ <td class="pollChoice"> <input type="text" class="form-control" placeholder="votre nom" ng-model="voteName" /> </td>
+ <td ng-repeat="choice in voteChoices" class="pollChoice">
+ <input type="checkbox" name="{{choice.name}}" ng-model="choice.value"/>
+ </td>
+ <td></td>
+ </tr>
+
+ <tr ng-repeat="vote in poll.votants track by $index" class="pollAnim">
+ <td class="pollChoice"> {{vote.name}}</td>
+ <td ng-repeat="choice in vote.choices" class="pollChoice">
+ <input type="checkbox" ng-model="choice.value" disabled/>
+ </td>
+ </tr>
+ </table>
+
+ <div ng-if="gvar.editMode">
+ <input class="btn btn-primary" type="button" value="Save" ng-click="save()"/>
+ <br/><br/><br/>
+ <input type="button" value="reset" ng-click="reset();"/>
+ </div>
+
+ <div ng-if="!gvar.editMode">
+ <input class="btn btn-primary" type="button" value="Vote" ng-click="vote()" />
+ </div>
+ </div>
+</form>
+
+<script type="text/ng-template" id="popupChoice.html">
+ <form class="form-horizontal">
+ <div class="modal-header">
+ <h4 class="modal-title">{{title}}</h4>
+ </div>
+ <div class="modal-body">
+
+ <div class="form-group">
+ <label class="col-sm-4 control-label">Type de choix :</label>
+
+ <div class="col-sm-8 btn-group">
+ <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'text'">Text</button>
+ <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'date'">Date</button>
+ <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'picture'" disabled>Image</button>
+ </div>
+ </div>
+
+ <div class="form-group" ng-if="choice.type == 'text'">
+ <label for="popNameChoiceCheck" class="col-sm-4 control-label">Nom du Choix : </label>
+
+ <div class="col-sm-6">
+ <input id="popNameChoiceCheck" type="text" ng-model="choice.name" class="form-control" />
+ </div>
+ </div>
+
+ <div class="form-group" ng-if="choice.type == 'date'">
+ <label for="popNameChoiceDate" class="col-sm-4 control-label">Date : </label>
+
+ <div class="col-sm-6">
+ <div class="right-inner-addon ">
+ <i class="glyphicon glyphicon-calendar glyphicon-input"></i>
+ <input id="popNameChoiceDate" class="form-control" datepicker-popup="dd/MM/yyyy" type="text" ng-model="choice.date" is-open="opened"/>
+ </div>
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="popDescChoice" class="col-sm-4 control-label">Description : </label>
+
+ <div class="col-sm-6">
+ <textarea id="popDescChoice" type="text" ng-model="choice.description" class="form-control"></textarea>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-danger" data-dismiss="modal" ng-click="deleteChoice(choice)">delete</button>
+ <button type="button" class="btn btn-primary" ng-click="saveChoice()">Save</button>
+ </div>
+ </form>
+</script>
1
0
Author: tchemit
Date: 2014-04-25 17:34:32 +0200 (Fri, 25 Apr 2014)
New Revision: 3877
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3877
Log:
refs #885 : move to Topia3 stack
Added:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollImpl.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserTopiaDao.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUsers.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiServiceContext.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java
Removed:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaPollenPersistenceContext.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenEntityIdFactory.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Poll.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUser.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenJpaTransactionFilter.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AbstractPollenService.java
Modified:
trunk/pollen-persistence/pom.xml
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java
trunk/pollen-persistence/src/main/xmi/pollen.properties
trunk/pollen-persistence/src/main/xmi/pollen.zargo
trunk/pollen-rest-api/pom.xml
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenApplicationContext.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServices.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
trunk/pollen-services/pom.xml
trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityRealm.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java
trunk/pollen-services/src/test/resources/log4j.properties
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/AbstractVoteCounting.java
trunk/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java
trunk/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java
trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java
trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java
trunk/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java
trunk/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java
trunk/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java
trunk/pom.xml
Modified: trunk/pollen-persistence/pom.xml
===================================================================
--- trunk/pollen-persistence/pom.xml 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-persistence/pom.xml 2014-04-25 15:34:32 UTC (rev 3877)
@@ -18,12 +18,6 @@
<dependencies>
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>pollen-votecounting-api</artifactId>
- <version>${project.version}</version>
- </dependency-->
-
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
@@ -39,23 +33,18 @@
</dependency>
<dependency>
- <groupId>org.nuiton.jpa</groupId>
- <artifactId>nuiton-jpa-api</artifactId>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
</dependency>
<dependency>
- <groupId>org.nuiton.jpa</groupId>
- <artifactId>nuiton-jpa-hibernate</artifactId>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
- <groupId>org.hibernate.javax.persistence</groupId>
- <artifactId>hibernate-jpa-2.1-api</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
+ <artifactId>hibernate-c3p0</artifactId>
</dependency>
<dependency>
@@ -100,7 +89,7 @@
<configuration>
<!-- Corresponding to extracted package from zargo file -->
<fullPackagePath>
- org.chorem.pollen.persistence.entity
+ org.chorem.pollen.persistence
</fullPackagePath>
<!-- defaultPackage used for generation -->
<defaultPackage>
@@ -108,7 +97,7 @@
</defaultPackage>
<templates>
org.nuiton.eugene.java.JavaEnumerationTransformer,
- org.nuiton.jpa.templates.JpaMetaTransformer
+ org.nuiton.topia.templates.TopiaMetaTransformer
</templates>
</configuration>
<goals>
@@ -116,6 +105,13 @@
</goals>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-templates</artifactId>
+ <version>${topiaVersion}</version>
+ </dependency>
+ </dependencies>
</plugin>
</plugins>
</build>
Deleted: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaPollenPersistenceContext.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaPollenPersistenceContext.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaPollenPersistenceContext.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -1,61 +0,0 @@
-package org.chorem.pollen.persistence;
-
-/*
- * #%L
- * Pollen :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 org.nuiton.jpa.api.JpaEntity;
-import org.nuiton.jpa.api.JpaEntityIdFactory;
-import org.nuiton.jpa.hibernate.HibernateUtil;
-
-import javax.persistence.EntityManager;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class JpaPollenPersistenceContext extends AbstractJpaPollenPersistenceContext {
-
- public JpaPollenPersistenceContext(EntityManager entityManager) {
- this(new PollenEntityIdFactory(), entityManager);
- }
-
- public JpaPollenPersistenceContext(JpaEntityIdFactory idGenerator,
- EntityManager entityManager) {
- super(idGenerator, entityManager);
- }
-
- @Override
- public void detach(JpaEntity entity) {
- entityManager.detach(entity);
- }
-
- @Override
- public void clearDatabase() {
- rollback();
- HibernateUtil.cleanDatabase(entityManager);
- commit();
- }
-
-} //JpaPollenPersistenceContext
Deleted: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenEntityIdFactory.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenEntityIdFactory.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenEntityIdFactory.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -1,68 +0,0 @@
-package org.chorem.pollen.persistence;
-
-/*
- * #%L
- * Pollen :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 com.google.common.base.Preconditions;
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.codec.binary.Hex;
-import org.nuiton.jpa.api.JpaEntity;
-import org.nuiton.jpa.api.JpaEntityIdFactory;
-
-import java.util.UUID;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenEntityIdFactory implements JpaEntityIdFactory {
-
- public static String generateId() {
-
- // generate uuid
- String uuid = UUID.randomUUID().toString().replaceAll("-", "");
-
- // decode in hexa base
- byte[] decode;
- try {
- decode = Hex.decodeHex(uuid.toCharArray());
- } catch (DecoderException e) {
- // can't happen!
- throw new RuntimeException(e);
- }
-
- // encode it in base64 (url safe version)
- String result = Base64.encodeBase64URLSafeString(decode);
- return result;
- }
-
- @Override
- public String newId(JpaEntity entity) {
- Preconditions.checkNotNull(entity);
-
- return generateId();
- }
-}
Deleted: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -1,82 +0,0 @@
-package org.chorem.pollen.persistence;
-
-/*
- * #%L
- * Pollen :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 org.chorem.pollen.persistence.dao.ChoiceJpaDao;
-import org.chorem.pollen.persistence.dao.CommentJpaDao;
-import org.chorem.pollen.persistence.dao.FavoriteListJpaDao;
-import org.chorem.pollen.persistence.dao.FavoriteListMemberJpaDao;
-import org.chorem.pollen.persistence.dao.PollJpaDao;
-import org.chorem.pollen.persistence.dao.PollenPrincipalJpaDao;
-import org.chorem.pollen.persistence.dao.PollenUserJpaDao;
-import org.chorem.pollen.persistence.dao.SessionTokenJpaDao;
-import org.chorem.pollen.persistence.dao.VoteJpaDao;
-import org.chorem.pollen.persistence.dao.VoteToChoiceJpaDao;
-import org.chorem.pollen.persistence.dao.VoterJpaDao;
-import org.chorem.pollen.persistence.dao.VoterListJpaDao;
-import org.chorem.pollen.persistence.dao.VoterListMemberJpaDao;
-import org.nuiton.jpa.api.JpaEntity;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public interface PollenPersistenceContext {
-
- void detach(JpaEntity entity);
-
- void commit();
-
- void rollback();
-
- void clearDatabase();
-
- ChoiceJpaDao getChoiceDao();
-
- CommentJpaDao getCommentDao();
-
- FavoriteListJpaDao getFavoriteListDao();
-
- FavoriteListMemberJpaDao getFavoriteListMemberDao();
-
- PollJpaDao getPollDao();
-
- PollenPrincipalJpaDao getPollenPrincipalDao();
-
- PollenUserJpaDao getPollenUserDao();
-
- SessionTokenJpaDao getSessionTokenDao();
-
- VoteJpaDao getVoteDao();
-
- VoteToChoiceJpaDao getVoteToChoiceDao();
-
- VoterJpaDao getVoterDao();
-
- VoterListJpaDao getVoterListDao();
-
- VoterListMemberJpaDao getVoterListMemberDao();
-}
Deleted: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Poll.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Poll.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Poll.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -1,99 +0,0 @@
-package org.chorem.pollen.persistence.entity;
-
-/*
- * #%L
- * Pollen :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 com.google.common.collect.Sets;
-
-import javax.persistence.Entity;
-import java.util.Date;
-import java.util.Set;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-@Entity
-public class Poll extends AbstractJpaPoll {
-
- private static final long serialVersionUID = 1L;
-
- public boolean isFreePoll() {
- return PollType.FREE == pollType;
- }
-
- public boolean isRestrictedPoll() {
- return PollType.RESTRICTED == pollType;
- }
-
- public boolean isGroupPoll() {
- return PollType.GROUP == pollType;
- }
-
- public boolean isStarted(Date currentDate) {
- return beginDate == null || beginDate.before(currentDate);
- }
-
- public boolean isRunning(Date currentDate) {
- return !isClosed() &&
- isStarted(currentDate) &&
- !isFinished(currentDate);
- }
-
- public boolean isFinished(Date currentDate) {
- return endDate != null && currentDate.after(endDate);
- }
-
- public boolean isAddChoiceStarted(Date currentDate) {
- return isChoiceAddAllowed() &&
- (beginChoiceDate == null || beginChoiceDate.before(currentDate));
- }
-
- public boolean isAddChoiceRunning(Date currentDate) {
- return isChoiceAddAllowed() &&
- !isClosed() &&
- !isFinished(currentDate) &&
- isAddChoiceStarted(currentDate) &&
- !isAddChoiceFinished(currentDate);
- }
-
- public boolean isAddChoiceFinished(Date currentDate) {
- return !isChoiceAddAllowed() ||
- (endChoiceDate != null && endChoiceDate.before(currentDate));
- }
-
- public Set<VoterListMember> getAllVoters() {
- Set<VoterListMember> result = Sets.newHashSet();
- if (!isVoterListEmpty()) {
- for (VoterList list : getVoterList()) {
-
- if (!list.isVoterListMemberEmpty()) {
- result.addAll(list.getVoterListMember());
- }
- }
- }
- return result;
- }
-} //Poll
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollImpl.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollImpl.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -0,0 +1,107 @@
+package org.chorem.pollen.persistence.entity;
+
+/*
+ * #%L
+ * Pollen :: Persistence
+ * $Id$
+ * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-persistence/src/main/java/org… $
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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 com.google.common.collect.Sets;
+
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollImpl extends PollAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ //FIXME Remove this
+ public boolean isFreePoll() {
+ return Polls.isPollFree(this);
+ }
+
+ //FIXME Remove this
+ public boolean isRestrictedPoll() {
+ return Polls.isPollRestricted(this);
+ }
+
+ //FIXME Remove this
+ public boolean isGroupPoll() {
+ return Polls.isPollGroup(this);
+ }
+
+ //FIXME Remove this
+ public boolean isStarted(Date currentDate) {
+ return beginDate == null || beginDate.before(currentDate);
+ }
+
+ //FIXME Remove this
+ public boolean isRunning(Date currentDate) {
+ return !isClosed() &&
+ isStarted(currentDate) &&
+ !isFinished(currentDate);
+ }
+
+ //FIXME Remove this
+ public boolean isFinished(Date currentDate) {
+ return endDate != null && currentDate.after(endDate);
+ }
+
+ //FIXME Remove this
+ public boolean isAddChoiceStarted(Date currentDate) {
+ return isChoiceAddAllowed() &&
+ (beginChoiceDate == null || beginChoiceDate.before(currentDate));
+ }
+
+ //FIXME Remove this
+ public boolean isAddChoiceRunning(Date currentDate) {
+ return isChoiceAddAllowed() &&
+ !isClosed() &&
+ !isFinished(currentDate) &&
+ isAddChoiceStarted(currentDate) &&
+ !isAddChoiceFinished(currentDate);
+ }
+
+ //FIXME Remove this
+ public boolean isAddChoiceFinished(Date currentDate) {
+ return !isChoiceAddAllowed() ||
+ (endChoiceDate != null && endChoiceDate.before(currentDate));
+ }
+
+ //FIXME Remove this
+ public Set<VoterListMember> getAllVoters() {
+ Set<VoterListMember> result = Sets.newHashSet();
+ if (!isVoterListEmpty()) {
+ for (VoterList list : getVoterList()) {
+
+ if (!list.isVoterListMemberEmpty()) {
+ result.addAll(list.getVoterListMember());
+ }
+ }
+ }
+ return result;
+ }
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -0,0 +1,52 @@
+package org.chorem.pollen.persistence.entity;
+
+/*
+ * #%L
+ * Pollen :: Persistence
+ * $Id$
+ * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-persistence/src/main/java/org… $
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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 com.google.common.collect.Sets;
+
+import java.util.Set;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollTopiaDao extends AbstractPollTopiaDao<Poll> {
+
+ public Set<Poll> findAllCreated(String userId) {
+ //TODO
+ return Sets.newHashSet();
+ }
+
+ public Set<Poll> findAllInvited(String userId) {
+ //TODO
+ return Sets.newHashSet();
+ }
+
+ public Set<Poll> findAllParticipated(String userId) {
+ //TODO
+ return Sets.newHashSet();
+ }
+
+
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUser.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUser.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUser.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -1,43 +0,0 @@
-package org.chorem.pollen.persistence.entity;
-
-/*
- * #%L
- * Pollen :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 javax.persistence.Entity;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-@Entity
-public class PollenUser extends AbstractJpaPollenUser {
-
- private static final long serialVersionUID = 1L;
-
- public boolean isEmailActivated() {
- return emailActivationToken == null;
- }
-
-} //PollenUser
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -0,0 +1,40 @@
+package org.chorem.pollen.persistence.entity;
+
+/*
+ * #%L
+ * Pollen :: Persistence
+ * $Id$
+ * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-persistence/src/main/java/org… $
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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%
+ */
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenUserImpl extends PollenUserAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ public boolean isEmailActivated() {
+ return emailActivationToken == null;
+ }
+
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserTopiaDao.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserTopiaDao.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserTopiaDao.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -0,0 +1,41 @@
+package org.chorem.pollen.persistence.entity;
+
+/*
+ * #%L
+ * Pollen :: Persistence
+ * $Id$
+ * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-persistence/src/main/java/org… $
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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%
+ */
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenUserTopiaDao extends AbstractPollenUserTopiaDao<PollenUser> {
+
+ public boolean loginExists(String login) {
+ boolean exists = forLoginEquals(login).exists();
+ return exists;
+ }
+
+ public boolean emailExists(String email) {
+ boolean exists = forEmailEquals(email).exists();
+ return exists;
+ }
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserTopiaDao.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUsers.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUsers.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUsers.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -0,0 +1,14 @@
+package org.chorem.pollen.persistence.entity;
+
+/**
+ * Created on 4/25/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenUsers {
+
+ public static boolean isEmailActivated(PollenUser pollenUser) {
+ return pollenUser.getEmailActivationToken() == null;
+ }
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUsers.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -23,8 +23,12 @@
* #L%
*/
-import org.apache.commons.lang3.ObjectUtils;
+import com.google.common.collect.Sets;
+import java.util.Date;
+import java.util.Objects;
+import java.util.Set;
+
/**
* TODO
*
@@ -33,15 +37,33 @@
*/
public class Polls {
- public boolean isPollFree(Poll poll) {
- return ObjectUtils.equals(PollType.FREE, poll.getPollType());
+ public static boolean isPollFree(Poll poll) {
+ return Objects.equals(PollType.FREE, poll.getPollType());
}
- public boolean isPollRestricted(Poll poll) {
- return ObjectUtils.equals(PollType.RESTRICTED, poll.getPollType());
+ public static boolean isPollRestricted(Poll poll) {
+ return Objects.equals(PollType.RESTRICTED, poll.getPollType());
}
- public boolean isPollGroup(Poll poll) {
- return ObjectUtils.equals(PollType.GROUP, poll.getPollType());
+ public static boolean isPollGroup(Poll poll) {
+ return Objects.equals(PollType.GROUP, poll.getPollType());
}
+
+ public static boolean isStarted(Poll poll, Date currentDate) {
+ Date beginDate = poll.getBeginDate();
+ return beginDate == null || beginDate.before(currentDate);
+ }
+
+ public static Set<VoterListMember> getAllVoters(Poll poll) {
+ Set<VoterListMember> result = Sets.newHashSet();
+ if (poll.isVoterListNotEmpty()) {
+ for (VoterList list : poll.getVoterList()) {
+
+ if (!list.isVoterListMemberEmpty()) {
+ result.addAll(list.getVoterListMember());
+ }
+ }
+ }
+ return result;
+ }
}
Modified: trunk/pollen-persistence/src/main/xmi/pollen.properties
===================================================================
--- trunk/pollen-persistence/src/main/xmi/pollen.properties 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-persistence/src/main/xmi/pollen.properties 2014-04-25 15:34:32 UTC (rev 3877)
@@ -21,9 +21,11 @@
# #L%
###m
model.tagvalue.version=2.0
-model.tagValue.idFactory=true
-model.tagValue.generateVisitors=true
-model.tagValue.generateExtraTechnicalFields=true
+model.tagValue.notGenerateToString=true
+model.tagValue.constantPrefix=PROPERTY_
+model.tagValue.useEnumerationName=true
+model.tagValue.indexForeignKeys=true
+model.tagValue.String=string
org.chorem.pollen.persistence.entity.Poll.attribute.choice.stereotype=ordered
org.chorem.pollen.persistence.entity.Poll.attribute.voterList.stereotype=ordered
Modified: trunk/pollen-persistence/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-rest-api/pom.xml
===================================================================
--- trunk/pollen-rest-api/pom.xml 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/pom.xml 2014-04-25 15:34:32 UTC (rev 3877)
@@ -42,11 +42,6 @@
</dependency>
<dependency>
- <groupId>org.hibernate.javax.persistence</groupId>
- <artifactId>hibernate-jpa-2.1-api</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.nuiton.web</groupId>
<artifactId>nuiton-web</artifactId>
</dependency>
@@ -126,7 +121,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <scope>test</scope>
+ <scope>compile</scope>
</dependency>
</dependencies>
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenApplicationContext.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenApplicationContext.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenApplicationContext.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -25,17 +25,20 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.persistence.JpaPollenPersistenceContext;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.PropertyConfigurator;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.services.DefaultPollenServiceContext;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.nuiton.i18n.I18n;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
+import org.nuiton.i18n.init.I18nInitializer;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import javax.persistence.PersistenceException;
import java.io.Closeable;
-import java.util.Map;
+import java.io.File;
+import java.util.Locale;
/**
* TODO
@@ -45,81 +48,119 @@
*/
public class PollenApplicationContext implements Closeable {
- private static final Log log = LogFactory.getLog(PollenApplicationContext.class);
+ private static Log log = LogFactory.getLog(PollenApplicationContext.class);
protected static final String APPLICATION_CONTEXT_PARAMETER = "pollen_PollenApplicationContext";
- protected PollenServiceConfig applicationConfig;
+ protected static PollenTopiaApplicationContext topiaApplicationContext;
- protected EntityManagerFactory entityManagerFactory;
+ protected static PollenServiceConfig applicationConfig;
- public PollenServiceConfig getPollenServiceConfig() {
+ public static PollenServiceConfig getApplicationConfig() {
if (applicationConfig == null) {
applicationConfig = new PollenServiceConfig();
}
return applicationConfig;
}
- public EntityManager newEntityManager() {
+ public static PollenTopiaApplicationContext getTopiaApplicationContext() {
+ if (topiaApplicationContext == null) {
+ topiaApplicationContext = new PollenTopiaApplicationContext(getApplicationConfig().getTopiaProperties());
+ }
+ return topiaApplicationContext;
+ }
- if (entityManagerFactory == null) {
+ public static void setTopiaApplicationContext(PollenTopiaApplicationContext topiaApplicationContext) {
+ PollenApplicationContext.topiaApplicationContext = topiaApplicationContext;
+ }
- PollenServiceConfig applicationConfig = getPollenServiceConfig();
+ public PollenTopiaPersistenceContext newPersistenceContext() {
- Map<String, String> jpaParameters = applicationConfig.getJpaParameters();
+ PollenTopiaPersistenceContext persistenceContext = getTopiaApplicationContext().newPersistenceContext();
- if (log.isInfoEnabled()) {
- log.info("creating entity manager factory");
- }
+ return persistenceContext;
- try {
+ }
- entityManagerFactory = Persistence.createEntityManagerFactory("pollenPersistenceUnit", jpaParameters);
+ public PollenServiceContext newServiceContext(PollenTopiaPersistenceContext persistenceContext, Locale locale) {
- } catch (PersistenceException e) {
+ DefaultPollenServiceContext newServiceContext =
+ new DefaultPollenServiceContext();
- if (log.isErrorEnabled()) {
- log.error("unable to create entity manager factory", e);
- }
+ PollenServiceConfig applicationConfig = getApplicationConfig();
- throw e;
+ newServiceContext.setPollenServiceConfig(applicationConfig);
- }
+ newServiceContext.setPersistenceContext(persistenceContext);
- }
+ newServiceContext.setLocale(locale);
- EntityManager entityManager = entityManagerFactory.createEntityManager();
+ return newServiceContext;
- return entityManager;
-
}
+ @Override
public void close() {
- if (entityManagerFactory != null && entityManagerFactory.isOpen()) {
+ if (topiaApplicationContext != null) {
if (log.isInfoEnabled()) {
log.info("stopping Pollen, will close entity manager factory");
}
- entityManagerFactory.close();
+ topiaApplicationContext.closeContext();
}
}
- public PollenServiceContext newServiceContext(EntityManager entityManager) {
+ public void init() {
- DefaultPollenServiceContext serviceContext = new DefaultPollenServiceContext();
+ if (getApplicationConfig().isLogConfigurationProvided()) {
- JpaPollenPersistenceContext jpaMagaliePersistenceContext =
- new JpaPollenPersistenceContext(entityManager);
+ File log4jConfigurationFile = getApplicationConfig().getLogConfigurationFile();
- serviceContext.setPersistenceContext(jpaMagaliePersistenceContext);
+ String log4jConfigurationFileAbsolutePath = log4jConfigurationFile.getAbsolutePath();
- serviceContext.setPollenServiceConfig(applicationConfig);
+ if (log4jConfigurationFile.exists()) {
- return serviceContext;
+ if (log.isInfoEnabled()) {
+ log.info("will use logging configuration " + log4jConfigurationFileAbsolutePath);
+ }
+ // reset logger configuration
+ LogManager.resetConfiguration();
+
+ // use generate log config file
+ PropertyConfigurator.configure(log4jConfigurationFileAbsolutePath);
+
+ log = LogFactory.getLog(PollenApplicationContext.class);
+
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("there is no file " + log4jConfigurationFileAbsolutePath + ". Default logging configuration will be used.");
+ }
+ }
+
+ } else {
+ log.info("will use default logging configuration");
+ }
+
+ I18nInitializer initializer = new DefaultI18nInitializer("pollen");
+ // to show none translated sentences
+ initializer.setMissingKeyReturnNull(true);
+
+ I18n.init(initializer, Locale.FRANCE);
+
+// PollenTopiaPersistenceContext persistenceContext = newPersistenceContext();
+//
+// PollenServiceContext serviceContext = newServiceContext(persistenceContext, Locale.FRANCE);
+//
+// InitWaoService initWaoService = serviceContext.newService(InitWaoService.class);
+//
+// initWaoService.init();
+//
+// persistenceContext.closeContext();
+
}
}
Deleted: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenJpaTransactionFilter.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenJpaTransactionFilter.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenJpaTransactionFilter.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -1,87 +0,0 @@
-package org.chorem.pollen.rest.api;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 com.google.common.base.Preconditions;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.web.filter.JpaTransactionFilter;
-
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceException;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-
-public class PollenJpaTransactionFilter extends JpaTransactionFilter {
-
- private static final Log log =
- LogFactory.getLog(PollenJpaTransactionFilter.class);
-
- protected PollenApplicationContext applicationContext;
-
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
-
- super.init(filterConfig);
-
- if (log.isInfoEnabled()) {
- log.info("Init JPA Filter");
- }
-
-// applicationContext = PollenServices.getApplicationContext(
-// filterConfig.getServletContext());
-//
-// Preconditions.checkNotNull(applicationContext, "Could not find application context at ServletContext#pollen_PollenApplicationContext");
- }
-
- protected PollenApplicationContext getApplicationContext(ServletRequest request) {
- if (applicationContext == null) {
- applicationContext = PollenServices.getApplicationContext(
- request.getServletContext());
-
- Preconditions.checkNotNull(applicationContext, "Could not find application context at ServletContext#pollen_PollenApplicationContext");
- }
- return applicationContext;
- }
-
- @Override
- protected EntityManager createEntityManager(ServletRequest request) {
-
- EntityManager entityManager;
-
- try {
-
- entityManager = getApplicationContext(request).newEntityManager();
-
- } catch (PersistenceException e) {
-
- if (log.isErrorEnabled()) {
- log.error("unable to create entity manager", e);
- }
- throw e;
- }
- return entityManager;
- }
-}
Added: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiServiceContext.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiServiceContext.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiServiceContext.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -0,0 +1,78 @@
+package org.chorem.pollen.rest.api;
+
+import org.chorem.pollen.services.PollenSecurityContext;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.service.AuthService;
+import org.chorem.pollen.services.service.ChoiceService;
+import org.chorem.pollen.services.service.CommentService;
+import org.chorem.pollen.services.service.FavoriteListService;
+import org.chorem.pollen.services.service.FixturesService;
+import org.chorem.pollen.services.service.PollService;
+import org.chorem.pollen.services.service.PollenUserService;
+import org.chorem.pollen.services.service.SecurityService;
+import org.chorem.pollen.services.service.VoteCountingService;
+import org.chorem.pollen.services.service.VoteService;
+import org.chorem.pollen.services.service.VoterListService;
+
+/**
+ * Created on 4/25/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenRestApiServiceContext {
+
+ protected PollenServiceContext serviceContext;
+
+ public void setServiceContext(PollenServiceContext serviceContext) {
+ this.serviceContext = serviceContext;
+ }
+
+ public void setSecurityContext(PollenSecurityContext securityContext) {
+ serviceContext.setSecurityContext(securityContext);
+ }
+
+ public AuthService getAuthService() {
+ return serviceContext.newService(AuthService.class);
+ }
+
+ public ChoiceService getChoiceService() {
+ return serviceContext.newService(ChoiceService.class);
+ }
+
+ public CommentService getCommentService() {
+ return serviceContext.newService(CommentService.class);
+ }
+
+ public FavoriteListService getFavoriteListService() {
+ return serviceContext.newService(FavoriteListService.class);
+ }
+
+ public PollService getPollService() {
+ return serviceContext.newService(PollService.class);
+ }
+
+ public PollenUserService getPollenUserService() {
+ return serviceContext.newService(PollenUserService.class);
+ }
+
+ public VoteCountingService getVoteCountingService() {
+ return serviceContext.newService(VoteCountingService.class);
+ }
+
+ public VoterListService getVoterListService() {
+ return serviceContext.newService(VoterListService.class);
+ }
+
+ public VoteService getVoteService() {
+ return serviceContext.newService(VoteService.class);
+ }
+
+ public FixturesService getFixturesService() {
+ return serviceContext.newService(FixturesService.class);
+ }
+
+ public SecurityService getSecurityService() {
+ return serviceContext.newService(SecurityService.class);
+ }
+}
Property changes on: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiServiceContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -24,6 +24,7 @@
*/
import org.apache.commons.lang3.StringUtils;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.persistence.entity.SessionToken;
import org.chorem.pollen.services.PollenSecurityContext;
import org.chorem.pollen.services.PollenServiceContext;
@@ -31,8 +32,8 @@
import org.debux.webmotion.server.WebMotionFilter;
import org.debux.webmotion.server.call.HttpContext;
-import javax.persistence.EntityManager;
import javax.servlet.http.HttpServletResponse;
+import java.util.Locale;
/**
* Inject le service context dans les controlleurs.
@@ -49,15 +50,19 @@
PollenApplicationContext applicationContext =
PollenServices.getApplicationContext(context.getServletContext());
- EntityManager entityManager =
- PollenServices.getEntityManager(context.getRequest());
+ PollenTopiaPersistenceContext persistenceContext =
+ PollenServices.getPersistenceContext(context.getRequest());
PollenServiceContext serviceContext =
- applicationContext.newServiceContext(entityManager);
- PollenServices.setServiceContext(context.getRequest(), serviceContext);
+ applicationContext.newServiceContext(persistenceContext, Locale.FRANCE);
- addSecurityContext(context, serviceContext);
+ PollenRestApiServiceContext apiContext = new PollenRestApiServiceContext();
+ apiContext.setServiceContext(serviceContext);
+ PollenServices.setServiceContext(context.getRequest(), apiContext);
+
+ addSecurityContext(context, apiContext);
+
doProcess();
HttpServletResponse response = context.getResponse();
@@ -66,7 +71,7 @@
}
protected void addSecurityContext(HttpContext context,
- PollenServiceContext serviceContext) throws InvalidSessionTokenException {
+ PollenRestApiServiceContext serviceContext) throws InvalidSessionTokenException {
String[] strings = context.getParameters().get(REQUEST_AUTH_PARAMETER);
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -24,11 +24,11 @@
*/
import org.apache.commons.beanutils.Converter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
+import org.chorem.pollen.services.service.PollenUserService;
import org.debux.webmotion.server.WebMotionServerListener;
import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.HttpContext;
@@ -36,10 +36,10 @@
import org.debux.webmotion.server.handler.ExecutorParametersInjectorHandler;
import org.debux.webmotion.server.mapping.Mapping;
-import javax.persistence.EntityManager;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Type;
import java.util.Date;
+import java.util.Locale;
/**
* TODO
@@ -49,10 +49,6 @@
*/
public class PollenServiceListener implements WebMotionServerListener {
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(PollenServiceListener.class);
-
@Override
public void onStart(Mapping mapping, ServerContext serverContext) {
serverContext.addConverter(new Converter() {
@@ -83,18 +79,18 @@
PollenServices.setApplicationContext(
serverContext.getServletContext(), applicationContext);
- EntityManager entityManager = applicationContext.newEntityManager();
+ PollenTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext();
try {
PollenServiceContext serviceContext =
- applicationContext.newServiceContext(entityManager);
- serviceContext.getPollenUserService().createDefaultUsers();
+ applicationContext.newServiceContext(persistenceContext, Locale.FRANCE);
+ serviceContext.newService(PollenUserService.class).createDefaultUsers();
} catch (InvalidPollenUserFormException e) {
//Can't happen
} catch (EntityNotFoundException e) {
//Can't happen
} finally {
- entityManager.close();
+ persistenceContext.closeContext();
}
}
@@ -114,8 +110,8 @@
protected static class PollenServiceContextInjector implements ExecutorParametersInjectorHandler.Injector {
@Override
- public Object getValue(Mapping mapping, Call call, String name, Class<?> type, Type generic) {
- PollenServiceContext result = null;
+ public PollenRestApiServiceContext getValue(Mapping mapping, Call call, String name, Class<?> type, Type generic) {
+ PollenRestApiServiceContext result = null;
if (PollenServiceContext.class.isAssignableFrom(type)) {
HttpContext httpContext = call.getContext();
HttpServletRequest request = httpContext.getRequest();
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServices.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServices.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServices.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -23,11 +23,10 @@
* #L%
*/
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.persistence.entity.SessionToken;
-import org.chorem.pollen.services.PollenServiceContext;
import org.nuiton.web.filter.JpaTransactionFilter;
-import javax.persistence.EntityManager;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -59,19 +58,20 @@
}
- public static PollenServiceContext getServiceContext(HttpServletRequest request) {
- PollenServiceContext result = (PollenServiceContext)
+ public static PollenRestApiServiceContext getServiceContext(HttpServletRequest request) {
+ PollenRestApiServiceContext result = (PollenRestApiServiceContext)
request.getAttribute(REQUEST_POLLEN_SERVICE_CONTEXT);
return result;
}
public static void setServiceContext(HttpServletRequest request,
- PollenServiceContext serviceContext) {
+ PollenRestApiServiceContext serviceContext) {
request.setAttribute(REQUEST_POLLEN_SERVICE_CONTEXT, serviceContext);
}
- public static EntityManager getEntityManager(HttpServletRequest request) {
- EntityManager result = (EntityManager)
+
+ public static PollenTopiaPersistenceContext getPersistenceContext(HttpServletRequest request) {
+ PollenTopiaPersistenceContext result = (PollenTopiaPersistenceContext)
request.getAttribute(REQUEST_ENTITY_MANAGER);
return result;
}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java (from rev 3875, trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenJpaTransactionFilter.java)
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -0,0 +1,75 @@
+package org.chorem.pollen.rest.api;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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 com.google.common.base.Preconditions;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.nuiton.topia.persistence.TopiaException;
+import org.nuiton.web.filter.TypedTopiaTransactionFilter;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+
+public class PollenTopiaTransactionFilter extends TypedTopiaTransactionFilter<PollenTopiaPersistenceContext> {
+
+ private static final Log log =
+ LogFactory.getLog(PollenTopiaTransactionFilter.class);
+
+ protected PollenApplicationContext applicationContext;
+
+ protected PollenTopiaTransactionFilter() {
+ super(PollenTopiaPersistenceContext.class);
+ }
+
+ @Override
+ protected PollenTopiaPersistenceContext beginTransaction(ServletRequest request) throws TopiaException {
+ PollenApplicationContext applicationContext = getApplicationContext(request);
+ PollenTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext();
+ return persistenceContext;
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+
+ super.init(filterConfig);
+
+ if (log.isInfoEnabled()) {
+ log.info("Init Topia Filter");
+ }
+ }
+
+ protected PollenApplicationContext getApplicationContext(ServletRequest request) {
+ if (applicationContext == null) {
+ applicationContext = PollenServices.getApplicationContext(
+ request.getServletContext());
+
+ Preconditions.checkNotNull(applicationContext, "Could not find application context at ServletContext#pollen_PollenApplicationContext");
+ }
+ return applicationContext;
+ }
+
+}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.SessionToken;
-import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.UserInvalidPasswordException;
import org.debux.webmotion.server.WebMotionController;
@@ -37,15 +37,15 @@
*/
public class AuthService extends WebMotionController {
- public SessionToken login(PollenServiceContext context, String login, String password) throws UserInvalidPasswordException, EntityNotFoundException {
+ public SessionToken login(PollenRestApiServiceContext context, String login, String password) throws UserInvalidPasswordException, EntityNotFoundException {
return context.getAuthService().login(login, password);
}
- public void lostPassword(PollenServiceContext context, String login) throws EntityNotFoundException {
+ public void lostPassword(PollenRestApiServiceContext context, String login) throws EntityNotFoundException {
context.getAuthService().lostPassword(login);
}
- public void logout(PollenServiceContext context, String login, String token) throws EntityNotFoundException {
+ public void logout(PollenRestApiServiceContext context, String login, String token) throws EntityNotFoundException {
context.getAuthService().logout(login, token);
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.Choice;
-import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidChoiceFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -39,28 +39,28 @@
*/
public class ChoiceService extends WebMotionController {
- public List<Choice> getChoices(PollenServiceContext context, String pollId) throws EntityNotFoundException {
+ public List<Choice> getChoices(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject((String) null);
List<Choice> choices = context.getChoiceService().getChoices(pollId);
return choices;
}
- public Choice getChoice(PollenServiceContext context, String pollId, String choiceId) throws EntityNotFoundException {
+ public Choice getChoice(PollenRestApiServiceContext context, String pollId, String choiceId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(choiceId);
return context.getChoiceService().getChoice(pollId, choiceId);
}
- public Choice addChoice(PollenServiceContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
+ public Choice addChoice(PollenRestApiServiceContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getChoiceService().addChoice(pollId, choice);
}
- public Choice editChoice(PollenServiceContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
+ public Choice editChoice(PollenRestApiServiceContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
context.getSecurityService().prepareSubject(choice);
return context.getChoiceService().editChoice(pollId, choice);
}
- public void deleteChoice(PollenServiceContext context, String pollId, String choiceId) throws EntityNotFoundException {
+ public void deleteChoice(PollenRestApiServiceContext context, String pollId, String choiceId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(choiceId);
context.getChoiceService().deleteChoice(pollId, choiceId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.Comment;
-import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidCommentFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -39,28 +39,28 @@
*/
public class CommentService extends WebMotionController {
- public List<Comment> getComments(PollenServiceContext context, String pollId) throws EntityNotFoundException {
+ public List<Comment> getComments(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
List<Comment> comments = context.getCommentService().getComments(pollId);
return comments;
}
- public Comment getComment(PollenServiceContext context, String pollId, String commentId) throws EntityNotFoundException {
+ public Comment getComment(PollenRestApiServiceContext context, String pollId, String commentId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(commentId);
return context.getCommentService().getComment(pollId, commentId);
}
- public Comment addComment(PollenServiceContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
+ public Comment addComment(PollenRestApiServiceContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getCommentService().addComment(pollId, comment);
}
- public Comment editComment(PollenServiceContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
+ public Comment editComment(PollenRestApiServiceContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
context.getSecurityService().prepareSubject(comment);
return context.getCommentService().editComment(pollId, comment);
}
- public void deleteComment(PollenServiceContext context, String pollId, String commentId) throws EntityNotFoundException {
+ public void deleteComment(PollenRestApiServiceContext context, String pollId, String commentId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(commentId);
context.getCommentService().deleteComment(pollId, commentId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -25,7 +25,7 @@
import org.chorem.pollen.persistence.entity.FavoriteList;
import org.chorem.pollen.persistence.entity.FavoriteListMember;
-import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.FavoriteListImportException;
import org.chorem.pollen.services.exception.InvalidFavoriteListFormException;
@@ -43,53 +43,53 @@
*/
public class FavoriteListService extends WebMotionController {
- public List<FavoriteList> getFavoriteLists(PollenServiceContext context, String userId) throws EntityNotFoundException {
+ public List<FavoriteList> getFavoriteLists(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
List<FavoriteList> favoriteLists = context.getFavoriteListService().getFavoriteLists(userId);
return favoriteLists;
}
- public FavoriteList getFavoriteList(PollenServiceContext context, String userId, String favoriteListId) throws EntityNotFoundException {
+ public FavoriteList getFavoriteList(PollenRestApiServiceContext context, String userId, String favoriteListId) throws EntityNotFoundException {
return context.getFavoriteListService().getFavoriteList(userId, favoriteListId);
}
- public FavoriteList createFavoriteList(PollenServiceContext context, String userId, FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
+ public FavoriteList createFavoriteList(PollenRestApiServiceContext context, String userId, FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
return context.getFavoriteListService().createFavoriteList(userId, favoriteList);
}
- public FavoriteList editFavoriteList(PollenServiceContext context, String userId, FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
+ public FavoriteList editFavoriteList(PollenRestApiServiceContext context, String userId, FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
return context.getFavoriteListService().editFavoriteList(userId, favoriteList);
}
- public void deleteFavoriteList(PollenServiceContext context, String userId, String favoriteListId) throws EntityNotFoundException {
+ public void deleteFavoriteList(PollenRestApiServiceContext context, String userId, String favoriteListId) throws EntityNotFoundException {
context.getFavoriteListService().deleteFavoriteList(userId, favoriteListId);
}
- public int importFavoriteListMembersFromCsv(PollenServiceContext context, String userId, String favoriteListId, File csvFile) throws EntityNotFoundException, FavoriteListImportException {
+ public int importFavoriteListMembersFromCsv(PollenRestApiServiceContext context, String userId, String favoriteListId, File csvFile) throws EntityNotFoundException, FavoriteListImportException {
return context.getFavoriteListService().importFavoriteListMembersFromCsv(userId, favoriteListId, csvFile);
}
- public int importFavoriteListMembersFromLdap(PollenServiceContext context, String userId, String favoriteListId, String ldap) throws EntityNotFoundException, FavoriteListImportException {
+ public int importFavoriteListMembersFromLdap(PollenRestApiServiceContext context, String userId, String favoriteListId, String ldap) throws EntityNotFoundException, FavoriteListImportException {
return context.getFavoriteListService().importFavoriteListMembersFromLdap(userId, favoriteListId, ldap);
}
- public List<FavoriteListMember> getMembers(PollenServiceContext context, String userId, String favoriteListId) throws EntityNotFoundException {
+ public List<FavoriteListMember> getMembers(PollenRestApiServiceContext context, String userId, String favoriteListId) throws EntityNotFoundException {
List<FavoriteListMember> members = context.getFavoriteListService().getFavoriteListMembers(userId, favoriteListId);
return members;
}
- public FavoriteListMember getMember(PollenServiceContext context, String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
+ public FavoriteListMember getMember(PollenRestApiServiceContext context, String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
return context.getFavoriteListService().getFavoriteListMember(userId, favoriteListId, memberId);
}
- public FavoriteListMember addMember(PollenServiceContext context, String userId, String favoriteListId, FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
+ public FavoriteListMember addMember(PollenRestApiServiceContext context, String userId, String favoriteListId, FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
return context.getFavoriteListService().addFavoriteListMember(userId, favoriteListId, member);
}
- public FavoriteListMember editMember(PollenServiceContext context, String userId, String favoriteListId, FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
+ public FavoriteListMember editMember(PollenRestApiServiceContext context, String userId, String favoriteListId, FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
return context.getFavoriteListService().editFavoriteListMember(userId, favoriteListId, member);
}
- public void removeMember(PollenServiceContext context, String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
+ public void removeMember(PollenRestApiServiceContext context, String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
context.getFavoriteListService().removeFavoriteListMember(userId, favoriteListId, memberId);
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -25,7 +25,7 @@
import org.chorem.pollen.persistence.entity.ChoiceType;
import org.chorem.pollen.persistence.entity.Poll;
-import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -41,60 +41,60 @@
*/
public class PollService extends WebMotionController {
- public Poll getNewPoll(PollenServiceContext context, String userId, ChoiceType choiceType) throws EntityNotFoundException {
+ public Poll getNewPoll(PollenRestApiServiceContext context, String userId, ChoiceType choiceType) throws EntityNotFoundException {
return context.getPollService().getNewPoll(userId, choiceType);
}
- public Set<Poll> getPolls(PollenServiceContext context, String userId) throws EntityNotFoundException {
+ public Set<Poll> getPolls(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
Set<Poll> polls = context.getPollService().getPolls(userId);
return polls;
}
- public Set<Poll> getCreatedPolls(PollenServiceContext context, String userId) throws EntityNotFoundException {
+ public Set<Poll> getCreatedPolls(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
Set<Poll> polls = context.getPollService().getCreatedPolls(userId);
return polls;
}
- public Set<Poll> getInvitedPolls(PollenServiceContext context, String userId) throws EntityNotFoundException {
+ public Set<Poll> getInvitedPolls(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
Set<Poll> polls = context.getPollService().getInvitedPolls(userId);
return polls;
}
- public Set<Poll> getParticipatedPolls(PollenServiceContext context, String userId) throws EntityNotFoundException {
+ public Set<Poll> getParticipatedPolls(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
Set<Poll> polls = context.getPollService().getParticipatedPolls(userId);
return polls;
}
- public Poll getPoll(PollenServiceContext context, String pollId) throws EntityNotFoundException {
- context.getSecurityService().prepareSubject((String)null);
+ public Poll getPoll(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
+ context.getSecurityService().prepareSubject((String) null);
return context.getPollService().getPoll(pollId);
}
- public Poll createPoll(PollenServiceContext context, String userId, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
+ public Poll createPoll(PollenRestApiServiceContext context, String userId, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
return context.getPollService().createPoll(userId, poll);
}
- public Poll editPoll(PollenServiceContext context, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
+ public Poll editPoll(PollenRestApiServiceContext context, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
context.getSecurityService().prepareSubject(poll);
return context.getPollService().editPoll(poll);
}
- public void deletePoll(PollenServiceContext context, String pollId) throws EntityNotFoundException {
+ public void deletePoll(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
context.getPollService().deletePoll(pollId);
}
- public Poll clonePoll(PollenServiceContext context, String pollId) throws EntityNotFoundException {
+ public Poll clonePoll(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
return context.getPollService().clonePoll(pollId);
}
- public File closePoll(PollenServiceContext context, String pollId) throws EntityNotFoundException {
+ public File closePoll(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
return context.getPollService().closePoll(pollId);
}
- public File exportPoll(PollenServiceContext context, String pollId) throws EntityNotFoundException {
+ public File exportPoll(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
return context.getPollService().exportPoll(pollId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.PollenUser;
-import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
@@ -41,34 +41,34 @@
*/
public class PollenUserService extends WebMotionController {
- public List<PollenUser> getUsers(PollenServiceContext context) {
+ public List<PollenUser> getUsers(PollenRestApiServiceContext context) {
List<PollenUser> users = context.getPollenUserService().getUsers();
return users;
}
- public PollenUser getUser(PollenServiceContext context, String userId) throws EntityNotFoundException {
+ public PollenUser getUser(PollenRestApiServiceContext context, String userId) throws EntityNotFoundException {
return context.getPollenUserService().getUser(userId);
}
- public PollenUser createUser(PollenServiceContext context,
+ public PollenUser createUser(PollenRestApiServiceContext context,
PollenUser user,
boolean generatePassword) throws EntityNotFoundException, InvalidPollenUserFormException {
return context.getPollenUserService().createUser(user, generatePassword);
}
- public PollenUser editUser(PollenServiceContext context,
+ public PollenUser editUser(PollenRestApiServiceContext context,
PollenUser user) throws EntityNotFoundException, InvalidPollenUserFormException {
return context.getPollenUserService().editUser(user);
}
- public void validateUserEmail(PollenServiceContext context,
+ public void validateUserEmail(PollenRestApiServiceContext context,
String userId,
String token) throws EntityNotFoundException, UserInvalidEmailActivationTokenException {
context.getPollenUserService().validateUserEmail(userId, token);
}
- public void changePassword(PollenServiceContext context,
+ public void changePassword(PollenRestApiServiceContext context,
String userId,
String oldPassword,
String newPassword) throws EntityNotFoundException, UserInvalidPasswordException {
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -23,8 +23,8 @@
* #L%
*/
+import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
import org.chorem.pollen.services.PollResult;
-import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.debux.webmotion.server.WebMotionController;
@@ -36,7 +36,7 @@
*/
public class VoteCountingService extends WebMotionController {
- public PollResult getResult(PollenServiceContext context, String pollId) throws EntityNotFoundException {
+ public PollResult getResult(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
return context.getVoteCountingService().getResult(pollId);
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.Vote;
-import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidVoteFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -39,28 +39,28 @@
*/
public class VoteService extends WebMotionController {
- public List<Vote> getVotes(PollenServiceContext context, String pollId) throws EntityNotFoundException {
+ public List<Vote> getVotes(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
List<Vote> votes = context.getVoteService().getVotes(pollId);
return votes;
}
- public Vote getVote(PollenServiceContext context, String pollId, String voteId) throws EntityNotFoundException {
+ public Vote getVote(PollenRestApiServiceContext context, String pollId, String voteId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(voteId);
return context.getVoteService().getVote(pollId, voteId);
}
- public Vote addVote(PollenServiceContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
+ public Vote addVote(PollenRestApiServiceContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getVoteService().addVote(pollId, vote);
}
- public Vote editVote(PollenServiceContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
+ public Vote editVote(PollenRestApiServiceContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
context.getSecurityService().prepareSubject(vote);
return context.getVoteService().editVote(pollId, vote);
}
- public void deleteVote(PollenServiceContext context, String pollId, String voteId) throws EntityNotFoundException {
+ public void deleteVote(PollenRestApiServiceContext context, String pollId, String voteId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(voteId);
context.getVoteService().deleteVote(pollId, voteId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -25,7 +25,7 @@
import org.chorem.pollen.persistence.entity.VoterList;
import org.chorem.pollen.persistence.entity.VoterListMember;
-import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.rest.api.PollenRestApiServiceContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidVoterListFormException;
import org.chorem.pollen.services.exception.InvalidVoterListMemberFormException;
@@ -42,58 +42,58 @@
*/
public class VoterListService extends WebMotionController {
- public VoterList importFavoriteList(PollenServiceContext context, String userId, String pollId, String favoriteListId) throws EntityNotFoundException {
+ public VoterList importFavoriteList(PollenRestApiServiceContext context, String userId, String pollId, String favoriteListId) throws EntityNotFoundException {
return context.getVoterListService().importFavoriteList(userId, pollId, favoriteListId);
}
- public List<VoterList> getVoterLists(PollenServiceContext context, String pollId) throws EntityNotFoundException {
+ public List<VoterList> getVoterLists(PollenRestApiServiceContext context, String pollId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(pollId);
List<VoterList> voterLists = context.getVoterListService().getVoterLists(pollId);
return voterLists;
}
- public VoterList getVoterList(PollenServiceContext context, String pollId, String voterListId) throws EntityNotFoundException {
+ public VoterList getVoterList(PollenRestApiServiceContext context, String pollId, String voterListId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(voterListId);
return context.getVoterListService().getVoterList(pollId, voterListId);
}
- public VoterList createVoterList(PollenServiceContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
+ public VoterList createVoterList(PollenRestApiServiceContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getVoterListService().addVoterList(pollId, voterList);
}
- public VoterList editVoterList(PollenServiceContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
+ public VoterList editVoterList(PollenRestApiServiceContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
context.getSecurityService().prepareSubject(voterList);
return context.getVoterListService().editVoterList(pollId, voterList);
}
- public void deleteVoterList(PollenServiceContext context, String pollId, String voterListId) throws EntityNotFoundException {
+ public void deleteVoterList(PollenRestApiServiceContext context, String pollId, String voterListId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(voterListId);
context.getVoterListService().deleteVoterList(pollId, voterListId);
}
- public Set<VoterListMember> getMembers(PollenServiceContext context, String pollId, String voterListId) throws EntityNotFoundException {
+ public Set<VoterListMember> getMembers(PollenRestApiServiceContext context, String pollId, String voterListId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(voterListId);
Set<VoterListMember> members = context.getVoterListService().getVoterListMembers(pollId, voterListId);
return members;
}
- public VoterListMember getMember(PollenServiceContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException {
+ public VoterListMember getMember(PollenRestApiServiceContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(memberId);
return context.getVoterListService().getVoterListMember(pollId, voterListId, memberId);
}
- public VoterListMember addMember(PollenServiceContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
+ public VoterListMember addMember(PollenRestApiServiceContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
context.getSecurityService().prepareSubject(member);
return context.getVoterListService().addVoterListMember(pollId, voterListId, member);
}
- public VoterListMember editMember(PollenServiceContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
+ public VoterListMember editMember(PollenRestApiServiceContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
context.getSecurityService().prepareSubject(member);
return context.getVoterListService().editVoterListMember(pollId, voterListId, member);
}
- public void deleteMember(PollenServiceContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException {
+ public void deleteMember(PollenRestApiServiceContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException {
context.getSecurityService().prepareSubject(memberId);
context.getVoterListService().deleteVoterListMember(pollId, voterListId, memberId);
}
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -23,16 +23,25 @@
* #L%
*/
-import org.chorem.pollen.persistence.JpaPollenPersistenceContext;
+import org.apache.commons.lang3.SystemUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.services.PollenFixtures;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.service.FixturesService;
import org.debux.webmotion.unittest.WebMotionJUnit;
-import org.junit.Rule;
-import org.nuiton.jpa.junit.JpaEntityManagerRule;
+import org.hibernate.cfg.Environment;
+import org.junit.After;
-import javax.persistence.EntityManager;
+import java.io.File;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
import java.util.Map;
+import java.util.UUID;
/**
* TODO
@@ -42,63 +51,148 @@
*/
public class AbstractPollenRestApiTest extends WebMotionJUnit {
- protected JpaEntityManagerRule jpaEntityManagerRule;
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(AbstractPollenRestApiTest.class);
+ protected PollenApplicationContext applicationContext;
+
+ protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
+
protected PollenFixtures fixtures;
- protected PollenApplicationContext applicationContext;
+ @After
+ public void tearDown() {
+ for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("closing transaction " + openedTransaction);
+ }
+
+ openedTransaction.closeContext();
+
+ }
+
+ if (applicationContext != null) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("closing application context " + applicationContext);
+ }
+ applicationContext.close();
+ }
+ }
+
+ protected PollenTopiaApplicationContext newTopiaApplicationContext(String dataBase) {
+
+ Map<String, String> hibernateH2Config = new HashMap<>();
+
+ hibernateH2Config.putAll(PollenApplicationContext.getApplicationConfig().getTopiaProperties());
+
+ hibernateH2Config.put(Environment.DRIVER, org.h2.Driver.class.getName());
+ hibernateH2Config.put(Environment.DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
+ hibernateH2Config.put(Environment.USER, "sa");
+ hibernateH2Config.put(Environment.PASS, "sa");
+ hibernateH2Config.put(Environment.HBM2DDL_AUTO, "update");
+
+ File tempDirFile = SystemUtils.getJavaIoTmpDir();
+
+ File databaseFile = new File(tempDirFile, dataBase);
+
+ String h2dataPath = databaseFile.getAbsolutePath() + File.separator + "h2data";
+
+ String jdbcUrl = "jdbc:h2:file:" + h2dataPath;
+
+ hibernateH2Config.put(Environment.URL, jdbcUrl);
+
+ if (log.isTraceEnabled()) {
+ log.trace("will store H2 data in " + h2dataPath);
+ log.trace("allTopiaParameters = " + hibernateH2Config);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("jdbc url is\n" + jdbcUrl);
+ }
+
+ PollenTopiaApplicationContext applicationContext = new PollenTopiaApplicationContext(hibernateH2Config);
+
+ if (log.isTraceEnabled()) {
+ log.trace("created root context " + applicationContext);
+ }
+
+ return applicationContext;
+ }
+
public PollenApplicationContext getApplicationContext() {
if (applicationContext == null) {
+
+ // prepare db
+
+ String databaseName = UUID.randomUUID().toString();
+
+ PollenTopiaApplicationContext pollenTopiaApplicationContext = newTopiaApplicationContext(databaseName);
+
+ PollenApplicationContext.setTopiaApplicationContext(pollenTopiaApplicationContext);
+
applicationContext =
new PollenApplicationContext() {
@Override
- public PollenServiceContext newServiceContext(EntityManager entityManager) {
+ public PollenServiceContext newServiceContext(PollenTopiaPersistenceContext persistenceContext, Locale locale) {
FakePollenServiceContext serviceContext = new FakePollenServiceContext();
-
- JpaPollenPersistenceContext jpaMagaliePersistenceContext =
- new JpaPollenPersistenceContext(entityManager);
-
- serviceContext.setPersistenceContext(jpaMagaliePersistenceContext);
-
+ serviceContext.setPersistenceContext(persistenceContext);
serviceContext.setPollenServiceConfig(applicationConfig);
return serviceContext;
}
+
+ @Override
+ public PollenTopiaPersistenceContext newPersistenceContext() {
+ PollenTopiaPersistenceContext pollenTopiaPersistenceContext = super.newPersistenceContext();
+ openedTransactions.add(pollenTopiaPersistenceContext);
+ return pollenTopiaPersistenceContext;
+ }
};
}
return applicationContext;
}
- @Rule
- public JpaEntityManagerRule getJpaEntityManagerRule() {
+ protected PollenTopiaPersistenceContext newPersistenceContext() {
- if (jpaEntityManagerRule == null) {
+ if (applicationContext == null) {
- Map<String, String> jpaParameters = getApplicationContext().getPollenServiceConfig().getJpaParameters();
+ applicationContext = getApplicationContext();
+ }
- jpaEntityManagerRule = new JpaEntityManagerRule("pollenPersistenceUnit", jpaParameters);
+ PollenTopiaPersistenceContext persistenceContext;
+
+ persistenceContext = applicationContext.newPersistenceContext();
+
+ if (log.isTraceEnabled()) {
+ log.trace("opened transaction " + persistenceContext);
}
- return jpaEntityManagerRule;
+ openedTransactions.add(persistenceContext);
+
+ return persistenceContext;
+
}
protected PollenServiceContext getServiceContext() {
- EntityManager entityManager = getJpaEntityManagerRule().newEntityManager();
+ PollenTopiaPersistenceContext entityManager = getApplicationContext().newPersistenceContext();
- PollenServiceContext result = applicationContext.newServiceContext(entityManager);
+ PollenServiceContext result = applicationContext.newServiceContext(entityManager, Locale.FRANCE);
return result;
}
protected void loadFixtures(String fixturesSetName) {
- FixturesService fixturesService = getServiceContext().getFixturesService();
+ FixturesService fixturesService = getServiceContext().newService(FixturesService.class);
+
fixtures = fixturesService.loadFixtures(fixturesSetName);
}
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/pom.xml 2014-04-25 15:34:32 UTC (rev 3877)
@@ -16,21 +16,15 @@
<dependencies>
- <!--dependency>
+ <dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>pollen-votecounting-api</artifactId>
+ <artifactId>pollen-persistence</artifactId>
<version>${project.version}</version>
- </dependency-->
-
- <dependency>
- <groupId>org.hibernate.javax.persistence</groupId>
- <artifactId>hibernate-jpa-2.1-api</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>pollen-persistence</artifactId>
- <version>${project.version}</version>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-junit</artifactId>
</dependency>
<dependency>
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -23,34 +23,26 @@
* #L%
*/
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
-import org.chorem.pollen.persistence.PollenEntityIdFactory;
-import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
-import org.chorem.pollen.services.service.AuthService;
-import org.chorem.pollen.services.service.ChoiceService;
-import org.chorem.pollen.services.service.CommentService;
-import org.chorem.pollen.services.service.FavoriteListService;
-import org.chorem.pollen.services.service.FixturesService;
-import org.chorem.pollen.services.service.PollService;
-import org.chorem.pollen.services.service.PollenUserService;
-import org.chorem.pollen.services.service.SecurityService;
-import org.chorem.pollen.services.service.VoteCountingService;
-import org.chorem.pollen.services.service.VoteService;
-import org.chorem.pollen.services.service.VoterListService;
import org.nuiton.util.StringUtil;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.Locale;
+import java.util.UUID;
public class DefaultPollenServiceContext implements PollenServiceContext {
protected PollenServiceConfig pollenServiceConfig;
- protected PollenPersistenceContext persistenceContext;
+ protected PollenTopiaPersistenceContext persistenceContext;
protected PollenSecurityContext securityContext;
@@ -60,7 +52,7 @@
this.pollenServiceConfig = pollenServiceConfig;
}
- public void setPersistenceContext(PollenPersistenceContext persistenceContext) {
+ public void setPersistenceContext(PollenTopiaPersistenceContext persistenceContext) {
this.persistenceContext = persistenceContext;
}
@@ -79,7 +71,7 @@
@Override
public String generateToken() {
- return PollenEntityIdFactory.generateId();
+ return generateId();
}
@Override
@@ -98,66 +90,11 @@
}
@Override
- public PollenPersistenceContext getPersistenceContext() {
+ public PollenTopiaPersistenceContext getPersistenceContext() {
return persistenceContext;
}
@Override
- public AuthService getAuthService() {
- return newService(AuthService.class);
- }
-
- @Override
- public ChoiceService getChoiceService() {
- return newService(ChoiceService.class);
- }
-
- @Override
- public CommentService getCommentService() {
- return newService(CommentService.class);
- }
-
- @Override
- public FavoriteListService getFavoriteListService() {
- return newService(FavoriteListService.class);
- }
-
- @Override
- public PollService getPollService() {
- return newService(PollService.class);
- }
-
- @Override
- public PollenUserService getPollenUserService() {
- return newService(PollenUserService.class);
- }
-
- @Override
- public VoteCountingService getVoteCountingService() {
- return newService(VoteCountingService.class);
- }
-
- @Override
- public VoterListService getVoterListService() {
- return newService(VoterListService.class);
- }
-
- @Override
- public VoteService getVoteService() {
- return newService(VoteService.class);
- }
-
- @Override
- public FixturesService getFixturesService() {
- return newService(FixturesService.class);
- }
-
- @Override
- public SecurityService getSecurityService() {
- return newService(SecurityService.class);
- }
-
- @Override
public String encodePassword(String password) {
return StringUtil.encodeMD5(password);
}
@@ -175,7 +112,7 @@
return email == null ? null : StringUtils.lowerCase(email.trim());
}
- public <E extends PollenServiceSupport> E newService(Class<E> serviceClass) {
+ public <E extends PollenService> E newService(Class<E> serviceClass) {
E service;
@@ -208,4 +145,23 @@
}
+ protected String generateId() {
+
+ // generate uuid
+ String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+
+ // decode in hexa base
+ byte[] decode;
+ try {
+ decode = Hex.decodeHex(uuid.toCharArray());
+ } catch (DecoderException e) {
+ // can't happen!
+ throw new RuntimeException(e);
+ }
+
+ // encode it in base64 (url safe version)
+ String result = Base64.encodeBase64URLSafeString(decode);
+ return result;
+ }
+
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,15 +27,15 @@
import com.esotericsoftware.yamlbeans.YamlReader;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
-import org.chorem.pollen.persistence.entity.Choice;
-import org.chorem.pollen.persistence.entity.Comment;
-import org.chorem.pollen.persistence.entity.FavoriteList;
-import org.chorem.pollen.persistence.entity.FavoriteListMember;
-import org.chorem.pollen.persistence.entity.Poll;
-import org.chorem.pollen.persistence.entity.PollenUser;
-import org.chorem.pollen.persistence.entity.Vote;
-import org.chorem.pollen.persistence.entity.VoterList;
-import org.chorem.pollen.persistence.entity.VoterListMember;
+import org.chorem.pollen.persistence.entity.ChoiceImpl;
+import org.chorem.pollen.persistence.entity.CommentImpl;
+import org.chorem.pollen.persistence.entity.FavoriteListImpl;
+import org.chorem.pollen.persistence.entity.FavoriteListMemberImpl;
+import org.chorem.pollen.persistence.entity.PollImpl;
+import org.chorem.pollen.persistence.entity.PollenUserImpl;
+import org.chorem.pollen.persistence.entity.VoteImpl;
+import org.chorem.pollen.persistence.entity.VoterListImpl;
+import org.chorem.pollen.persistence.entity.VoterListMemberImpl;
import java.io.IOException;
import java.io.InputStream;
@@ -55,15 +55,15 @@
throw new IllegalArgumentException(fixturesName + " is not a valid fixtures set name", e);
}
YamlReader reader = new YamlReader(yaml);
- reader.getConfig().setClassTag("poll", Poll.class);
- reader.getConfig().setClassTag("user", PollenUser.class);
- reader.getConfig().setClassTag("favorite-list", FavoriteList.class);
- reader.getConfig().setClassTag("favorite-list-member", FavoriteListMember.class);
- reader.getConfig().setClassTag("comment", Comment.class);
- reader.getConfig().setClassTag("choice", Choice.class);
- reader.getConfig().setClassTag("voter-list", VoterList.class);
- reader.getConfig().setClassTag("voter-list-member", VoterListMember.class);
- reader.getConfig().setClassTag("vote", Vote.class);
+ reader.getConfig().setClassTag("poll", PollImpl.class);
+ reader.getConfig().setClassTag("user", PollenUserImpl.class);
+ reader.getConfig().setClassTag("favorite-list", FavoriteListImpl.class);
+ reader.getConfig().setClassTag("favorite-list-member", FavoriteListMemberImpl.class);
+ reader.getConfig().setClassTag("comment", CommentImpl.class);
+ reader.getConfig().setClassTag("choice", ChoiceImpl.class);
+ reader.getConfig().setClassTag("voter-list", VoterListImpl.class);
+ reader.getConfig().setClassTag("voter-list-member", VoterListMemberImpl.class);
+ reader.getConfig().setClassTag("vote", VoteImpl.class);
try {
fixtures = (Map<String, Object>) reader.read();
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityRealm.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityRealm.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityRealm.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -43,7 +43,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class PollenSecurityRealm extends AuthorizingRealm implements PollenServiceSupport {
+public class PollenSecurityRealm extends AuthorizingRealm implements PollenService {
protected PollenServiceContext serviceContext;
@@ -67,7 +67,7 @@
String username = upToken.getUsername();
char[] password = upToken.getPassword();
- AuthService authService = serviceContext.getAuthService();
+ AuthService authService = serviceContext.newService(AuthService.class);
try {
authService.login(username, new String(password));
} catch (EntityNotFoundException e) {
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenService.java (from rev 3875, trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenService.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -0,0 +1,35 @@
+package org.chorem.pollen.services;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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%
+ */
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public interface PollenService {
+
+ void setServiceContext(PollenServiceContext serviceContext);
+}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -23,19 +23,8 @@
* #L%
*/
-import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
-import org.chorem.pollen.services.service.AuthService;
-import org.chorem.pollen.services.service.ChoiceService;
-import org.chorem.pollen.services.service.CommentService;
-import org.chorem.pollen.services.service.FavoriteListService;
-import org.chorem.pollen.services.service.FixturesService;
-import org.chorem.pollen.services.service.PollService;
-import org.chorem.pollen.services.service.PollenUserService;
-import org.chorem.pollen.services.service.SecurityService;
-import org.chorem.pollen.services.service.VoteCountingService;
-import org.chorem.pollen.services.service.VoteService;
-import org.chorem.pollen.services.service.VoterListService;
import java.util.Date;
import java.util.Locale;
@@ -54,32 +43,12 @@
void setSecurityContext(PollenSecurityContext securityContext);
- PollenPersistenceContext getPersistenceContext();
+ PollenTopiaPersistenceContext getPersistenceContext();
PollenServiceConfig getPollenServiceConfig();
- AuthService getAuthService();
+ <E extends PollenService> E newService(Class<E> serviceClass);
- ChoiceService getChoiceService();
-
- CommentService getCommentService();
-
- FavoriteListService getFavoriteListService();
-
- PollService getPollService();
-
- PollenUserService getPollenUserService();
-
- VoteCountingService getVoteCountingService();
-
- VoterListService getVoterListService();
-
- VoteService getVoteService();
-
- FixturesService getFixturesService();
-
- SecurityService getSecurityService();
-
String generatePassword();
String encodePassword(String password);
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -1,35 +0,0 @@
-package org.chorem.pollen.services;
-
-/*
- * #%L
- * Pollen :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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%
- */
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public interface PollenServiceSupport {
-
- void setServiceContext(PollenServiceContext serviceContext);
-}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -25,6 +25,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.persistence.entity.CommentVisibility;
@@ -34,6 +35,7 @@
import org.nuiton.config.ApplicationConfig;
import org.nuiton.config.ArgumentsParserException;
+import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -71,15 +73,25 @@
}
}
- public Map<String, String> getJpaParameters() {
+ public Map<String, String> getTopiaProperties() {
Map<String, String> jpaParameters = Maps.newHashMap();
Properties hibernateProperties = applicationConfig.getOptionStartsWith("hibernate");
jpaParameters.putAll((Map) hibernateProperties);
- Properties jpaProperties = applicationConfig.getOptionStartsWith("javax.persistence");
- jpaParameters.putAll((Map) jpaProperties);
+ Properties topiaProperties = applicationConfig.getOptionStartsWith("topia");
+ jpaParameters.putAll((Map) topiaProperties);
return jpaParameters;
}
+ public boolean isLogConfigurationProvided() {
+ boolean logConfigurationProvided =
+ StringUtils.isNotBlank(applicationConfig.getOption(PollenServiceConfigOption.LOG_CONFIGURATION_FILE.key));
+ return logConfigurationProvided;
+ }
+
+ public File getLogConfigurationFile() {
+ return applicationConfig.getOptionAsFile(PollenServiceConfigOption.LOG_CONFIGURATION_FILE.key);
+ }
+
public boolean isDevMode() {
boolean isDevMode = applicationConfig.getOptionAsBoolean(PollenServiceConfigOption.DEV_MODE.key);
return isDevMode;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -28,7 +28,7 @@
import org.chorem.pollen.persistence.entity.VoteVisibility;
import org.nuiton.config.ConfigOptionDef;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.n;
/**
@@ -46,7 +46,7 @@
*/
DEFAULT_POLL_TYPE(
"pollen.default.pollType",
- n_("pollen.configuration.defaultPollType"),
+ n("pollen.configuration.defaultPollType"),
PollType.FREE.name(),
PollType.class),
@@ -57,7 +57,7 @@
*/
DEFAULT_VOTE_COUNTING_TYPE(
"pollen.default.voteCountingType",
- n_("pollen.configuration.defaultVoteCountingType"),
+ n("pollen.configuration.defaultVoteCountingType"),
"0",
Integer.class),
@@ -68,7 +68,7 @@
*/
DEFAULT_VOTE_VISIBILITY(
"pollen.default.pollVoteVisibility",
- n_("pollen.configuration.defaultPollVoteVisibility"),
+ n("pollen.configuration.defaultPollVoteVisibility"),
VoteVisibility.EVERYBODY.name(),
VoteVisibility.class),
@@ -79,7 +79,7 @@
*/
DEFAULT_COMMENT_VISIBILITY(
"pollen.default.pollCommentVisibility",
- n_("pollen.configuration.defaultPollCommentVisibility"),
+ n("pollen.configuration.defaultPollCommentVisibility"),
CommentVisibility.EVERYBODY.name(),
CommentVisibility.class),
@@ -101,7 +101,12 @@
DEV_MODE(
"pollen.devMode",
"Mode développement, court-circuite l'envoi de mail",
- "true", Boolean.class),;
+ "true", Boolean.class),
+ LOG_CONFIGURATION_FILE(
+ "logConfigurationFile",
+ "Chemin vers le fichier de configuration des journaux",
+ null,
+ String.class),;
protected final String key;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -23,7 +23,7 @@
* #L%
*/
-import org.nuiton.jpa.api.JpaEntity;
+import org.nuiton.topia.persistence.TopiaEntity;
/**
* When an entity is not found in database.
@@ -35,17 +35,17 @@
private static final long serialVersionUID = -5760536098822762990L;
- protected final Class<? extends JpaEntity> entityType;
+ protected final Class<? extends TopiaEntity> entityType;
protected final String entityId;
- public EntityNotFoundException(Class<? extends JpaEntity> entityType,
+ public EntityNotFoundException(Class<? extends TopiaEntity> entityType,
String entityId) {
this.entityType = entityType;
this.entityId = entityId;
}
- public Class<? extends JpaEntity> getEntityType() {
+ public Class<? extends TopiaEntity> getEntityType() {
return entityType;
}
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AbstractPollenService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AbstractPollenService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AbstractPollenService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -1,185 +0,0 @@
-package org.chorem.pollen.services.service;
-
-/*
- * #%L
- * Pollen :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 com.google.common.base.Preconditions;
-import com.google.common.collect.Multimap;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.chorem.pollen.persistence.PollenPersistenceContext;
-import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.PollenServiceSupport;
-import org.chorem.pollen.services.config.PollenServiceConfig;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.nuiton.jpa.api.JpaEntities;
-import org.nuiton.jpa.api.JpaEntity;
-import org.nuiton.util.StringUtil;
-
-import java.util.Collection;
-import java.util.Date;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public abstract class AbstractPollenService implements PollenServiceSupport {
-
- // -- PollenServiceSupport -- //
-
- protected PollenServiceContext serviceContext;
-
- public String createPermission(PermissionVerb verb, String id) {
- return ":" + verb.name() + ":" + id;
- }
-
- @Override
- public void setServiceContext(PollenServiceContext serviceContext) {
- this.serviceContext = serviceContext;
- }
-
- // -- Delegate serviceContext -- //
-
- protected Date getNow() {
- return serviceContext.getNow();
- }
-
- protected String generateToken() {
- return serviceContext.generateToken();
- }
-
- protected String getCleanMail(String email) {
- return serviceContext.getCleanMail(email);
- }
-
- protected PollenPersistenceContext getPersistenceContext() {
- return serviceContext.getPersistenceContext();
- }
-
- protected PollenServiceConfig getPollenServiceConfig() {
- return serviceContext.getPollenServiceConfig();
- }
-
- protected AuthService getAuthService() {
- return serviceContext.getAuthService();
- }
-
- public ChoiceService getChoiceService() {
- return serviceContext.getChoiceService();
- }
-
- protected CommentService getCommentService() {
- return serviceContext.getCommentService();
- }
-
- protected FavoriteListService getFavoriteListService() {
- return serviceContext.getFavoriteListService();
- }
-
- protected PollService getPollService() {
- return serviceContext.getPollService();
- }
-
- protected SecurityService getSecurityService() {
- return serviceContext.getSecurityService();
- }
-
- protected PollenUserService getUserService() {
- return serviceContext.getPollenUserService();
- }
-
- protected VoteCountingService getVoteCountingService() {
- return serviceContext.getVoteCountingService();
- }
-
- protected VoterListService getVoterListService() {
- return serviceContext.getVoterListService();
- }
-
- protected VoteService getVoteService() {
- return serviceContext.getVoteService();
- }
-
- // -- check method -- //
-
- protected void checkPermission(PermissionVerb verb, String id) {
- String permission = createPermission(verb, id);
-// serviceContext.getSecurityContext().getSubject().checkPermission(permission);
- }
-
- protected void checkHasId(JpaEntity entity) {
- Preconditions.checkState(JpaEntities.isEntityHasId(entity));
- }
-
- protected void checkHasNoId(JpaEntity entity) {
- Preconditions.checkState(JpaEntities.isEntityHasNoId(entity));
- }
-
- protected <E extends JpaEntity> void checkEntityExists(Class<E> type,
- E entity,
- String entityId) throws EntityNotFoundException {
- if (entity == null) {
- throw new EntityNotFoundException(type, entityId);
- }
- }
-
- protected boolean check(Multimap<String, String> errors, String field, boolean condition, String error) {
- boolean valid = condition;
- if (!valid) {
- errors.put(field, error);
- }
- return valid;
- }
-
- protected boolean checkNot(Multimap<String, String> errors, String field, boolean condition, String error) {
- boolean valid = check(errors, field, !condition, error);
- return valid;
- }
-
- protected boolean checkNotNull(Multimap<String, String> errors, String field, Object value, String error) {
- boolean valid = check(errors, field, value != null, error);
- return valid;
- }
-
- protected boolean checkEmpty(Multimap<String, String> errors, String field, Collection<?> value, String error) {
- boolean valid = check(errors, field, CollectionUtils.isEmpty(value), error);
- return valid;
- }
-
- protected boolean checkNotEmpty(Multimap<String, String> errors, String field, Collection<?> value, String error) {
- boolean valid = check(errors, field, CollectionUtils.isNotEmpty(value), error);
- return valid;
- }
-
- protected boolean checkNotBlank(Multimap<String, String> errors, String field, String value, String error) {
- boolean valid = check(errors, field, StringUtils.isNotBlank(value), error);
- return valid;
- }
-
- protected boolean checkValidEmail(Multimap<String, String> errors, String field, String value, String error) {
- boolean valid = check(errors, field, StringUtil.isEmail(value), error);
- return valid;
- }
-}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -26,10 +26,10 @@
import com.google.common.base.Preconditions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.persistence.dao.PollenUserJpaDao;
-import org.chorem.pollen.persistence.dao.SessionTokenJpaDao;
import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.PollenUserTopiaDao;
import org.chorem.pollen.persistence.entity.SessionToken;
+import org.chorem.pollen.persistence.entity.SessionTokenTopiaDao;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidSessionTokenException;
import org.chorem.pollen.services.exception.UserInvalidPasswordException;
@@ -40,7 +40,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class AuthService extends AbstractPollenService {
+public class AuthService extends PollenServiceSupport {
/** Logger. */
private static final Log log = LogFactory.getLog(AuthService.class);
@@ -57,7 +57,7 @@
}
// Create a new session Token
- SessionTokenJpaDao dao = getPersistenceContext().getSessionTokenDao();
+ SessionTokenTopiaDao dao = getPersistenceContext().getSessionTokenDao();
SessionToken sessionToken = dao.newInstance();
String token = serviceContext.generateToken();
@@ -66,7 +66,7 @@
sessionToken.setToken(encodedToken);
sessionToken.setCreationDate(serviceContext.getNow());
- dao.persist(sessionToken);
+ dao.create(sessionToken);
getPersistenceContext().commit();
return sessionToken;
@@ -75,7 +75,7 @@
public void lostPassword(String login) throws EntityNotFoundException {
Preconditions.checkNotNull(login);
- PollenUserJpaDao dao = getPersistenceContext().getPollenUserDao();
+ PollenUserTopiaDao dao = getPersistenceContext().getPollenUserDao();
PollenUser user = getUserService().getUserByLogin(login);
@@ -83,7 +83,7 @@
String newPassword = serviceContext.generatePassword();
String encodedPassword = serviceContext.encodePassword(newPassword);
user.setPassword(encodedPassword);
- dao.merge(user);
+// dao.update(user);
getPersistenceContext().commit();
//TODO Notifiy Password changed
@@ -99,18 +99,18 @@
getUserService().getUserByLogin(login);
- SessionTokenJpaDao dao = getPersistenceContext().getSessionTokenDao();
+ SessionTokenTopiaDao dao = getPersistenceContext().getSessionTokenDao();
- SessionToken sessionToken = dao.findById(token);
+ SessionToken sessionToken = dao.findByTopiaId(token);
checkEntityExists(SessionToken.class, sessionToken, token);
- dao.remove(sessionToken);
+ dao.delete(sessionToken);
getPersistenceContext().commit();
}
public SessionToken getUserByAuth(String authParam) throws InvalidSessionTokenException {
- SessionToken sessionToken = getPersistenceContext().getSessionTokenDao().findById(authParam);
+ SessionToken sessionToken = getPersistenceContext().getSessionTokenDao().findByTopiaId(authParam);
if (sessionToken == null) {
throw new InvalidSessionTokenException();
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,13 +27,12 @@
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
-import org.chorem.pollen.persistence.dao.ChoiceJpaDao;
import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.ChoiceTopiaDao;
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidChoiceFormException;
-import org.nuiton.jpa.api.JpaEntities;
import java.util.List;
import java.util.Set;
@@ -44,7 +43,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class ChoiceService extends AbstractPollenService {
+public class ChoiceService extends PollenServiceSupport {
public List<Choice> getChoices(String pollId) throws EntityNotFoundException {
Preconditions.checkNotNull(pollId);
@@ -76,7 +75,7 @@
Choice result = saveChoice(poll, choice);
- getPersistenceContext().getPollDao().merge(poll);
+ getPersistenceContext().getPollDao().update(poll);
getPersistenceContext().commit();
//TODO Notify Choice added
return result;
@@ -85,7 +84,7 @@
public Choice editChoice(String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
Preconditions.checkNotNull(choice);
checkHasId(choice);
- checkPermission(PermissionVerb.editChoice, choice.getId());
+ checkPermission(PermissionVerb.editChoice, choice.getTopiaId());
Poll poll = getPollService().getPoll(pollId);
@@ -93,7 +92,7 @@
Choice result = saveChoice(poll, choice);
- getPersistenceContext().getChoiceDao().merge(choice);
+ getPersistenceContext().getChoiceDao().update(choice);
getPersistenceContext().commit();
//TODO Notify Choice edited
return result;
@@ -109,14 +108,14 @@
poll.removeChoice(choice);
- getPersistenceContext().getPollDao().merge(poll);
+ getPersistenceContext().getPollDao().update(poll);
getPersistenceContext().commit();
//TODO Notify Choice deleted
}
protected Choice getChoice(Poll poll, String choiceId) throws EntityNotFoundException {
- Choice result = poll.getChoiceById(choiceId);
+ Choice result = poll.getChoiceByTopiaId(choiceId);
checkEntityExists(Choice.class, result, choiceId);
return result;
}
@@ -124,16 +123,16 @@
protected Choice saveChoice(Poll poll,
Choice choice) throws EntityNotFoundException {
- ChoiceJpaDao choiceDao = getPersistenceContext().getChoiceDao();
+ ChoiceTopiaDao choiceDao = getPersistenceContext().getChoiceDao();
- boolean choiceExists = JpaEntities.isEntityHasId(choice);
+ boolean choiceExists = choice.isPersisted();
Choice choiceToPersist;
if (choiceExists) {
// get existing choice
- choiceToPersist = getChoice(poll, choice.getId());
+ choiceToPersist = getChoice(poll, choice.getTopiaId());
} else {
// create a new choice
@@ -175,7 +174,7 @@
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
- boolean choiceExists = JpaEntities.isEntityHasId(choice);
+ boolean choiceExists = choice.isPersisted();
Set<String> choiceNames = Sets.newHashSet();
@@ -186,7 +185,7 @@
for (Choice member : poll.getChoice()) {
if (choiceExists &&
- member.getId().equals(choice.getId())) {
+ member.getTopiaId().equals(choice.getTopiaId())) {
continue;
}
choiceNames.add(member.getName());
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -42,7 +42,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class CommentService extends AbstractPollenService {
+public class CommentService extends PollenServiceSupport {
public List<Comment> getComments(String pollId) throws EntityNotFoundException {
Preconditions.checkNotNull(pollId);
@@ -71,7 +71,7 @@
Comment result = saveComment(poll, comment);
- getPersistenceContext().getPollDao().merge(poll);
+ getPersistenceContext().getPollDao().update(poll);
getPersistenceContext().commit();
return result;
}
@@ -81,14 +81,14 @@
Preconditions.checkNotNull(comment);
checkHasId(comment);
- checkPermission(PermissionVerb.editComment, comment.getId());
+ checkPermission(PermissionVerb.editComment, comment.getTopiaId());
Poll poll = getPollService().getPoll(pollId);
checkCommentForm(poll, comment);
Comment result = saveComment(poll, comment);
- getPersistenceContext().getCommentDao().merge(comment);
+ getPersistenceContext().getCommentDao().update(comment);
getPersistenceContext().commit();
return result;
}
@@ -105,13 +105,13 @@
poll.removeComment(comment);
- getPersistenceContext().getPollDao().merge(poll);
+ getPersistenceContext().getPollDao().update(poll);
getPersistenceContext().commit();
}
protected Comment getComment(Poll poll, String commentId) throws EntityNotFoundException {
- Comment result = poll.getCommentById(commentId);
+ Comment result = poll.getCommentByTopiaId(commentId);
checkEntityExists(Comment.class, result, commentId);
return result;
}
@@ -135,13 +135,13 @@
protected Comment saveComment(Poll poll, Comment comment) throws EntityNotFoundException {
- boolean commentExists = JpaEntities.isEntityHasId(comment);
+ boolean commentExists = comment.isPersisted();
Comment toSave;
if (commentExists) {
- toSave = getComment(poll, comment.getId());
+ toSave = getComment(poll, comment.getTopiaId());
} else {
toSave = getPersistenceContext().getCommentDao().newInstance();
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -37,7 +37,6 @@
import org.chorem.pollen.services.exception.FavoriteListImportException;
import org.chorem.pollen.services.exception.InvalidFavoriteListFormException;
import org.chorem.pollen.services.exception.InvalidFavoriteListMemberFormException;
-import org.nuiton.jpa.api.JpaEntities;
import org.nuiton.util.StringUtil;
import javax.naming.NamingEnumeration;
@@ -57,7 +56,7 @@
import java.util.Properties;
import java.util.Set;
-import static org.nuiton.i18n.I18n.l_;
+import static org.nuiton.i18n.I18n.l;
/**
* TODO
@@ -65,7 +64,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class FavoriteListService extends AbstractPollenService {
+public class FavoriteListService extends PollenServiceSupport {
public List<FavoriteList> getFavoriteLists(String userId) throws EntityNotFoundException {
Preconditions.checkNotNull(userId);
@@ -99,7 +98,7 @@
copyFavoriteList(favoriteList, toSave);
user.addFavoriteList(toSave);
- getPersistenceContext().getPollenUserDao().merge(user);
+ getPersistenceContext().getPollenUserDao().update(user);
getPersistenceContext().commit();
return toSave;
@@ -114,14 +113,14 @@
PollenUser user = getUserService().getUser(userId);
// get list to save
- FavoriteList toSave = getFavoriteList(user, favoriteList.getId());
+ FavoriteList toSave = getFavoriteList(user, favoriteList.getTopiaId());
checkFavoriteListForm(user, favoriteList);
copyFavoriteList(favoriteList, toSave);
- getPersistenceContext().getFavoriteListDao().merge(toSave);
+ getPersistenceContext().getFavoriteListDao().update(toSave);
getPersistenceContext().commit();
return toSave;
}
@@ -136,7 +135,7 @@
user.removeFavoriteList(persisted);
- getPersistenceContext().getPollenUserDao().merge(user);
+ getPersistenceContext().getPollenUserDao().update(user);
getPersistenceContext().commit();
}
@@ -183,7 +182,7 @@
copyFavoriteListMember(member, newMember);
favoriteList.addFavoriteListMember(newMember);
- getPersistenceContext().getFavoriteListDao().merge(favoriteList);
+ getPersistenceContext().getFavoriteListDao().update(favoriteList);
getPersistenceContext().commit();
return newMember;
@@ -202,7 +201,7 @@
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
- String memberId = member.getId();
+ String memberId = member.getTopiaId();
FavoriteListMember toSave = getFavoriteListMember(favoriteList, memberId);
@@ -210,7 +209,7 @@
copyFavoriteListMember(member, toSave);
- getPersistenceContext().getFavoriteListMemberDao().merge(toSave);
+ getPersistenceContext().getFavoriteListMemberDao().update(toSave);
getPersistenceContext().commit();
return toSave;
@@ -231,7 +230,7 @@
favoriteList.removeFavoriteListMember(member);
- getPersistenceContext().getFavoriteListDao().merge(favoriteList);
+ getPersistenceContext().getFavoriteListDao().update(favoriteList);
getPersistenceContext().commit();
}
@@ -290,21 +289,21 @@
if (!usedName.add(memberName)) {
// name already exists
- String error = l_(locale, "pollen.error.favoriteList.import.csv.already.used.name", lineNumber, memberName);
+ String error = l(locale, "pollen.error.favoriteList.import.csv.already.used.name", lineNumber, memberName);
throw new FavoriteListImportException(error, null);
}
email = email.toLowerCase().trim();
if (!usedEmail.add(email)) {
// email already exists
- String error = l_(locale, "pollen.error.favoriteList.import.csv.already.used.email", lineNumber, email);
+ String error = l(locale, "pollen.error.favoriteList.import.csv.already.used.email", lineNumber, email);
throw new FavoriteListImportException(error, null);
}
if (!StringUtil.isEmail(email)) {
// email is not valid
- String error = l_(locale, "pollen.error.favoriteList.import.csv.invalid.email", lineNumber, email);
+ String error = l(locale, "pollen.error.favoriteList.import.csv.invalid.email", lineNumber, email);
throw new FavoriteListImportException(error, null);
}
@@ -327,7 +326,7 @@
IOUtils.closeQuietly(reader);
}
- getPersistenceContext().getFavoriteListDao().merge(favoriteList);
+ getPersistenceContext().getFavoriteListDao().update(favoriteList);
getPersistenceContext().commit();
@@ -385,7 +384,7 @@
if (!usedName.add(memberName)) {
// name already exists
- String error = l_(locale, "pollen.error.favoriteList.import.ldap.already.used.name", memberName);
+ String error = l(locale, "pollen.error.favoriteList.import.ldap.already.used.name", memberName);
throw new FavoriteListImportException(error, null);
}
@@ -393,14 +392,14 @@
if (!usedEmail.add(email)) {
// email already exists
- String error = l_(locale, "pollen.error.favoriteList.import.ldap.already.used.email", email);
+ String error = l(locale, "pollen.error.favoriteList.import.ldap.already.used.email", email);
throw new FavoriteListImportException(error, null);
}
if (!StringUtil.isEmail(email)) {
// email is not valid
- String error = l_(locale, "pollen.error.favoriteList.import.ldap.invalid.email", email);
+ String error = l(locale, "pollen.error.favoriteList.import.ldap.invalid.email", email);
throw new FavoriteListImportException(error, null);
}
@@ -415,7 +414,7 @@
throw new FavoriteListImportException("LDAP", ex);
}
- getPersistenceContext().getFavoriteListDao().merge(favoriteList);
+ getPersistenceContext().getFavoriteListDao().update(favoriteList);
getPersistenceContext().commit();
return result;
@@ -424,7 +423,7 @@
protected FavoriteList getFavoriteList(PollenUser user, String favoriteListId) throws EntityNotFoundException {
Preconditions.checkNotNull(favoriteListId);
- FavoriteList result = user.getFavoriteListById(favoriteListId);
+ FavoriteList result = user.getFavoriteListByTopiaId(favoriteListId);
checkEntityExists(FavoriteList.class, result, favoriteListId);
return result;
@@ -432,7 +431,7 @@
protected FavoriteListMember getFavoriteListMember(FavoriteList favoriteList, String memberId) throws EntityNotFoundException {
- FavoriteListMember result = favoriteList.getFavoriteListMemberById(memberId);
+ FavoriteListMember result = favoriteList.getFavoriteListMemberByTopiaId(memberId);
checkEntityExists(FavoriteListMember.class, result, memberId);
return result;
}
@@ -517,7 +516,7 @@
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
- boolean voterListMemberExists = JpaEntities.isEntityHasId(favoriteListMember);
+ boolean voterListMemberExists = favoriteListMember.isPersisted();
Set<String> memberNames = Sets.newHashSet();
Set<String> memberEmails = Sets.newHashSet();
@@ -528,7 +527,7 @@
for (FavoriteListMember member : favoriteList.getFavoriteListMember()) {
- if (voterListMemberExists && member.getId().equals(member.getId())) {
+ if (voterListMemberExists && member.getTopiaId().equals(member.getTopiaId())) {
continue;
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,15 +27,17 @@
import com.google.common.collect.Maps;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.persistence.PollenPersistenceContext;
-import org.chorem.pollen.persistence.dao.PollenUserJpaDao;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.PollenUserTopiaDao;
import org.chorem.pollen.services.PollenFixtures;
+import javax.persistence.EntityManager;
+import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Map;
-public class FixturesService extends AbstractPollenService {
+public class FixturesService extends PollenServiceSupport {
private static final Log log = LogFactory.getLog(FixturesService.class);
@@ -71,22 +73,23 @@
log.info("will restore database with fixture set");
}
- PollenPersistenceContext persistenceContext = serviceContext.getPersistenceContext();
+ PollenTopiaPersistenceContext persistenceContext = serviceContext.getPersistenceContext();
if (cleanDatabase) {
- persistenceContext.clearDatabase();
+ //FIXME
+ //persistenceContext.clearDatabase();
}
- PollenUserJpaDao userDao = persistenceContext.getPollenUserDao();
+ PollenUserTopiaDao userDao = persistenceContext.getPollenUserDao();
Collection<PollenUser> users = fixtures.fixture("users");
for (PollenUser user : users) {
user.setPassword(serviceContext.encodePassword(user.getPassword()));
- userDao.persist(user);
+ userDao.create(user);
}
persistenceContext.commit();
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -29,17 +29,17 @@
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils;
-import org.chorem.pollen.persistence.dao.PollJpaDao;
import org.chorem.pollen.persistence.entity.Choice;
import org.chorem.pollen.persistence.entity.ChoiceType;
import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.PollTopiaDao;
import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.Polls;
import org.chorem.pollen.persistence.entity.VoterList;
import org.chorem.pollen.persistence.entity.VoterListMember;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollFormException;
-import org.nuiton.jpa.api.JpaEntities;
import java.io.File;
import java.util.Set;
@@ -50,7 +50,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class PollService extends AbstractPollenService {
+public class PollService extends PollenServiceSupport {
public Set<Poll> getPolls(String userId) throws EntityNotFoundException {
return Sets.newHashSet(getPersistenceContext().getPollDao().findAll());
@@ -83,7 +83,7 @@
public Poll getPoll(String pollId) throws EntityNotFoundException {
Preconditions.checkNotNull(pollId);
checkPermission(PermissionVerb.readPoll, pollId);
- Poll result = getPersistenceContext().getPollDao().findById(pollId);
+ Poll result = getPersistenceContext().getPollDao().findByTopiaId(pollId);
checkEntityExists(Poll.class, result, pollId);
return result;
}
@@ -128,7 +128,7 @@
Poll pollToPersist = savePoll(userId, poll);
- getPersistenceContext().getPollDao().persist(pollToPersist);
+ getPersistenceContext().getPollDao().create(pollToPersist);
getPersistenceContext().commit();
return pollToPersist;
}
@@ -137,13 +137,13 @@
Preconditions.checkNotNull(poll);
checkHasId(poll);
- checkPermission(PermissionVerb.editPoll, poll.getId());
+ checkPermission(PermissionVerb.editPoll, poll.getTopiaId());
checkPollForm(poll);
Poll toSave = savePoll(null, poll);
- getPersistenceContext().getPollDao().merge(toSave);
+ getPersistenceContext().getPollDao().update(toSave);
getPersistenceContext().commit();
return toSave;
@@ -157,7 +157,7 @@
Poll poll = getPoll(pollId);
- getPersistenceContext().getPollDao().remove(poll);
+ getPersistenceContext().getPollDao().delete(poll);
getPersistenceContext().commit();
if (poll.getCreator().getEmail() != null) {
@@ -197,15 +197,15 @@
protected Poll savePoll(String userId, Poll poll) throws EntityNotFoundException {
- boolean pollExists = JpaEntities.isEntityHasId(poll);
+ boolean pollExists = poll.isPersisted();
Poll toSave;
if (pollExists) {
- toSave = getPoll(poll.getId());
+ toSave = getPoll(poll.getTopiaId());
} else {
- PollJpaDao dao = getPersistenceContext().getPollDao();
+ PollTopiaDao dao = getPersistenceContext().getPollDao();
toSave = dao.newInstance();
@@ -281,11 +281,11 @@
checkNotBlank(errors, "title", poll.getTitle(), "title can not be empty");
checkNotEmpty(errors, "choice", poll.getChoice(), "need at least one choice");
- if (poll.isFreePoll()) {
+ if (Polls.isPollFree(poll)) {
checkEmpty(errors, "voterList", poll.getVoterList(), "can't have voterList with free poll");
- } else if (poll.isRestrictedPoll()) {
+ } else if (Polls.isPollRestricted(poll)) {
check(errors, "voterList", 1 == poll.sizeVoterList(), "must have a unique voterList with a resitricted poll");
- } else if (poll.isGroupPoll()) {
+ } else if (Polls.isPollGroup(poll)) {
checkNotEmpty(errors, "voterList", poll.getVoterList(), "must have at least one voterList with a group poll");
}
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java (from rev 3875, trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AbstractPollenService.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -0,0 +1,188 @@
+package org.chorem.pollen.services.service;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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 com.google.common.base.Preconditions;
+import com.google.common.collect.Multimap;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.services.PollenService;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.exception.EntityNotFoundException;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.StringUtil;
+
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public abstract class PollenServiceSupport implements PollenService {
+
+ // -- PollenServiceSupport -- //
+
+ protected PollenServiceContext serviceContext;
+
+ public String createPermission(PermissionVerb verb, String id) {
+ return ":" + verb.name() + ":" + id;
+ }
+
+ @Override
+ public void setServiceContext(PollenServiceContext serviceContext) {
+ this.serviceContext = serviceContext;
+ }
+
+ // -- Delegate serviceContext -- //
+
+ protected Date getNow() {
+ return serviceContext.getNow();
+ }
+
+ protected String generateToken() {
+ return serviceContext.generateToken();
+ }
+
+ protected String getCleanMail(String email) {
+ return serviceContext.getCleanMail(email);
+ }
+
+ protected PollenTopiaPersistenceContext getPersistenceContext() {
+ return serviceContext.getPersistenceContext();
+ }
+
+ protected PollenServiceConfig getPollenServiceConfig() {
+ return serviceContext.getPollenServiceConfig();
+ }
+
+ protected AuthService getAuthService() {
+ return newService(AuthService.class);
+ }
+
+ public ChoiceService getChoiceService() {
+ return newService(ChoiceService.class);
+ }
+
+ protected CommentService getCommentService() {
+ return newService(CommentService.class);
+ }
+
+ protected FavoriteListService getFavoriteListService() {
+ return newService(FavoriteListService.class);
+ }
+
+ protected PollService getPollService() {
+ return newService(PollService.class);
+ }
+
+ protected SecurityService getSecurityService() {
+ return newService(SecurityService.class);
+ }
+
+ protected PollenUserService getUserService() {
+ return newService(PollenUserService.class);
+ }
+
+ protected VoteCountingService getVoteCountingService() {
+ return newService(VoteCountingService.class);
+ }
+
+ protected VoterListService getVoterListService() {
+ return newService(VoterListService.class);
+ }
+
+ protected VoteService getVoteService() {
+ return newService(VoteService.class);
+ }
+
+ protected <E extends PollenService> E newService(Class<E> serviceClass) {
+ return serviceContext.newService(serviceClass);
+ }
+
+ // -- check method -- //
+
+ protected void checkPermission(PermissionVerb verb, String id) {
+ String permission = createPermission(verb, id);
+// serviceContext.getSecurityContext().getSubject().checkPermission(permission);
+ }
+
+ protected void checkHasId(TopiaEntity entity) {
+ Preconditions.checkState(entity.isPersisted());
+ }
+
+ protected void checkHasNoId(TopiaEntity entity) {
+ Preconditions.checkState(!entity.isPersisted());
+ }
+
+ protected <E extends TopiaEntity> void checkEntityExists(Class<E> type,
+ E entity,
+ String entityId) throws EntityNotFoundException {
+ if (entity == null) {
+ throw new EntityNotFoundException(type, entityId);
+ }
+ }
+
+ protected boolean check(Multimap<String, String> errors, String field, boolean condition, String error) {
+ boolean valid = condition;
+ if (!valid) {
+ errors.put(field, error);
+ }
+ return valid;
+ }
+
+ protected boolean checkNot(Multimap<String, String> errors, String field, boolean condition, String error) {
+ boolean valid = check(errors, field, !condition, error);
+ return valid;
+ }
+
+ protected boolean checkNotNull(Multimap<String, String> errors, String field, Object value, String error) {
+ boolean valid = check(errors, field, value != null, error);
+ return valid;
+ }
+
+ protected boolean checkEmpty(Multimap<String, String> errors, String field, Collection<?> value, String error) {
+ boolean valid = check(errors, field, CollectionUtils.isEmpty(value), error);
+ return valid;
+ }
+
+ protected boolean checkNotEmpty(Multimap<String, String> errors, String field, Collection<?> value, String error) {
+ boolean valid = check(errors, field, CollectionUtils.isNotEmpty(value), error);
+ return valid;
+ }
+
+ protected boolean checkNotBlank(Multimap<String, String> errors, String field, String value, String error) {
+ boolean valid = check(errors, field, StringUtils.isNotBlank(value), error);
+ return valid;
+ }
+
+ protected boolean checkValidEmail(Multimap<String, String> errors, String field, String value, String error) {
+ boolean valid = check(errors, field, StringUtil.isEmail(value), error);
+ return valid;
+ }
+}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,14 +27,14 @@
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import org.apache.commons.lang3.ObjectUtils;
-import org.chorem.pollen.persistence.dao.PollenUserJpaDao;
import org.chorem.pollen.persistence.entity.PollenUser;
-import org.chorem.pollen.services.PollenServiceSupport;
+import org.chorem.pollen.persistence.entity.PollenUserTopiaDao;
+import org.chorem.pollen.services.PollenService;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
import org.chorem.pollen.services.exception.UserInvalidPasswordException;
-import org.nuiton.jpa.api.JpaEntities;
+import org.nuiton.topia.persistence.TopiaNoResultException;
import java.util.List;
@@ -44,7 +44,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class PollenUserService extends AbstractPollenService implements PollenServiceSupport {
+public class PollenUserService extends PollenServiceSupport implements PollenService {
public List<PollenUser> getUsers() {
return getPersistenceContext().getPollenUserDao().findAll();
@@ -53,17 +53,22 @@
public PollenUser getUser(String userId) throws EntityNotFoundException {
Preconditions.checkNotNull(userId);
- PollenUser result = getPersistenceContext().getPollenUserDao().findById(userId);
- checkEntityExists(PollenUser.class, result, userId);
- return result;
+ try {
+ PollenUser result = getPersistenceContext().getPollenUserDao().findByTopiaId(userId);
+ return result;
+ } catch (TopiaNoResultException e) {
+ throw new EntityNotFoundException(PollenUser.class, userId);
+ }
}
public PollenUser getUserByLogin(String login) throws EntityNotFoundException {
Preconditions.checkNotNull(login);
-
- PollenUser result = getPersistenceContext().getPollenUserDao().findByLogin(login);
- checkEntityExists(PollenUser.class, result, login);
- return result;
+ try {
+ PollenUser result = getPersistenceContext().getPollenUserDao().forLoginEquals(login).findAny();
+ return result;
+ } catch (TopiaNoResultException e) {
+ throw new EntityNotFoundException(PollenUser.class, login);
+ }
}
public PollenUser createUser(PollenUser user, boolean generatePassword) throws InvalidPollenUserFormException, EntityNotFoundException {
@@ -73,7 +78,7 @@
PollenUser result = savePollenUser(user, generatePassword);
- getPersistenceContext().getPollenUserDao().persist(result);
+ getPersistenceContext().getPollenUserDao().create(result);
getPersistenceContext().commit();
//TODO Notify user created
return result;
@@ -86,7 +91,7 @@
PollenUser result = savePollenUser(user, false);
- getPersistenceContext().getPollenUserDao().merge(result);
+ getPersistenceContext().getPollenUserDao().update(result);
getPersistenceContext().commit();
//TODO Notify user edited
return result;
@@ -111,7 +116,7 @@
String newEncodedPassword = serviceContext.encodePassword(newPassword);
user.setPassword(newEncodedPassword);
- getPersistenceContext().getPollenUserDao().merge(user);
+ getPersistenceContext().getPollenUserDao().update(user);
getPersistenceContext().commit();
//TODO Notify PasswordChanged
}
@@ -134,7 +139,7 @@
// reset token in database
user.setEmailActivationToken(null);
- getPersistenceContext().getPollenUserDao().merge(user);
+ getPersistenceContext().getPollenUserDao().update(user);
getPersistenceContext().commit();
}
@@ -155,9 +160,9 @@
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
- boolean userExists = JpaEntities.isEntityHasId(user);
- PollenUser persisted = userExists ? getUser(user.getId()) : null;
- PollenUserJpaDao dao = getPersistenceContext().getPollenUserDao();
+ boolean userExists = user.isPersisted();
+ PollenUser persisted = userExists ? getUser(user.getTopiaId()) : null;
+ PollenUserTopiaDao dao = getPersistenceContext().getPollenUserDao();
String userLogin = user.getLogin();
String userEmail = getCleanMail(user.getEmail());
@@ -205,7 +210,7 @@
protected PollenUser savePollenUser(PollenUser user,
boolean generatePassword) throws EntityNotFoundException {
- boolean userExists = JpaEntities.isEntityHasId(user);
+ boolean userExists = user.isPersisted();
PollenUser toSave;
@@ -215,7 +220,7 @@
if (userExists) {
- toSave = getUser(user.getId());
+ toSave = getUser(user.getTopiaId());
boolean emailChanged = ObjectUtils.notEqual(toSave.getEmail(),
userEmail);
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,20 +27,21 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.shiro.subject.Subject;
-import org.chorem.pollen.persistence.dao.ChoiceJpaDao;
-import org.chorem.pollen.persistence.dao.CommentJpaDao;
-import org.chorem.pollen.persistence.dao.PollJpaDao;
-import org.chorem.pollen.persistence.dao.PollenPrincipalJpaDao;
-import org.chorem.pollen.persistence.dao.VoteJpaDao;
import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.ChoiceTopiaDao;
import org.chorem.pollen.persistence.entity.Comment;
+import org.chorem.pollen.persistence.entity.CommentTopiaDao;
import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.PollTopiaDao;
import org.chorem.pollen.persistence.entity.PollenPrincipal;
+import org.chorem.pollen.persistence.entity.PollenPrincipalTopiaDao;
import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.Polls;
import org.chorem.pollen.persistence.entity.Vote;
+import org.chorem.pollen.persistence.entity.VoteTopiaDao;
import org.chorem.pollen.persistence.entity.VoterListMember;
import org.chorem.pollen.services.PollenSecurityContext;
-import org.nuiton.jpa.api.JpaEntity;
+import org.nuiton.topia.persistence.TopiaEntity;
import java.util.Date;
import java.util.List;
@@ -53,19 +54,19 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class SecurityService extends AbstractPollenService {
+public class SecurityService extends PollenServiceSupport {
public PollenPrincipal generatePrincipal() {
- PollenPrincipalJpaDao pollenPrincipalDao = getPersistenceContext().getPollenPrincipalDao();
+ PollenPrincipalTopiaDao pollenPrincipalDao = getPersistenceContext().getPollenPrincipalDao();
PollenPrincipal principal = pollenPrincipalDao.newInstance();
principal.setCreationDate(serviceContext.getNow());
- pollenPrincipalDao.persist(principal);
+ pollenPrincipalDao.create(principal);
return principal;
}
- public void prepareSubject(JpaEntity entity) {
+ public void prepareSubject(TopiaEntity entity) {
Preconditions.checkNotNull(entity);
- prepareSubject(entity.getId());
+ prepareSubject(entity.getTopiaId());
}
public void prepareSubject(String principalId) {
@@ -88,12 +89,12 @@
Set<PollenPrincipal> principals = Sets.newHashSet();
- PollenPrincipalJpaDao pollenPrincipalDao =
+ PollenPrincipalTopiaDao pollenPrincipalDao =
getPersistenceContext().getPollenPrincipalDao();
if (principalId != null) {
PollenPrincipal pollenPrincipal =
- pollenPrincipalDao.findById(principalId);
+ pollenPrincipalDao.findByTopiaId(principalId);
principals.add(pollenPrincipal);
}
@@ -105,13 +106,13 @@
principals.addAll(allByPollenUser);
}
- Map<PollenPrincipal, JpaEntity> principalJpaEntityMap = Maps.newHashMap();
+ Map<PollenPrincipal, TopiaEntity> principalTopiaEntityMap = Maps.newHashMap();
for (PollenPrincipal principal : principals) {
// find out which entity is using this principal
- JpaEntity entity = getPrincipalEntity(principal);
- principalJpaEntityMap.put(principal, entity);
+ TopiaEntity entity = getPrincipalEntity(principal);
+ principalTopiaEntityMap.put(principal, entity);
if (entity instanceof Poll) {
@@ -120,27 +121,27 @@
if (!poll.isChoiceEmpty()) {
for (Choice choice : poll.getChoice()) {
- principalJpaEntityMap.put(choice.getCreator(), choice);
+ principalTopiaEntityMap.put(choice.getCreator(), choice);
}
}
if (!poll.isCommentEmpty()) {
for (Comment comment : poll.getComment()) {
- principalJpaEntityMap.put(comment.getAuthor(), comment);
+ principalTopiaEntityMap.put(comment.getAuthor(), comment);
}
}
if (!poll.isVoteEmpty()) {
for (Vote vote : poll.getVote()) {
- principalJpaEntityMap.put(vote.getVoter(), vote);
+ principalTopiaEntityMap.put(vote.getVoter(), vote);
}
}
}
}
Date now = serviceContext.getNow();
- for (Map.Entry<PollenPrincipal, JpaEntity> entry : principalJpaEntityMap.entrySet()) {
- JpaEntity entity = entry.getValue();
+ for (Map.Entry<PollenPrincipal, TopiaEntity> entry : principalTopiaEntityMap.entrySet()) {
+ TopiaEntity entity = entry.getValue();
if (entity instanceof Choice) {
permissions.add(createWildcardSubjectPermission(entity));
@@ -159,9 +160,9 @@
Poll poll = (Poll) entity;
- Set<VoterListMember> members = poll.getAllVoters();
+ Set<VoterListMember> members = Polls.getAllVoters(poll);
- boolean freePoll = poll.isFreePoll();
+ boolean freePoll = Polls.isPollFree(poll);
if (freePoll) {
@@ -172,14 +173,14 @@
// only his creator / participants / voters can read it
for (VoterListMember member : members) {
- permissions.add(createSubjectPermission(member.getId(), PermissionVerb.readPoll, entity));
+ permissions.add(createSubjectPermission(member.getTopiaId(), PermissionVerb.readPoll, entity));
}
}
// add editVote / deleteVote for any voter
if (!poll.isVoteEmpty()) {
for (Vote vote : poll.getVote()) {
- String id = vote.getVoter().getId();
+ String id = vote.getVoter().getTopiaId();
permissions.add(createSubjectPermission(id, PermissionVerb.editVote, vote));
permissions.add(createSubjectPermission(id, PermissionVerb.deleteVote, vote));
}
@@ -212,9 +213,9 @@
return null;
}
- protected JpaEntity getPrincipalEntity(PollenPrincipal principal) {
+ protected TopiaEntity getPrincipalEntity(PollenPrincipal principal) {
- JpaEntity result = null;
+ TopiaEntity result = null;
// try a poll
Poll poll = getPollDao().findByCreator(principal);
@@ -247,51 +248,51 @@
return result;
}
- protected CommentJpaDao commentDao;
+ protected CommentTopiaDao commentDao;
- protected VoteJpaDao voteDao;
+ protected VoteTopiaDao voteDao;
- protected ChoiceJpaDao choiceDao;
+ protected ChoiceTopiaDao choiceDao;
- protected PollJpaDao pollDao;
+ protected PollTopiaDao pollDao;
- protected CommentJpaDao getCommentDao() {
+ protected CommentTopiaDao getCommentDao() {
if (commentDao == null) {
commentDao = getPersistenceContext().getCommentDao();
}
return commentDao;
}
- protected VoteJpaDao getVoteDao() {
+ protected VoteTopiaDao getVoteDao() {
if (voteDao == null) {
voteDao = getPersistenceContext().getVoteDao();
}
return voteDao;
}
- protected ChoiceJpaDao getChoiceDao() {
+ protected ChoiceTopiaDao getChoiceDao() {
if (choiceDao == null) {
choiceDao = getPersistenceContext().getChoiceDao();
}
return choiceDao;
}
- protected PollJpaDao getPollDao() {
+ protected PollTopiaDao getPollDao() {
if (pollDao == null) {
pollDao = getPersistenceContext().getPollDao();
}
return pollDao;
}
- protected String createSubjectPermission(String people, PermissionVerb verb, JpaEntity entity) {
- return people + ":" + verb.name() + ":" + entity.getId();
+ protected String createSubjectPermission(String people, PermissionVerb verb, TopiaEntity entity) {
+ return people + ":" + verb.name() + ":" + entity.getTopiaId();
}
- protected String createSubjectPermission(PermissionVerb verb, JpaEntity entity) {
+ protected String createSubjectPermission(PermissionVerb verb, TopiaEntity entity) {
return createSubjectPermission("*", verb, entity);
}
- protected String createWildcardSubjectPermission(JpaEntity entity) {
- return "*:*:" + entity.getId();
+ protected String createWildcardSubjectPermission(TopiaEntity entity) {
+ return "*:*:" + entity.getTopiaId();
}
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -34,7 +34,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class VoteCountingService extends AbstractPollenService {
+public class VoteCountingService extends PollenServiceSupport {
//GET /poll/{pollId}/results
public PollResult getResult(String pollId) throws EntityNotFoundException {
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,10 +27,10 @@
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.Polls;
import org.chorem.pollen.persistence.entity.Vote;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidVoteFormException;
-import org.nuiton.jpa.api.JpaEntities;
import java.util.Date;
import java.util.List;
@@ -41,7 +41,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class VoteService extends AbstractPollenService {
+public class VoteService extends PollenServiceSupport {
public List<Vote> getVotes(String pollId) throws EntityNotFoundException {
Preconditions.checkNotNull(pollId);
@@ -73,7 +73,7 @@
Vote result = saveVote(poll, vote);
- getPersistenceContext().getPollDao().merge(poll);
+ getPersistenceContext().getPollDao().update(poll);
getPersistenceContext().commit();
//TODO Notify vote added
return result;
@@ -82,14 +82,14 @@
public Vote editVote(String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
Preconditions.checkNotNull(vote);
checkHasId(vote);
- checkPermission(PermissionVerb.editVote, vote.getId());
+ checkPermission(PermissionVerb.editVote, vote.getTopiaId());
Poll poll = getPollService().getPoll(pollId);
checkVoteForm(poll, vote);
Vote result = saveVote(poll, vote);
- getPersistenceContext().getVoteDao().merge(vote);
+ getPersistenceContext().getVoteDao().update(vote);
getPersistenceContext().commit();
//TODO Notify vote edited
return result;
@@ -107,7 +107,7 @@
poll.removeVote(vote);
- getPersistenceContext().getPollDao().merge(poll);
+ getPersistenceContext().getPollDao().update(poll);
getPersistenceContext().commit();
//TODO Notify vote deleted
}
@@ -123,7 +123,7 @@
Date now = serviceContext.getNow();
// poll must be started
- check(errors, "poll", poll.isStarted(now), "poll is not stardted");
+ check(errors, "poll", Polls.isStarted(poll, now), "poll is not stardted");
checkNotBlank(errors, "voter.name", vote.getVoter().getName(), "voter name can not be empty");
@@ -137,14 +137,14 @@
protected Vote saveVote(Poll poll, Vote vote) throws EntityNotFoundException {
- boolean commentExists = JpaEntities.isEntityHasId(vote);
+ boolean commentExists = vote.isPersisted();
Vote toSave;
//TODO Finish save
if (commentExists) {
- toSave = getVote(poll, vote.getId());
+ toSave = getVote(poll, vote.getTopiaId());
} else {
toSave = getPersistenceContext().getVoteDao().newInstance();
@@ -173,7 +173,7 @@
protected Vote getVote(Poll poll, String voteId) throws EntityNotFoundException {
Preconditions.checkNotNull(voteId);
- Vote result = poll.getVoteById(voteId);
+ Vote result = poll.getVoteByTopiaId(voteId);
checkEntityExists(Vote.class, result, voteId);
return result;
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -28,17 +28,16 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
-import org.chorem.pollen.persistence.dao.VoterListJpaDao;
-import org.chorem.pollen.persistence.dao.VoterListMemberJpaDao;
import org.chorem.pollen.persistence.entity.FavoriteList;
import org.chorem.pollen.persistence.entity.FavoriteListMember;
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.VoterList;
import org.chorem.pollen.persistence.entity.VoterListMember;
+import org.chorem.pollen.persistence.entity.VoterListMemberTopiaDao;
+import org.chorem.pollen.persistence.entity.VoterListTopiaDao;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidVoterListFormException;
import org.chorem.pollen.services.exception.InvalidVoterListMemberFormException;
-import org.nuiton.jpa.api.JpaEntities;
import java.util.List;
import java.util.Set;
@@ -49,7 +48,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class VoterListService extends AbstractPollenService {
+public class VoterListService extends PollenServiceSupport {
public VoterList importFavoriteList(String userId, String pollId,
String favoriteListId) throws EntityNotFoundException {
@@ -60,13 +59,13 @@
FavoriteList favoriteList = getFavoriteListService().getFavoriteList(userId, favoriteListId);
- VoterListJpaDao dao = getPersistenceContext().getVoterListDao();
+ VoterListTopiaDao dao = getPersistenceContext().getVoterListDao();
VoterList result = dao.newInstance();
result.setName(favoriteList.getName());
result.setWeight(1d);
- VoterListMemberJpaDao voterListMemberDao =
+ VoterListMemberTopiaDao voterListMemberDao =
getPersistenceContext().getVoterListMemberDao();
for (FavoriteListMember favoriteListMember : favoriteList.getFavoriteListMember()) {
@@ -79,7 +78,7 @@
poll.addVoterList(result);
- getPersistenceContext().getPollDao().merge(poll);
+ getPersistenceContext().getPollDao().update(poll);
getPersistenceContext().commit();
return result;
}
@@ -113,7 +112,7 @@
VoterList result = saveVoterList(poll, voterList);
- getPersistenceContext().getPollDao().merge(poll);
+ getPersistenceContext().getPollDao().update(poll);
getPersistenceContext().commit();
return result;
}
@@ -128,7 +127,7 @@
VoterList result = saveVoterList(poll, voterList);
- getPersistenceContext().getVoterListDao().merge(voterList);
+ getPersistenceContext().getVoterListDao().update(voterList);
getPersistenceContext().commit();
return result;
}
@@ -143,7 +142,7 @@
poll.removeVoterList(voterList);
- getPersistenceContext().getPollDao().merge(poll);
+ getPersistenceContext().getPollDao().update(poll);
getPersistenceContext().commit();
}
@@ -181,7 +180,7 @@
VoterListMember result = saveVoterListMember(voterList, member);
- getPersistenceContext().getVoterListDao().merge(voterList);
+ getPersistenceContext().getVoterListDao().update(voterList);
getPersistenceContext().commit();
return result;
}
@@ -199,7 +198,7 @@
VoterListMember result = saveVoterListMember(voterList, member);
- getPersistenceContext().getVoterListMemberDao().merge(member);
+ getPersistenceContext().getVoterListMemberDao().update(member);
getPersistenceContext().commit();
return result;
}
@@ -214,14 +213,14 @@
VoterListMember member = getVoterListMember(voterList, memberId);
voterList.removeVoterListMember(member);
- getPersistenceContext().getVoterListDao().merge(voterList);
+// getPersistenceContext().getVoterListDao().merge(voterList);
getPersistenceContext().commit();
}
protected VoterList getVoterList(Poll poll, String voterListId) throws EntityNotFoundException {
- VoterList result = poll.getVoterListById(voterListId);
+ VoterList result = poll.getVoterListByTopiaId(voterListId);
checkEntityExists(VoterList.class, result, voterListId);
return result;
}
@@ -229,7 +228,7 @@
protected VoterListMember getVoterListMember(VoterList voterList, String memberId) throws EntityNotFoundException {
Preconditions.checkNotNull(memberId);
- VoterListMember result = voterList.getVoterListMemberById(memberId);
+ VoterListMember result = voterList.getVoterListMemberByTopiaId(memberId);
checkEntityExists(VoterListMember.class, result, memberId);
return result;
}
@@ -237,15 +236,15 @@
protected VoterList saveVoterList(Poll poll, VoterList voterList) throws EntityNotFoundException {
- boolean voterListExists = JpaEntities.isEntityHasId(voterList);
+ boolean voterListExists = voterList.isPersisted();
VoterList toSave;
if (voterListExists) {
- toSave = getVoterList(poll, voterList.getId());
+ toSave = getVoterList(poll, voterList.getTopiaId());
} else {
- VoterListJpaDao voterListDao =
+ VoterListTopiaDao voterListDao =
getPersistenceContext().getVoterListDao();
toSave = voterListDao.newInstance();
@@ -266,17 +265,16 @@
protected VoterListMember saveVoterListMember(VoterList voterList,
VoterListMember voterListMember) throws EntityNotFoundException {
- boolean voterListMemberExists =
- JpaEntities.isEntityHasId(voterListMember);
+ boolean voterListMemberExists = voterListMember.isPersisted();
VoterListMember toSave;
if (voterListMemberExists) {
- toSave = getVoterListMember(voterList, voterListMember.getId());
+ toSave = getVoterListMember(voterList, voterListMember.getTopiaId());
} else {
- VoterListMemberJpaDao voterListMemberDao =
+ VoterListMemberTopiaDao voterListMemberDao =
getPersistenceContext().getVoterListMemberDao();
toSave = voterListMemberDao.newInstance();
@@ -296,7 +294,7 @@
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
- boolean voterListExists = JpaEntities.isEntityHasId(voterList);
+ boolean voterListExists = voterList.isPersisted();
Set<String> voterListNames = Sets.newHashSet();
@@ -306,7 +304,7 @@
for (VoterList lists : poll.getVoterList()) {
- if (voterListExists && lists.getId().equals(voterList.getId())) {
+ if (voterListExists && lists.getTopiaId().equals(voterList.getTopiaId())) {
continue;
}
@@ -362,7 +360,7 @@
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
- boolean voterListMemberExists = JpaEntities.isEntityHasId(voterListMember);
+ boolean voterListMemberExists = voterListMember.isPersisted();
Set<String> voterListMemberNames = Sets.newHashSet();
Set<String> voterListMemberEmails = Sets.newHashSet();
@@ -373,7 +371,7 @@
for (VoterListMember member : voterList.getVoterListMember()) {
if (voterListMemberExists &&
- member.getId().equals(voterListMember.getId())) {
+ member.getTopiaId().equals(voterListMember.getTopiaId())) {
continue;
}
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -24,97 +24,185 @@
*/
import com.google.common.collect.Multimap;
-import org.chorem.pollen.persistence.JpaPollenPersistenceContext;
+import org.apache.commons.lang3.SystemUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.services.PollenFixtures;
-import org.chorem.pollen.services.PollenServiceSupport;
+import org.chorem.pollen.services.PollenService;
import org.chorem.pollen.services.config.PollenServiceConfig;
import org.chorem.pollen.services.exception.AbstractInvalidFormException;
import org.chorem.pollen.services.service.FixturesService;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.service.ServiceRegistry;
+import org.hibernate.service.internal.SessionFactoryServiceRegistryImpl;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.junit.After;
import org.junit.Assert;
-import org.junit.Rule;
-import org.nuiton.jpa.junit.JpaEntityManagerRule;
+import org.nuiton.util.DateUtil;
import javax.persistence.EntityManager;
+import java.io.File;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
+import java.util.UUID;
public abstract class AbstractPollenServiceTest {
+ private static final Log log = LogFactory.getLog(AbstractPollenServiceTest.class);
+
protected static final double DELTA = 0.0001;
- protected static PollenServiceConfig config;
+ protected static PollenServiceConfig applicationConfig;
- protected JpaEntityManagerRule jpaEntityManagerRule;
+ protected PollenTopiaApplicationContext applicationContext;
+ protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
+
protected FakePollenServiceContext serviceContext;
protected PollenFixtures fixtures;
- protected static PollenServiceConfig getPollenServiceConfig() {
+ @After
+ public void tearDown() {
- if (config == null) {
+ for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
- config = new PollenServiceConfig();
+ if (log.isTraceEnabled()) {
+ log.trace("closing transaction " + openedTransaction);
+ }
+
+ openedTransaction.closeContext();
+
}
- return config;
+ if (applicationContext != null) {
+ if (log.isTraceEnabled()) {
+ log.trace("closing transaction " + applicationContext);
+ }
+
+ applicationContext.closeContext();
+
+ }
+
}
- protected FakePollenServiceContext getServiceContext() {
+ protected PollenTopiaApplicationContext newApplicationContext(String dataBase) {
- if (serviceContext == null) {
+ Map<String, String> hibernateH2Config = new HashMap<>();
- synchronized (this) {
- serviceContext = new FakePollenServiceContext();
+ hibernateH2Config.putAll(getApplicationConfig().getTopiaProperties());
- serviceContext.setPollenServiceConfig(getPollenServiceConfig());
+ hibernateH2Config.put(Environment.DRIVER, org.h2.Driver.class.getName());
+ hibernateH2Config.put(Environment.DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
+ hibernateH2Config.put(Environment.USER, "sa");
+ hibernateH2Config.put(Environment.PASS, "sa");
+ hibernateH2Config.put(Environment.HBM2DDL_AUTO, "update");
- EntityManager entityManager = getJpaEntityManagerRule().newEntityManager();
+ File tempDirFile = SystemUtils.getJavaIoTmpDir();
- JpaPollenPersistenceContext persistenceContext = new JpaPollenPersistenceContext(entityManager);
+ File databaseFile = new File(tempDirFile, dataBase);
- serviceContext.setPersistenceContext(persistenceContext);
- }
+ String h2dataPath = databaseFile.getAbsolutePath() + File.separator + "h2data";
+
+ String jdbcUrl = "jdbc:h2:file:" + h2dataPath;
+
+ hibernateH2Config.put(Environment.URL, jdbcUrl);
+
+ if (log.isTraceEnabled()) {
+ log.trace("will store H2 data in " + h2dataPath);
+ log.trace("allTopiaParameters = " + hibernateH2Config);
}
- return serviceContext;
+ if (log.isDebugEnabled()) {
+ log.debug("jdbc url is\n" + jdbcUrl);
+ }
+ PollenTopiaApplicationContext applicationContext = new PollenTopiaApplicationContext(hibernateH2Config);
+
+ if (log.isTraceEnabled()) {
+ log.trace("created root context " + applicationContext);
+ }
+
+ return applicationContext;
}
- protected void loadFixtures(String fixturesSetName) {
+ protected PollenTopiaApplicationContext getApplicationContext() {
- FixturesService fixturesService = getServiceContext().newService(FixturesService.class);
+ String databaseName = UUID.randomUUID().toString();
- fixtures = fixturesService.loadFixtures(fixturesSetName);
+ return newApplicationContext(databaseName);
+ }
+ protected PollenTopiaPersistenceContext newPersistenceContext() {
+
+ if (applicationContext == null) {
+
+ applicationContext = getApplicationContext();
+ }
+
+ PollenTopiaPersistenceContext persistenceContext;
+
+ persistenceContext = applicationContext.newPersistenceContext();
+
+ if (log.isTraceEnabled()) {
+ log.trace("opened transaction " + persistenceContext);
+ }
+
+ openedTransactions.add(persistenceContext);
+
+ return persistenceContext;
+
}
- protected <E> E fixture(String id) {
+ protected static PollenServiceConfig getApplicationConfig() {
- return fixtures.fixture(id);
+ if (applicationConfig == null) {
+ applicationConfig = new PollenServiceConfig();
+ }
+
+ return applicationConfig;
}
- protected <E extends PollenServiceSupport> E newService(Class<E> serviceClass) {
+ protected FakePollenServiceContext getServiceContext() {
- return getServiceContext().newService(serviceClass);
+ if (serviceContext == null) {
+ serviceContext = new FakePollenServiceContext();
+ serviceContext.setPollenServiceConfig(getApplicationConfig());
+ PollenTopiaPersistenceContext persistenceContext = newPersistenceContext();
+ serviceContext.setPersistenceContext(persistenceContext);
+ serviceContext.setDate(DateUtil.createDate(2, 11, 2009));
+ }
+ return serviceContext;
}
- @Rule
- public JpaEntityManagerRule getJpaEntityManagerRule() {
+ protected void loadFixtures(String fixturesSetName) {
- if (jpaEntityManagerRule == null) {
+ FixturesService fixturesService = getServiceContext().newService(FixturesService.class);
- Map<String, String> jpaParameters = getPollenServiceConfig().getJpaParameters();
+ fixtures = fixturesService.loadFixtures(fixturesSetName);
- jpaEntityManagerRule = new JpaEntityManagerRule("pollenPersistenceUnit", jpaParameters);
- }
+// getServiceContext().getPersistenceContext().getHibernateSupport().getHibernateSession().clear();
+ }
- return jpaEntityManagerRule;
+ protected <E> E fixture(String id) {
+ return fixtures.fixture(id);
}
+ protected <E extends PollenService> E newService(Class<E> serviceClass) {
+
+ return getServiceContext().newService(serviceClass);
+ }
+
protected void assertErrorKeyFound(AbstractInvalidFormException e, String... keys) {
Multimap<String, String> errors = e.getErrors();
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -24,15 +24,21 @@
*/
import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.ChoiceImpl;
import org.chorem.pollen.persistence.entity.ChoiceType;
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.PollType;
import org.chorem.pollen.persistence.entity.VoterList;
+import org.chorem.pollen.persistence.entity.VoterListImpl;
import org.chorem.pollen.persistence.entity.VoterListMember;
+import org.chorem.pollen.persistence.entity.VoterListMemberImpl;
import org.chorem.pollen.services.PollenSecurityContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollFormException;
+import org.chorem.pollen.services.service.ChoiceService;
import org.chorem.pollen.services.service.PollService;
+import org.chorem.pollen.services.service.SecurityService;
+import org.chorem.pollen.services.service.VoterListService;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -55,7 +61,7 @@
loadFixtures("fixtures");
- service = serviceContext.getPollService();
+ service = getServiceContext().newService(PollService.class);
serviceContext.setDate(new Date(1363948427576l));
@@ -79,7 +85,7 @@
poll.setTitle("poll1");
- Choice choice1 = new Choice();
+ Choice choice1 = new ChoiceImpl();
poll.addChoice(choice1);
try {
@@ -93,7 +99,7 @@
choice1.setDescription("Choice A");
- Choice choice2 = new Choice();
+ Choice choice2 = new ChoiceImpl();
choice2.setName("A");
choice2.setDescription("Choice B");
poll.addChoice(choice2);
@@ -110,17 +116,17 @@
Poll createdPoll = service.createPoll(null, poll);
Assert.assertNotNull(createdPoll);
- Assert.assertNotNull(createdPoll.getId());
+ Assert.assertNotNull(createdPoll.getTopiaId());
- serviceContext.getSecurityService().prepareSubject(createdPoll.getCreator().getId());
+ serviceContext.newService(SecurityService.class).prepareSubject(createdPoll.getCreator().getTopiaId());
- Poll reloadedPoll = service.getPoll(createdPoll.getId());
+ Poll reloadedPoll = service.getPoll(createdPoll.getTopiaId());
Assert.assertEquals(createdPoll, reloadedPoll);
Assert.assertEquals(serviceContext.getNow(), createdPoll.getBeginDate());
Assert.assertNotNull(createdPoll.getCreator());
- Assert.assertNotNull(createdPoll.getCreator().getId());
+ Assert.assertNotNull(createdPoll.getCreator().getTopiaId());
Assert.assertNull(createdPoll.getCreator().getName());
Assert.assertNull(createdPoll.getCreator().getEmail());
Assert.assertNull(createdPoll.getComment());
@@ -133,9 +139,10 @@
Choice createdChoice1 = createdPoll.getChoice(0);
Assert.assertNotNull(createdChoice1);
- Assert.assertNotNull(createdChoice1.getId());
+ Assert.assertNotNull(createdChoice1.getTopiaId());
- Choice reloadedChoice1 = serviceContext.getChoiceService().getChoice(createdPoll.getId(), createdChoice1.getId());
+ ChoiceService choiceService = serviceContext.newService(ChoiceService.class);
+ Choice reloadedChoice1 = choiceService.getChoice(createdPoll.getTopiaId(), createdChoice1.getTopiaId());
Assert.assertEquals(createdChoice1, reloadedChoice1);
Assert.assertEquals(choice1.getName(), createdChoice1.getName());
@@ -144,9 +151,9 @@
Choice createdChoice2 = createdPoll.getChoice(1);
Assert.assertNotNull(createdChoice2);
- Assert.assertNotNull(createdChoice2.getId());
+ Assert.assertNotNull(createdChoice2.getTopiaId());
- Choice reloadedChoice2 = serviceContext.getChoiceService().getChoice(createdPoll.getId(), createdChoice2.getId());
+ Choice reloadedChoice2 = choiceService.getChoice(createdPoll.getTopiaId(), createdChoice2.getTopiaId());
Assert.assertEquals(createdChoice2, reloadedChoice2);
Assert.assertEquals(choice2.getName(), createdChoice2.getName());
@@ -163,13 +170,13 @@
poll.setTitle("poll1");
- Choice choice1 = new Choice();
+ Choice choice1 = new ChoiceImpl();
choice1.setName("A");
choice1.setDescription("Choice A");
poll.addChoice(choice1);
- Choice choice2 = new Choice();
+ Choice choice2 = new ChoiceImpl();
choice2.setName("B");
choice2.setDescription("Choice B");
@@ -183,7 +190,7 @@
}
// add voter list
- VoterList voterList = new VoterList();
+ VoterList voterList = new VoterListImpl();
poll.addVoterList(voterList);
@@ -199,7 +206,7 @@
voterList.setName("voterList1");
voterList.setWeight(1);
- VoterListMember voterListMember1 = new VoterListMember();
+ VoterListMember voterListMember1 = new VoterListMemberImpl();
voterList.addVoterListMember(voterListMember1);
try {
@@ -223,7 +230,7 @@
voterListMember1.setEmail("voter1(a)pollen.org");
- VoterListMember voterListMember2 = new VoterListMember();
+ VoterListMember voterListMember2 = new VoterListMemberImpl();
voterListMember2.setName("voter1");
voterListMember2.setWeight(0.7);
voterListMember2.setEmail("voter1(a)pollen.org");
@@ -242,15 +249,15 @@
Poll createdPoll = service.createPoll(null, poll);
Assert.assertNotNull(createdPoll);
- Assert.assertNotNull(createdPoll.getId());
+ Assert.assertNotNull(createdPoll.getTopiaId());
- Poll reloadedPoll = service.getPoll(createdPoll.getId());
+ Poll reloadedPoll = service.getPoll(createdPoll.getTopiaId());
Assert.assertEquals(createdPoll, reloadedPoll);
Assert.assertEquals(serviceContext.getNow(), createdPoll.getBeginDate());
Assert.assertNotNull(createdPoll.getCreator());
- Assert.assertNotNull(createdPoll.getCreator().getId());
+ Assert.assertNotNull(createdPoll.getCreator().getTopiaId());
Assert.assertNull(createdPoll.getCreator().getName());
Assert.assertNull(createdPoll.getCreator().getEmail());
Assert.assertNull(createdPoll.getComment());
@@ -261,9 +268,10 @@
Choice createdChoice1 = createdPoll.getChoice(0);
Assert.assertNotNull(createdChoice1);
- Assert.assertNotNull(createdChoice1.getId());
+ Assert.assertNotNull(createdChoice1.getTopiaId());
- Choice reloadedChoice1 = serviceContext.getChoiceService().getChoice(createdPoll.getId(), createdChoice1.getId());
+ ChoiceService choiceService = serviceContext.newService(ChoiceService.class);
+ Choice reloadedChoice1 = choiceService.getChoice(createdPoll.getTopiaId(), createdChoice1.getTopiaId());
Assert.assertEquals(createdChoice1, reloadedChoice1);
Assert.assertEquals(choice1.getName(), createdChoice1.getName());
@@ -272,9 +280,9 @@
Choice createdChoice2 = createdPoll.getChoice(1);
Assert.assertNotNull(createdChoice2);
- Assert.assertNotNull(createdChoice2.getId());
+ Assert.assertNotNull(createdChoice2.getTopiaId());
- Choice reloadedChoice2 = serviceContext.getChoiceService().getChoice(createdPoll.getId(), createdChoice2.getId());
+ Choice reloadedChoice2 = choiceService.getChoice(createdPoll.getTopiaId(), createdChoice2.getTopiaId());
Assert.assertEquals(createdChoice2, reloadedChoice2);
Assert.assertEquals(choice2.getName(), createdChoice2.getName());
@@ -285,9 +293,10 @@
Assert.assertEquals(1, createdPoll.sizeVoterList());
VoterList createdVoterList = createdPoll.getVoterList(0);
Assert.assertNotNull(createdVoterList);
- Assert.assertNotNull(createdVoterList.getId());
+ Assert.assertNotNull(createdVoterList.getTopiaId());
- VoterList reloadedVoterList = serviceContext.getVoterListService().getVoterList(createdPoll.getId(), createdVoterList.getId());
+ VoterListService voterListService = serviceContext.newService(VoterListService.class);
+ VoterList reloadedVoterList = voterListService.getVoterList(createdPoll.getTopiaId(), createdVoterList.getTopiaId());
Assert.assertEquals(createdVoterList, reloadedVoterList);
Assert.assertEquals(voterList.getName(), createdVoterList.getName());
@@ -296,29 +305,29 @@
Assert.assertNotNull(createdVoterList.getVoterListMember());
Assert.assertEquals(2, createdVoterList.sizeVoterListMember());
- VoterListMember createdVoterListMember1 = createdVoterList.getVoterListMember(0);
+// VoterListMember createdVoterListMember1 = Iterables.get(createdVoterList.getVoterListMember(), 0);
+//
+// Assert.assertNotNull(createdVoterListMember1);
+// Assert.assertNotNull(createdVoterListMember1.getTopiaId());
+// VoterListMember reloadedVoterListMember1 = voterListService.getVoterListMember(createdPoll.getTopiaId(), createdVoterList.getTopiaId(), createdVoterListMember1.getTopiaId());
+// Assert.assertEquals(createdVoterListMember1, reloadedVoterListMember1);
+//
+// Assert.assertEquals(reloadedVoterListMember1.getName(), createdVoterListMember1.getName());
+// Assert.assertEquals(reloadedVoterListMember1.getEmail(), createdVoterListMember1.getEmail());
+// Assert.assertEquals(reloadedVoterListMember1.getWeight(), createdVoterListMember1.getWeight(), 0);
+//
+// VoterListMember createdVoterListMember2 = Iterables.get(createdVoterList.getVoterListMember(), 1);
+//
+// Assert.assertNotNull(createdVoterListMember2);
+// Assert.assertNotNull(createdVoterListMember2.getTopiaId());
+//
+// VoterListMember reloadedVoterListMember2 = voterListService.getVoterListMember(createdPoll.getTopiaId(), createdVoterList.getTopiaId(), createdVoterListMember2.getTopiaId());
+// Assert.assertEquals(createdVoterListMember2, reloadedVoterListMember2);
+//
+// Assert.assertEquals(reloadedVoterListMember2.getName(), createdVoterListMember2.getName());
+// Assert.assertEquals(reloadedVoterListMember2.getEmail(), createdVoterListMember2.getEmail());
+// Assert.assertEquals(reloadedVoterListMember2.getWeight(), createdVoterListMember2.getWeight(), 0);
- Assert.assertNotNull(createdVoterListMember1);
- Assert.assertNotNull(createdVoterListMember1.getId());
- VoterListMember reloadedVoterListMember1 = serviceContext.getVoterListService().getVoterListMember(createdPoll.getId(), createdVoterList.getId(), createdVoterListMember1.getId());
- Assert.assertEquals(createdVoterListMember1, reloadedVoterListMember1);
-
- Assert.assertEquals(voterListMember1.getName(), createdVoterListMember1.getName());
- Assert.assertEquals(voterListMember1.getEmail(), createdVoterListMember1.getEmail());
- Assert.assertEquals(voterListMember1.getWeight(), createdVoterListMember1.getWeight(), 0);
-
- VoterListMember createdVoterListMember2 = createdVoterList.getVoterListMember(1);
-
- Assert.assertNotNull(createdVoterListMember2);
- Assert.assertNotNull(createdVoterListMember2.getId());
-
- VoterListMember reloadedVoterListMember2 = serviceContext.getVoterListService().getVoterListMember(createdPoll.getId(), createdVoterList.getId(), createdVoterListMember2.getId());
- Assert.assertEquals(createdVoterListMember2, reloadedVoterListMember2);
-
- Assert.assertEquals(voterListMember2.getName(), createdVoterListMember2.getName());
- Assert.assertEquals(voterListMember2.getEmail(), createdVoterListMember2.getEmail());
- Assert.assertEquals(voterListMember2.getWeight(), createdVoterListMember2.getWeight(), 0);
-
}
}
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -25,6 +25,8 @@
import org.apache.commons.collections.CollectionUtils;
import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.PollenUserImpl;
+import org.chorem.pollen.persistence.entity.PollenUsers;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
@@ -54,7 +56,7 @@
loadFixtures("fixtures");
- service = serviceContext.getPollenUserService();
+ service = getServiceContext().newService(PollenUserService.class);
serviceContext.setDate(new Date(1363948427576l));
@@ -80,7 +82,7 @@
Assert.assertTrue(true);
}
- PollenUser user = service.getUser(this.user.getId());
+ PollenUser user = service.getUser(this.user.getTopiaId());
Assert.assertNotNull(user);
Assert.assertEquals(this.user, user);
@@ -97,15 +99,15 @@
Assert.assertTrue(true);
}
- PollenUser newUser = new PollenUser();
+ PollenUser newUser = new PollenUserImpl();
newUser.setLogin("pollen");
newUser.setEmail("pollen(a)pollen.org");
PollenUser savedUser = service.createUser(newUser, true);
Assert.assertNotNull(savedUser);
- Assert.assertNotNull(savedUser.getId());
+ Assert.assertNotNull(savedUser.getTopiaId());
- PollenUser newUser2 = new PollenUser();
+ PollenUser newUser2 = new PollenUserImpl();
newUser2.setLogin("pollen");
newUser2.setEmail("pollen(a)pollen.org");
@@ -130,18 +132,18 @@
newUser2.setEmail("pollen2(a)pollen.org");
PollenUser savedUser2 = service.createUser(newUser2, true);
Assert.assertNotNull(savedUser2);
- Assert.assertNotNull(savedUser2.getId());
+ Assert.assertNotNull(savedUser2.getTopiaId());
}
@Test
public void testEditUser() throws EntityNotFoundException, InvalidPollenUserFormException {
- PollenUser user = service.getUser(this.user.getId());
+ PollenUser user = service.getUser(this.user.getTopiaId());
Assert.assertNotNull(user);
Assert.assertNull(user.getEmailActivationToken());
- serviceContext.getPersistenceContext().detach(user);
+ serviceContext.getPersistenceContext().getHibernateSupport().getHibernateSession().evict(user);
String originalLogin = user.getLogin();
@@ -168,11 +170,11 @@
@Test
public void testValidateEmail() throws EntityNotFoundException, UserInvalidEmailActivationTokenException, InvalidPollenUserFormException {
- PollenUser user = service.getUser(this.user.getId());
+ PollenUser user = service.getUser(this.user.getTopiaId());
Assert.assertNotNull(user);
Assert.assertNull(user.getEmailActivationToken());
- serviceContext.getPersistenceContext().detach(user);
+ serviceContext.getPersistenceContext().getHibernateSupport().getHibernateSession().evict(user);
String email = "tony(a)pollen.org";
user.setEmail(email);
@@ -185,19 +187,18 @@
Assert.assertNotNull(savedUser.getEmailActivationToken());
try {
- service.validateUserEmail(user.getId(), "fakeToken");
+ service.validateUserEmail(user.getTopiaId(), "fakeToken");
Assert.fail();
} catch (UserInvalidEmailActivationTokenException e) {
Assert.assertTrue(true);
}
- Assert.assertFalse(savedUser.isEmailActivated());
+ Assert.assertFalse(PollenUsers.isEmailActivated(savedUser));
- service.validateUserEmail(user.getId(), savedUser.getEmailActivationToken());
+ service.validateUserEmail(user.getTopiaId(), savedUser.getEmailActivationToken());
+ PollenUser reloadedUser = service.getUser(this.user.getTopiaId());
+ Assert.assertTrue(PollenUsers.isEmailActivated(reloadedUser));
- PollenUser reloadedUser = service.getUser(this.user.getId());
- Assert.assertTrue(reloadedUser.isEmailActivated());
-
}
}
Modified: trunk/pollen-services/src/test/resources/log4j.properties
===================================================================
--- trunk/pollen-services/src/test/resources/log4j.properties 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-services/src/test/resources/log4j.properties 2014-04-25 15:34:32 UTC (rev 3877)
@@ -26,6 +26,6 @@
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{hh:mm:ss} %5p (%F:%L) %m%n
-# log4j.logger.org.chorem.pollen=TRACE
+log4j.logger.org.chorem.pollen=DEBUG
# log4j.logger.org.hibernate.tool.hbm2ddl.SchemaExport=FATAL
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/AbstractVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/AbstractVoteCounting.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/AbstractVoteCounting.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -25,7 +25,7 @@
import java.util.Locale;
-import static org.nuiton.i18n.I18n.l_;
+import static org.nuiton.i18n.I18n.l;
/**
* Base abstract implementation of a {@link VoteCounting}.
@@ -73,22 +73,22 @@
@Override
public final String getName(Locale locale) {
- String result = l_(locale, i18nName);
+ String result = l(locale, i18nName);
return result;
}
@Override
public final String getShortHelp(Locale locale) {
- String voteName = l_(locale, i18nName);
- String voteHelp = l_(locale, i18nShortHelp);
+ String voteName = l(locale, i18nName);
+ String voteHelp = l(locale, i18nShortHelp);
String result =
- l_(locale, "pollen.voteCountingType.help", voteName, voteHelp);
+ l(locale, "pollen.voteCountingType.help", voteName, voteHelp);
return result;
}
@Override
public final String getHelp(Locale locale) {
- String result = l_(locale, i18nHelp);
+ String result = l(locale, i18nHelp);
return result;
}
Modified: trunk/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,8 +27,8 @@
import java.util.Locale;
-import static org.nuiton.i18n.I18n.l_;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.l;
+import static org.nuiton.i18n.I18n.n;
/**
* Borda vote counting entry point.
@@ -43,9 +43,9 @@
public BordaVoteCounting() {
super(ID,
BordaVoteCountingStrategy.class,
- n_("pollen.voteCountingType.borda"),
- n_("pollen.voteCountingType.borda.shortHelp"),
- n_("pollen.voteCountingType.borda.help")
+ n("pollen.voteCountingType.borda"),
+ n("pollen.voteCountingType.borda.shortHelp"),
+ n("pollen.voteCountingType.borda.help")
);
}
@@ -59,7 +59,7 @@
public String getVoteValueNotValidMessage(Locale locale,
String choiceName,
String voteValue) {
- return l_(locale, "pollen.error.vote.invalidBordaVoteValue",
+ return l(locale, "pollen.error.vote.invalidBordaVoteValue",
choiceName, voteValue);
}
Modified: trunk/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,8 +27,8 @@
import java.util.Locale;
-import static org.nuiton.i18n.I18n.l_;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.l;
+import static org.nuiton.i18n.I18n.n;
/**
* Coombs vote counting entry point.
@@ -43,9 +43,9 @@
public CondorcetVoteCounting() {
super(ID,
CondorcetVoteCountingStrategy.class,
- n_("pollen.voteCountingType.condorcet"),
- n_("pollen.voteCountingType.condorcet.shortHelp"),
- n_("pollen.voteCountingType.condorcet.help")
+ n("pollen.voteCountingType.condorcet"),
+ n("pollen.voteCountingType.condorcet.shortHelp"),
+ n("pollen.voteCountingType.condorcet.help")
);
}
@@ -59,7 +59,7 @@
public String getVoteValueNotValidMessage(Locale locale,
String choiceName,
String voteValue) {
- return l_(locale, "pollen.error.vote.invalidCondorcetVoteValue",
+ return l(locale, "pollen.error.vote.invalidCondorcetVoteValue",
choiceName, voteValue);
}
Modified: trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,8 +27,8 @@
import java.util.Locale;
-import static org.nuiton.i18n.I18n.l_;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.l;
+import static org.nuiton.i18n.I18n.n;
/**
* Coombs vote counting entry point.
@@ -43,9 +43,9 @@
public CoombsVoteCounting() {
super(ID,
CoombsVoteCountingStrategy.class,
- n_("pollen.voteCountingType.coombs"),
- n_("pollen.voteCountingType.coombs.shortHelp"),
- n_("pollen.voteCountingType.coombs.help")
+ n("pollen.voteCountingType.coombs"),
+ n("pollen.voteCountingType.coombs.shortHelp"),
+ n("pollen.voteCountingType.coombs.help")
);
}
@@ -59,7 +59,7 @@
public String getVoteValueNotValidMessage(Locale locale,
String choiceName,
String voteValue) {
- return l_(locale, "pollen.error.vote.invalidCoombsVoteValue",
+ return l(locale, "pollen.error.vote.invalidCoombsVoteValue",
choiceName,
voteValue);
}
Modified: trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,8 +27,8 @@
import java.util.Locale;
-import static org.nuiton.i18n.I18n.l_;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.l;
+import static org.nuiton.i18n.I18n.n;
/**
* Coombs vote counting entry point.
@@ -43,9 +43,9 @@
public InstantRunoffVoteCounting() {
super(ID,
InstantRunoffVoteCountingStrategy.class,
- n_("pollen.voteCountingType.instantRunoff"),
- n_("pollen.voteCountingType.instantRunoff.shortHelp"),
- n_("pollen.voteCountingType.instantRunoff.help")
+ n("pollen.voteCountingType.instantRunoff"),
+ n("pollen.voteCountingType.instantRunoff.shortHelp"),
+ n("pollen.voteCountingType.instantRunoff.help")
);
}
@@ -59,7 +59,7 @@
public String getVoteValueNotValidMessage(Locale locale,
String choiceName,
String voteValue) {
- return l_(locale, "pollen.error.vote.invalidInstantRunoffVoteValue",
+ return l(locale, "pollen.error.vote.invalidInstantRunoffVoteValue",
choiceName,
voteValue);
}
Modified: trunk/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,7 +27,7 @@
import java.util.Locale;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.n;
/**
* Coombs vote counting entry point.
@@ -42,9 +42,9 @@
public NormalVoteCounting() {
super(ID,
NormalVoteCountingStrategy.class,
- n_("pollen.voteCountingType.normal"),
- n_("pollen.voteCountingType.normal.shortHelp"),
- n_("pollen.voteCountingType.normal.help")
+ n("pollen.voteCountingType.normal"),
+ n("pollen.voteCountingType.normal.shortHelp"),
+ n("pollen.voteCountingType.normal.help")
);
}
Modified: trunk/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,7 +27,7 @@
import java.util.Locale;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.n;
/**
* Coombs vote counting entry point.
@@ -42,9 +42,9 @@
public NumberVoteCounting() {
super(ID,
NumberVoteCountingStrategy.class,
- n_("pollen.voteCountingType.number"),
- n_("pollen.voteCountingType.number.shortHelp"),
- n_("pollen.voteCountingType.number.help")
+ n("pollen.voteCountingType.number"),
+ n("pollen.voteCountingType.number.shortHelp"),
+ n("pollen.voteCountingType.number.help")
);
}
Modified: trunk/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java 2014-04-25 15:34:32 UTC (rev 3877)
@@ -27,8 +27,8 @@
import java.util.Locale;
-import static org.nuiton.i18n.I18n.l_;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.l;
+import static org.nuiton.i18n.I18n.n;
/**
* Coombs vote counting entry point.
@@ -43,9 +43,9 @@
public PercentageVoteCounting() {
super(ID,
PercentageVoteCountingStrategy.class,
- n_("pollen.voteCountingType.percentage"),
- n_("pollen.voteCountingType.percentage.shortHelp"),
- n_("pollen.voteCountingType.percentage.help")
+ n("pollen.voteCountingType.percentage"),
+ n("pollen.voteCountingType.percentage.shortHelp"),
+ n("pollen.voteCountingType.percentage.help")
);
}
@@ -91,7 +91,7 @@
@Override
public String getTotalVoteValueNotValidMessage(Locale locale) {
- return l_(locale, "pollen.error.vote.percentage");
+ return l(locale, "pollen.error.vote.percentage");
}
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-04-25 09:34:07 UTC (rev 3876)
+++ trunk/pom.xml 2014-04-25 15:34:32 UTC (rev 3877)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>5.0.4</version>
+ <version>5.0.6</version>
</parent>
<groupId>org.chorem</groupId>
@@ -163,20 +163,21 @@
<nuitonJpaVersion>1.0-rc-1</nuitonJpaVersion>
<webmotionVersion>2.4</webmotionVersion>
- <eugenePluginVersion>2.7</eugenePluginVersion>
- <nuitonI18nVersion>2.5.1</nuitonI18nVersion>
+ <nuitonI18nVersion>3.0</nuitonI18nVersion>
+ <eugenePluginVersion>2.9-SNAPSHOT</eugenePluginVersion>
+ <topiaVersion>3.0-SNAPSHOT</topiaVersion>
- <nuitonWebVersion>1.13</nuitonWebVersion>
+ <nuitonWebVersion>1.16</nuitonWebVersion>
<nuitonUtilsVersion>2.7.1</nuitonUtilsVersion>
- <nuitonConfigVersion>3.0-alpha-1</nuitonConfigVersion>
- <nuitonCsvVersion>3.0-alpha-1</nuitonCsvVersion>
+ <nuitonConfigVersion>3.0-alpha-2</nuitonConfigVersion>
+ <nuitonCsvVersion>3.0-alpha-3</nuitonCsvVersion>
<nuitonValidatorVersion>3.0-alpha-1</nuitonValidatorVersion>
<h2Version>1.3.173</h2Version>
<postgresqlVersion>9.1-901-1.jdbc4</postgresqlVersion>
<shiroVersion>1.2.2</shiroVersion>
- <slf4jVersion>1.7.5</slf4jVersion>
+ <slf4jVersion>1.7.6</slf4jVersion>
<jettyVersion>9.0.3.v20130506</jettyVersion>
- <hibernateVersion>4.3.0.Beta3</hibernateVersion>
+ <hibernateVersion>4.3.5.Final</hibernateVersion>
<seleniumVersion>2.33.0</seleniumVersion>
<mockitoVersion>1.9.5</mockitoVersion>
<httpCommonsHttpclientVersion>4.2.3</httpCommonsHttpclientVersion>
@@ -190,7 +191,12 @@
<scmwebeditorEnabled>true</scmwebeditorEnabled>
<!-- java configuration -->
+ <!-- Using Java 7 -->
<javaVersion>1.7</javaVersion>
+ <!--TODO remove this when IDEA won't ask to change jdk level at each pom modification-->
+ <maven.compiler.source>${javaVersion}</maven.compiler.source>
+ <!--TODO remove this when IDEA won't ask to change jdk level at each pom modification-->
+ <maven.compiler.target>${javaVersion}</maven.compiler.target>
<signatureArtifactId>java17</signatureArtifactId>
<signatureVersion>1.0</signatureVersion>
</properties>
@@ -230,6 +236,8 @@
<dependencyManagement>
<dependencies>
+ <!-- persistence module dependencies -->
+
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
@@ -237,6 +245,17 @@
</dependency>
<dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${topiaVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-junit</artifactId>
+ <version>${topiaVersion}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernateVersion}</version>
@@ -251,6 +270,13 @@
<dependency>
<groupId>org.hibernate</groupId>
+ <artifactId>hibernate-c3p0</artifactId>
+ <version>${hibernateVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernateVersion}</version>
<scope>runtime</scope>
@@ -633,7 +659,7 @@
<plugin>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-maven-report-plugin</artifactId>
- <version>${nuitonUtilsVersion}</version>
+ <version>3.0-rc-1</version>
<reportSets>
<reportSet>
<reports>
1
0
r3876 - in trunk/pollen-ui-angular/src/main/webapp: . css js js/libs partials
by garandel@users.chorem.org 25 Apr '14
by garandel@users.chorem.org 25 Apr '14
25 Apr '14
Author: garandel
Date: 2014-04-25 11:34:07 +0200 (Fri, 25 Apr 2014)
New Revision: 3876
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3876
Log:
update create and vote page
Removed:
trunk/pollen-ui-angular/src/main/webapp/css/bootstrap-datetimepicker.min.css
trunk/pollen-ui-angular/src/main/webapp/js/libs/jquery.scrollto.js
Modified:
trunk/pollen-ui-angular/src/main/webapp/css/style.css
trunk/pollen-ui-angular/src/main/webapp/index.html
trunk/pollen-ui-angular/src/main/webapp/js/app.js
trunk/pollen-ui-angular/src/main/webapp/js/controllers.js
trunk/pollen-ui-angular/src/main/webapp/partials/poll-create.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll-vote.html
Deleted: trunk/pollen-ui-angular/src/main/webapp/css/bootstrap-datetimepicker.min.css
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/css/bootstrap-datetimepicker.min.css 2014-04-22 16:13:03 UTC (rev 3875)
+++ trunk/pollen-ui-angular/src/main/webapp/css/bootstrap-datetimepicker.min.css 2014-04-25 09:34:07 UTC (rev 3876)
@@ -1,8 +0,0 @@
-/*!
- * Datepicker for Bootstrap
- *
- * Copyright 2012 Stefan Petre
- * Licensed under the Apache License v2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:"";line-height:0}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bootstrap-datetimepicker-widget{top:0;left:0;width:250px;padding:4px;margin-top:1px;z-index:3000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.bootstrap-datetimepicker-widget:before{content:'';display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:rgba(0,0,0,0.2);position:absolute;top:-7px;left:6px}.bootstrap-datetimepicker-widget:after{content:'';display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #fff;position:absolute;top:-6px;left:7px}.bootstrap-datetimepicker-widget.pull-right:before{left:auto;right:6px}.bootstrap-datetimepicker-widget.pull-right:after{left:auto;right:7px}.bootstrap-datetimepicker-widget>ul{list-style-type:none;margin:0}.bootstrap-datetimepicker-widget .timepicker-hour,.bootstrap-datetimepicker-widget .timepicker-minute,.bootstrap-datetimepicker-widget .timepicker-second{width:100%;font-weight:bold;font-size:1.2em}.bootstrap-datetimepicker-widget table[data-hour-format="12"] .separator{width:4px;padding:0;margin:0}.bootstrap-datetimepicker-widget .datepicker>div{display:none}.bootstrap-datetimepicker-widget .picker-switch{text-align:center}.bootstrap-datetimepicker-widget table{width:100%;margin:0}.bootstrap-datetimepicker-widget td,.bootstrap-datetimepicker-widget th{text-align:center;width:20px;height:20px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.bootstrap-datetimepicker-widget td.day:hover,.bootstrap-datetimepicker-widget td.hour:hover,.bootstrap-datetimepicker-widget td.minute:hover,.bootstrap-datetimepicker-widget td.second:hover{background:#eee;cursor:pointer}.bootstrap-datetimepicker-widget td.old,.bootstrap-datetimepicker-widget td.new{color:#999}.bootstrap-datetimepicker-widget td.active,.bootstrap-datetimepicker-widget td.active:hover{color:#fff;background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0044cc',GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.bootstrap-datetimepicker-widget td.active:hover,.bootstrap-datetimepicker-widget td.active:hover:hover,.bootstrap-datetimepicker-widget td.active:active,.bootstrap-datetimepicker-widget td.active:hover:active,.bootstrap-datetimepicker-widget td.active.active,.bootstrap-datetimepicker-widget td.active:hover.active,.bootstrap-datetimepicker-widget td.active.disabled,.bootstrap-datetimepicker-widget td.active:hover.disabled,.bootstrap-datetimepicker-widget td.active[disabled],.bootstrap-datetimepicker-widget td.active:hover[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.bootstrap-datetimepicker-widget td.active:active,.bootstrap-datetimepicker-widget td.active:hover:active,.bootstrap-datetimepicker-widget td.active.active,.bootstrap-datetimepicker-widget td.active:hover.active{background-color:#039 \9}.bootstrap-datetimepicker-widget td.disabled,.bootstrap-datetimepicker-widget td.disabled:hover{background:0;color:#999;cursor:not-allowed}.bootstrap-datetimepicker-widget td span{display:block;width:47px;height:54px;line-height:54px;float:left;margin:2px;cursor:pointer;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.bootstrap-datetimepicker-widget td span:hover{background:#eee}.bootstrap-datetimepicker-widget td span.active{color:#fff;background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0044cc',GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.bootstrap-datetimepicker-widget td span.active:hover,.bootstrap-datetimepicker-widget td span.active:active,.bootstrap-datetimepicker-widget td span.active.active,.bootstrap-datetimepicker-widget td span.active.disabled,.bootstrap-datetimepicker-widget td span.active[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.bootstrap-datetimepicker-widget td span.active:active,.bootstrap-datetimepicker-widget td span.active.active{background-color:#039 \9}.bootstrap-datetimepicker-widget td span.old{color:#999}.bootstrap-datetimepicker-widget td span.disabled,.bootstrap-datetimepicker-widget td span.disabled:hover{background:0;color:#999;cursor:not-allowed}.bootstrap-datetimepicker-widget th.switch{width:145px}.bootstrap-datetimepicker-widget th.next,.bootstrap-datetimepicker-widget th.prev{font-size:21px}.bootstrap-datetimepicker-widget th.disabled,.bootstrap-datetimepicker-widget th.disabled:hover{background:0;color:#999;cursor:not-allowed}.bootstrap-datetimepicker-widget thead tr:first-child th{cursor:pointer}.bootstrap-datetimepicker-widget thead tr:first-child th:hover{background:#eee}.input-append.date .add-on i,.input-prepend.date .add-on i{display:block;cursor:pointer;width:16px;height:16px}.bootstrap-datetimepicker-widget.left-oriented:before{left:auto;right:6px}.bootstrap-datetimepicker-widget.left-oriented:after{left:auto;right:7px}
\ No newline at end of file
Modified: trunk/pollen-ui-angular/src/main/webapp/css/style.css
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-22 16:13:03 UTC (rev 3875)
+++ trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-25 09:34:07 UTC (rev 3876)
@@ -111,11 +111,11 @@
padding-left:5px;
margin-bottom:30px;
}
-.pollTitle, .pollDesc, .pollChoice {
+.pollAnim {
background-color:#F8F8F8;
transition-duration:0.8s;
}
-.pollTitle:hover, .pollDesc:hover, .pollChoice:hover {
+.pollAnim:hover {
background:#CCD8DD;
transition-duration: 0.8s;
}
@@ -126,19 +126,6 @@
font-size:20px;
}
-.popEditor {
- width:80%;
- height:300px;
- background-color:white;
- box-shadow:0px 0px 15px 15px rgba(0,0,0,0.8);
- border-radius:30px;
- float:left;
- padding:30px;
- position:fixed;
- top:80px;
- left:10%;
-}
-
#poll {
text-align:center;
}
@@ -148,26 +135,33 @@
}
#poll tr, #poll tr td {
border-collapse: collapse;
- border: 1px dashed #AAAAAA;
- text-align:center;
- padding-left:5px;
- padding-right:5px;
}
-#poll tr td {
+.pollChoice {
height:60px;
min-width:150px;
padding-left:5px;
padding-right:5px;
padding-top:10px;
padding-bottom:5px;
+ border: 1px dashed #AAAAAA;
+ text-align:center;
+ padding-left:5px;
+ padding-right:5px;
}
-#poll input[type=text]{
+.pollChoice input[type=text]{
height:25px;
width:140px;
}
-#poll input[type=checkbox]{
+.pollChoice input[type=checkbox]{
width:25px;
height:25px;
- }
\ No newline at end of file
+ }
+
+.right-inner-addon .glyphicon-input {
+ position: absolute;
+ right: 30px;
+ top:10px;
+ pointer-events: none;
+}
\ No newline at end of file
Modified: trunk/pollen-ui-angular/src/main/webapp/index.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/index.html 2014-04-22 16:13:03 UTC (rev 3875)
+++ trunk/pollen-ui-angular/src/main/webapp/index.html 2014-04-25 09:34:07 UTC (rev 3876)
@@ -8,12 +8,12 @@
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%
@@ -21,121 +21,38 @@
<html lang="en" ng-app="pollen">
<head>
<title>Pollen</title>
- <link rel="stylesheet" href="pollen-ui-angular.css" />
- <link rel="stylesheet" href="css/bootstrap-datetimepicker.min.css" />
- <link rel="stylesheet" href="css/style.css" />
+ <link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
+ <link rel="stylesheet" href="css/style.css"/>
- <script src="pollen-ui-angular.js"></script>
- <script src="js/libs/ckeditor/ckeditor.js"></script>
- <script src="js/libs/ckeditor/adapters/jquery.js"></script>
- <script src="js/libs/jquery.scrollto.js"></script>
- <script src="js/libs/bootstrap-datetimepicker.min.js"></script>
-
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-resource.min…"></script>
+ <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.10.0.js"></script>
+ <script src="js/libs/ckeditor/ckeditor.js"></script>
+ <script src="js/libs/ckeditor/adapters/jquery.js"></script>
+
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
</head>
<body>
- <div class="navbar navbar-inverse navbar-static-top">
-
- <div class="navbar-inner">
- <a class="brand" href="#">Pollen</a>
-
- <ul class="nav">
- <li><a href="#">Home</a></li>
-
- <li class="dropdown">
- <a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
- Create <strong class="caret"></strong>
- </a>
-
- <ul class="dropdown-menu" role="menu">
- <li role="presentation">
- <a href="#/poll/create" role="menuitem" tabIndex="-1">WYSIWYG</a>
- </li>
-
- <li role="presentation">
- <a href="#/polls/form" role="menuitem" tabIndex="-1">form</a>
- </li>
-
- <li class="divider" role="presentation" ng-show="currentUser.login"></li>
-
- <li role="presentation" ng-show="currentUser.login">
- <a href="#/polls/" role="menuitem" tabIndex="-1">pollen.menu.polls.list</a>
- </li>
-
- </ul>
- </li>
- <li> <a href="#/poll/vote"> Voter </a></li>
+<nav class="navbar navbar-inverse navbar-static-top">
+ <div class="container-fluid">
+ <div class="navbar-header">
+ <a class="navbar-brand" href="#">Pollen</a>
+ </div>
+ <div class="collapse navbar-collapse">
+ <ul class="nav navbar-nav">
+ <li><a href="#/poll/create">Creer</a></li>
+ <li><a href="#/poll/vote">Voter</a></li>
</ul>
-
- <ul class="nav pull-right">
- <li ng-show="!currentUser.login">
- <a href="#/user/register/">pollen.menu.register</a>
- </li>
-
- <li class="divider-vertical" ng-show="!currentUser.login"></li>
-
- <li class="dropdown" ng-show="!currentUser.login">
- <a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
- pollen.menu.login.label <strong class="caret"></strong>
- </a>
-
- <div class="dropdown-menu form" role="menu">
- <form id='loginForm'>
-
- <div class="control-group">
- <label class="control-label">pollen.menu.login.form.login.label</label>
- <input type="text" name='login' placeholder="pollen.menu.login.form.login.placeholder"/>
- <span class="help-block hide"></span>
- </div>
-
- <div class="control-group">
- <label class="control-label" >pollen.menu.login.form.password.label</label>
- <input type="password" name='password' placeholder="pollen.menu.login.form.password.placeholder"/>
- <span class="help-block hide"></span>
- </div>
-
- <div class="control-group">
- <label class="control-label checkbox" >
- <input type="checkbox" name='rememberMe'> pollen.menu.login.form.rememberMe.label
- </label>
- </div>
-
- <div class="form-actions">
- <button type="submit" class="btn btn-primary">pollen.menu.login.form.button</button>
- </div>
-
- </form>
- </div>
- </li>
-
- <li class="dropdown" ng-show="currentUser.login">
- <a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
- {{ currentUser.name }} <strong class="caret"></strong>
- </a>
-
- <ul class="dropdown-menu" role="menu">
- <li role="presentation">
- <a href="#/user/edit/{{currentUser.id}}">pollen.menu.user.profile</a>
- </li>
-
- <li class="divider" role="presentation"></li>
- <li role="presentation">
- <a id='menuItemLogout'>pollen.menu.logout</a>
- </li>
-
- </ul>
- </li>
- </ul>
</div>
</div>
+</nav>
- <div ng-view class='container' id="content"></div>
+<div ng-view class='container' id="content"></div>
</body>
-</html>
\ No newline at end of file
+</html>
+
Modified: trunk/pollen-ui-angular/src/main/webapp/js/app.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-22 16:13:03 UTC (rev 3875)
+++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-25 09:34:07 UTC (rev 3876)
@@ -8,32 +8,31 @@
* 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%
*/
-angular.module('pollen', ["ngRoute", "pollenControllers", "pollenServices"])
+angular.module('pollen', ["ngRoute", "pollenControllers", "pollenServices", 'ui.bootstrap'])
.config(['$routeProvider', function($routeProvider) {
+ $routeProvider.when('/', {templateUrl: 'partials/home.html', controller: "HomeCtrl"})
+ .when('/poll/create', {templateUrl: 'partials/poll-create.html', controller: "PollCreateCtrl"})
+ .when('/poll/vote', {templateUrl: 'partials/poll-vote.html', controller :"PollVoteCtrl"})
+ .when('/polls', {templateUrl: 'partials/poll-list.html', controller: "PollListCtrl"})
+ .when('/polls/form', {templateUrl: 'partials/poll-form.html', controller: "PollFormCtrl"})
+ .when('/polls/:pollId', {templateUrl: 'partials/poll-detail.html', controller: "PollDetailCtrl"})
+ .otherwise({redirectTo: '/'});
- $routeProvider.when('/', {templateUrl: 'partials/home.html', controller: "HomeCtrl"})
- .when('/poll/create', {templateUrl: 'partials/poll-create.html', controller: "PollCreateCtrl"})
- .when('/poll/vote', {templateUrl: 'partials/poll-vote.html', controller :"PollVoteCtrl"})
- .when('/polls', {templateUrl: 'partials/poll-list.html', controller: "PollListCtrl"})
- .when('/polls/form', {templateUrl: 'partials/poll-form.html', controller: "PollFormCtrl"})
- .when('/polls/:pollId', {templateUrl: 'partials/poll-detail.html', controller: "PollDetailCtrl"})
- .otherwise({redirectTo: '/'});
-
}]).config(['$httpProvider', function($httpProvider) {
- $httpProvider.defaults.useXDomain = true;
- delete $httpProvider.defaults.headers.common['X-Requested-With'];
+ $httpProvider.defaults.useXDomain = true;
+ delete $httpProvider.defaults.headers.common['X-Requested-With'];
}])
.directive('focusMe', function($timeout) {
return {
@@ -49,38 +48,58 @@
}
};
})
+
.directive('ckEditor', function () {
- return {
- require: '?ngModel',
- link: function ($scope, elm, attr, ngModel) {
+ return {
+ require: '?ngModel',
+ link: function ($scope, elm, attr, ngModel) {
+ var ck = CKEDITOR.replace(elm[0]);
- var ck = CKEDITOR.replace(elm[0]);
+ ck.on('pasteState', function () {
+ $scope.$apply(function () {
+ ngModel.$setViewValue(ck.getData());
+ });
+ });
- ck.on('pasteState', function () {
- $scope.$apply(function () {
- ngModel.$setViewValue(ck.getData());
- });
- });
+ ngModel.$render = function (value) {
+ ck.setData(ngModel.$modelValue);
+ };
+ }
+ };
+})
- ngModel.$render = function (value) {
- ck.setData(ngModel.$modelValue);
- };
- }
- };
+.directive('ngExit', function ($timeout) {
+ return function (scope, element, attrs) {
+ element.bind("keydown keypress", function (event) {
+ if(event.which === 13 || event.which === 27) {
+ scope.$apply(function (){
+ scope.$eval(attrs.ngExit);
+ });
+
+ event.preventDefault();
+ }
+ });
+ element.bind('blur', function () {
+ $timeout (function () {
+ scope.$apply(attrs.ngExit);
+ }, 150);
+ event.preventDefault();
+ });
+ };
})
+
.factory('pollStorage', function () {
- var storageId='poll-storage';
- return {
- get: function () {
- return JSON.parse(localStorage.getItem(storageId) || '{}');
- },
- put: function (data) {
- localStorage.setItem(storageId, JSON.stringify(data));
- },
- remove: function () {
- localStorage.setItem(storageId, '{}');
- }
- }
+ var storageId='poll-storage';
+ return {
+ get: function () {
+ return JSON.parse(localStorage.getItem(storageId) || '{}');
+ },
+ put: function (data) {
+ localStorage.setItem(storageId, JSON.stringify(data));
+ },
+ remove: function () {
+ localStorage.setItem(storageId, '{}');
+ }
+ }
+});
-})
-;
\ No newline at end of file
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers.js 2014-04-22 16:13:03 UTC (rev 3875)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers.js 2014-04-25 09:34:07 UTC (rev 3876)
@@ -8,12 +8,12 @@
* 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%
@@ -21,42 +21,108 @@
angular.module('pollenControllers', []).controller('HomeCtrl', ['$scope', '$http', function ($scope, $http) {
}])
-.controller('PollCreateCtrl', function ($scope, $http, $sce, pollStorage) {
+.controller('PollCreateCtrl', ['$scope', '$http', '$sce', '$modal', '$filter', 'pollStorage', function ($scope, $http, $sce, $modal, $filter, pollStorage) {
+ function initPoll() {
+ return {
+ title :'Click Me for Editing',
+ description : '',
+ choices : []
+ };
+ }
+
+ function initChoice() {
+ return {
+ name: '',
+ type: 'text'
+ };
+ }
+
$scope.gvar = {};
$scope.poll = pollStorage.get();
if (JSON.stringify($scope.poll) == "{}") {
- $http.get('http://localhost:8080/pollen/v1/polls/new?choiceType=TEXT').success(function(data) {
- data.choices = [{name:"Choix 1"}, {name:"Choix 2"}];
- data.title = "Titre";
- $scope.poll = data;
+ $scope.poll = initPoll();
+ }
+
+ $scope.addChoice = function () {
+ var index = $scope.poll.choices.push(initChoice());
+ var choice = $scope.poll.choices[index-1];
+ var modalInstance = $modal.open({
+ templateUrl : 'popupChoice.html',
+ controller : PollPopChoiceCtrl,
+ resolve : {
+ title : function () { return 'Add Choice';},
+ choice : function () { return choice; }
+ }
});
+ modalInstance.result.then(function (ch) {
+ deleteChoice(ch);
+ });
+
}
- $scope.addChoice = function() {
- var index = $scope.poll.choices.push({});
- console.log('index=',index);
- $scope.poll.choices[index-1].name = "Choix "+index;
+ $scope.editChoice = function (choice) {
+ var modalInstance = $modal.open({
+ templateUrl : 'popupChoice.html',
+ controller : PollPopChoiceCtrl,
+ resolve : {
+ title : function () { return 'Edit Choice';},
+ choice : function () { return choice; }
+ }
+ });
+
+ modalInstance.result.then(function (ch) {
+ deleteChoice(ch);
+ });
}
- $scope.save = function () {
+ var deleteChoice = function (ch) {
+ var index = $scope.poll.choices.indexOf(ch);
+ if (index > -1) {
+ $scope.poll.choices.splice(index,1);
+ }
+ }
+
+ $scope.save = function () {
pollStorage.put($scope.poll);
$scope.gvar.saved = true;
}
+
$scope.reset = function () {
- $scope.poll = {};
+ $scope.poll = initPoll();
pollStorage.put({});
}
+
$scope.toHTML = function (data) {
return $sce.trustAsHtml(data);
}
-})
-.controller('PollVoteCtrl', function ($scope, $sce, pollStorage) {
+
+ var PollPopChoiceCtrl = function ($scope, $filter, $modalInstance, title, choice) {
+ $scope.title = title;
+ $scope.choice = choice;
+
+ $scope.saveChoice = function () {
+ $modalInstance.close();
+ }
+
+ $scope.deleteChoice = function (ch) {
+ $modalInstance.close(ch);
+ }
+
+ }
+}])
+
+.controller('PollVoteCtrl', ['$scope', '$filter', '$sce', 'pollStorage', function ($scope, $filter, $sce, pollStorage) {
$scope.gvar = {saved:false};
$scope.poll = pollStorage.get();
$scope.voteName = "Name";
$scope.voteChoices = [];
for (var i = 0; i < $scope.poll.choices.length; ++i) {
- $scope.voteChoices.push({name:$scope.poll.choices[i].name, value:false});
+ if ($scope.poll.choices[i].type == 'text') {
+ $scope.voteChoices.push({name:$scope.poll.choices[i].name, value:false});
+ }
+ else if ($scope.poll.choices[i].type == 'date') {
+ $scope.voteChoices.push({name: $filter('date')($scope.poll.choices[i].date,'dd/MM/yyyy') , value:false});
+ }
}
$scope.vote = function () {
@@ -74,7 +140,7 @@
$scope.toHTML = function (data) {
return $sce.trustAsHtml(data);
}
-})
+}])
.controller('PollFormCtrl', ['$scope', '$http', function ($scope, $http) {
$http.get('http://localhost:8080/pollen/v1/polls/new?choiceType=TEXT').success(function(data) {
data.choices = [{}, {}];
@@ -134,4 +200,5 @@
this.text = "";
}
-}]);
\ No newline at end of file
+}]);
+
Deleted: trunk/pollen-ui-angular/src/main/webapp/js/libs/jquery.scrollto.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/libs/jquery.scrollto.js 2014-04-22 16:13:03 UTC (rev 3875)
+++ trunk/pollen-ui-angular/src/main/webapp/js/libs/jquery.scrollto.js 2014-04-25 09:34:07 UTC (rev 3876)
@@ -1,54 +0,0 @@
-/*
- * #%L
- * Pollen :: UI (JS)
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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%
- */
-/*!
- * jquery.scrollto.js 0.0.1 - https://github.com/yckart/jquery.scrollto.js
- * Scroll smooth to any element in your DOM.
- *
- * Copyright (c) 2012 Yannick Albert (http://yckart.com)
- * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
- * 2013/02/17
- **/
-$.scrollTo = $.fn.scrollTo = function(x, y, options){
- if (!(this instanceof $)) return $.fn.scrollTo.apply($('html, body'), arguments);
-
- options = $.extend({}, {
- gap: {
- x: 0,
- y: 0
- },
- animation: {
- easing: 'swing',
- duration: 600,
- complete: $.noop,
- step: $.noop
- }
- }, options);
-
- return this.each(function(){
- var elem = $(this);
- elem.stop().animate({
- scrollLeft: !isNaN(Number(x)) ? x : $(y).offset().left + options.gap.x,
- scrollTop: !isNaN(Number(y)) ? y : $(y).offset().top + options.gap.y
- }, options.animation);
- });
-};
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll-create.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-create.html 2014-04-22 16:13:03 UTC (rev 3875)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-create.html 2014-04-25 09:34:07 UTC (rev 3876)
@@ -20,42 +20,110 @@
~ #L%
~
-->
+<form>
+ <alert type="'success'" ng-if="gvar.saved"> Sondage sauvegardé..</alert>
- <div class="alert alert-success" ng-show="gvar.saved"> Sondage sauvegardé.. </div>
+ <div class="pollTitle pollAnim" ng-click="showEditTitle = true; gvar.saved = false;">
+ <h1 ng-hide="showEditTitle"> {{poll.title}} </h1>
- <div class="pollTitle" ng-click="showEditTitle = true; gvar.saved = false;">
- <h1 ng-hide="showEditTitle"> {{poll.title}} </h1>
- <h1 ng-show="showEditTitle" ><input type="text" focus-me="showEditTitle" ng-blur="showEditTitle = false" ng-model="poll.title" /></h1>
+ <h1 ng-show="showEditTitle"><input type="text" focus-me="showEditTitle" ng-model="poll.title" ng-exit="showEditTitle = false"/></h1>
+ </div>
+
+ <div ng-hide="showEditDesc" class="pollDesc pollAnim" ng-click="showEditDesc = true; gvar.saved = false;">
+ <div> Description (Facultatif):</div>
+ <div ng-bind-html="toHTML(poll.description)"></div>
+ </div>
+ <div ng-show="showEditDesc" class="pollDesc " ng-exit="showEditDesc = false;">
+ <textarea id="descEditor" data-ck-editor ng-model="poll.description"></textarea>
+
+ <input type="button" value="Return" class="btn btn-primary" ng-click="showEditDesc = false;"/>
+ </div>
+
+ <div id="poll">
+ <table>
+ <tr>
+ <td class="pollChoice"> Votant</td>
+ <td ng-repeat="choice in poll.choices" class="pollChoice pollAnim"
+ ng-click="showEdit = true; gvar.saved = false;">
+ <div ng-show="choice.type == 'text'">
+ <div ng-hide="showEdit" title="{{choice.description}}">{{choice.name}}</div>
+ <div ng-show="showEdit">
+ <input type="text" ng-model="choice.name" focus-me="showEdit" ng-exit="showEdit = false"/>
+ <input type="button" class="btn" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
+ </div>
+ </div>
+ <div ng-show="choice.type == 'date'">
+ <div ng-hide="showEdit" title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}}</div>
+ <div ng-show="showEdit">
+ <input type="text" ng-model="choice.date" focus-me="showEdit" datepicker-popup="dd/MM/yyyy" ng-exit="showEdit = false"/>
+ <input type="button" class="btn" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
+ </div>
+ </div>
+ </td>
+ <td><input type="button" class="btn btn-default" value="+" ng-click="addChoice()"/></td>
+ </tr>
+ <tr>
+ <td class="pollChoice"> Name</td>
+ <td ng-repeat="choice in poll.choices" class="pollChoice">
+ <input type="checkbox" name="{{choice.name}}" ng-model="value"/>
+ </td>
+ <td></td>
+ </tr>
+ </table>
+ <input class="btn btn-primary" type="button" value="Save" ng-click="save()"/>
+
+ <br/><br/><br/>
+ <input type="button" value="reset" ng-click="reset();"/>
+ </div>
+</form>
+
+<script type="text/ng-template" id="popupChoice.html">
+ <form class="form-horizontal">
+ <div class="modal-header">
+ <h4 class="modal-title">{{title}}</h4>
</div>
+ <div class="modal-body">
- <div class="pollDesc" ng-click="showEditDesc = true; gvar.saved = false;">
- <div> Description (Facultatif): </div>
- <div ng-bind-html="toHTML(poll.description)"> </div>
- </div>
- <div ng-show="showEditDesc" class="popEditor">
- <textarea id="descEditor" data-ck-editor ng-model="poll.description"></textarea>
+ <div class="form-group">
+ <label class="col-sm-4 control-label">Type de choix :</label>
- <input type="button" value="Return" class="btn btn-primary" ng-click="showEditDesc = false;"/>
- </div>
+ <div class="col-sm-8 btn-group">
+ <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'text'">Text</button>
+ <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'date'">Date</button>
+ <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'picture'" disabled>Image</button>
+ </div>
+ </div>
- <div id="poll" >
- <table>
- <tr>
- <td> Votant </td>
- <td ng-repeat="choice in poll.choices" class="pollChoice" ng-click="showEdit = true; gvar.saved = false;">
- <div ng-hide="showEdit">{{choice.name}}</div>
- <div ng-show="showEdit"> <input type="text" ng-model="choice.name" focus-me="showEdit" ng-blur="showEdit = false" /> </div>
- </td>
- <td class="pollChoice"><input type="button" class="btn" ng-click="addChoice()" value="+" /></td>
- </tr>
- <tr>
- <td> Name </td>
- <td ng-repeat="choice in poll.choices" class="pollChoice"> <input type="checkbox" name="{{choice.name}}" /></td>
- <td class="pollChoice"></td>
- </tr>
- </table>
- <input class="btn btn-primary" type="button" value="Save" ng-click="save()" />
+ <div class="form-group" ng-if="choice.type == 'text'">
+ <label for="popNameChoiceCheck" class="col-sm-4 control-label">Nom du Choix : </label>
- <br/><br/><br/>
- <input type="button" value="reset" ng-click="reset();" />
- </div>
+ <div class="col-sm-6">
+ <input id="popNameChoiceCheck" type="text" ng-model="choice.name" class="form-control"/>
+ </div>
+ </div>
+
+ <div class="form-group" ng-if="choice.type == 'date'">
+ <label for="popNameChoiceDate" class="col-sm-4 control-label">Date : </label>
+
+ <div class="col-sm-6">
+ <div class="right-inner-addon ">
+ <i class="glyphicon glyphicon-calendar glyphicon-input"></i>
+ <input id="popNameChoiceDate" class="form-control" datepicker-popup="dd/MM/yyyy" type="text" ng-model="choice.date" is-open="opened"/>
+ </div>
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="popDescChoice" class="col-sm-4 control-label">Description : </label>
+
+ <div class="col-sm-6">
+ <textarea id="popDescChoice" type="text" ng-model="choice.description" class="form-control"></textarea>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-danger" data-dismiss="modal" ng-click="deleteChoice(choice)">delete</button>
+ <button type="button" class="btn btn-primary" ng-click="saveChoice()">Save</button>
+ </div>
+ </form>
+</script>
+
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll-vote.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-vote.html 2014-04-22 16:13:03 UTC (rev 3875)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-vote.html 2014-04-25 09:34:07 UTC (rev 3876)
@@ -1,29 +1,38 @@
<div class="alert alert-success" ng-show="gvar.saved"> Vote effectué.. </div>
+<div class="pollTitle">
+ <h1> {{poll.title}} </h1>
+</div>
+<div class="pollDesc" ng-hide="poll.description == ''" >
+ <div ng-bind-html="toHTML(poll.description)"> </div>
+</div>
+<div id="poll" >
+ <table>
+ <tr>
+ <td class="pollChoice"> Votant </td>
+ <td ng-repeat="choice in poll.choices" class="pollChoice">
+ <div ng-if="choice.type == 'text'">
+ <div title="{{choice.description}}">{{choice.name}}</div>
+ </div>
+ <div ng-if="choice.type == 'date'">
+ <div title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}}</div>
+ </div>
+ </td>
+ </tr>
+ <tr ng-repeat="vote in poll.votants track by $index" class="pollAnim">
+ <td class="pollChoice"> {{vote.name}}</td>
+ <td ng-repeat="choice in vote.choices" class="pollChoice">
+ <input type="checkbox" ng-model="choice.value" disabled/>
+ </td>
+ </tr>
+ <tr ng-hide="gvar.saved">
+ <td class="pollChoice pollAnim"> <input type="text" ng-model="voteName" /> </td>
+ <td ng-repeat="choice in voteChoices" class="pollChoice pollAnim" >
+ <input type="checkbox" name="{{choice.name}}" ng-model="choice.value" />
+ </td>
+ </tr>
+ </table>
+ <input class="btn btn-primary" type="button" value="Vote" ng-click="vote()" ng-hide="gvar.saved"/>
- <h1 class="pollTitle"> {{poll.title}} </h1>
+</div>
- <div class="pollDesc">
- <div> Description (Facultatif): </div>
- <div ng-bind-html="toHTML(poll.description)"> </div>
- </div>
-<div id="poll" >
- <table>
- <tr>
- <td> Votant </td>
- <td ng-repeat="choice in poll.choices">
- {{choice.name}}
- </td>
- </tr>
- <tr ng-repeat="vote in poll.votants">
- <td> {{vote.name}}</td>
- <td ng-repeat="choice in vote.choices"> <input type="checkbox" ng-model="choice.value" disabled/></td>
- </tr>
- <tr ng-hide="gvar.saved">
- <td class="pollChoice"> <input type="text" ng-model="voteName" /> </td>
- <td ng-repeat="choice in voteChoices" class="pollChoice" > <input type="checkbox" name="{{choice.name}}" ng-model="choice.value"/></td>
- </tr>
- </table>
- <input class="btn btn-primary" type="button" value="Vote" ng-click="vote()" ng-hide="gvar.saved"/>
-
-</div>
\ No newline at end of file
1
0