Merge de master dans migrateUser pour prendre la suite.
Showing
74 changed files
with
2816 additions
and
1198 deletions
Jenkinsfile
0 → 100644
1 | +#!groovy | ||
2 | +node { | ||
3 | + stage 'Environment' | ||
4 | + if (scm.branches == 'master') { | ||
5 | + println 'Nous sommes dans master' | ||
6 | + } | ||
7 | +// println scm.branches | ||
8 | + | ||
9 | + stage 'Config' | ||
10 | + def sonarqubeScannerHome = tool name: 'sonar', type: 'hudson.plugins.sonar.SonarRunnerInstallation' | ||
11 | + | ||
12 | + stage 'Checkout' | ||
13 | + checkout([$class: 'GitSCM', branches: [[name: "origin/$scm.branches"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'grogdevSSH', url: 'git@grogv3.legrog.org:grogv3/web-application.git']]]) | ||
14 | + | ||
15 | + stage 'clean install' | ||
16 | + withMaven(mavenLocalRepo: '', mavenOpts: '', mavenSettingsFilePath: '') { | ||
17 | + sh "mvn clean install" | ||
18 | + } | ||
19 | + | ||
20 | + stage 'Scan' | ||
21 | + sh "${sonarqubeScannerHome}/bin/sonar-scanner -Dsonar.host.url=http://grogv3.legrog.org:9000" | ||
22 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -5,28 +5,74 @@ | ... | @@ -5,28 +5,74 @@ |
5 | 5 | ||
6 | <groupId>org.legrog</groupId> | 6 | <groupId>org.legrog</groupId> |
7 | <artifactId>grog-cubi</artifactId> | 7 | <artifactId>grog-cubi</artifactId> |
8 | - <version>1.0-SNAPSHOT</version> | 8 | + <version>3.0-SNAPSHOT</version> |
9 | <packaging>war</packaging> | 9 | <packaging>war</packaging> |
10 | - <name>GRoG Cubi Webapp (TomEE dev)</name> | 10 | + |
11 | - <url>http://tomee.apache.org</url> | 11 | + <name>Web-application of GROG</name> |
12 | + <url>http://legrog.org</url> | ||
13 | + <description> | ||
14 | + Le Guide du Roliste Galactique (GROG) est une encyclopedie en ligne référençant tous les jeux de rôles connus. | ||
15 | + Cette version CUBI est la 3e mouture du site. | ||
16 | + </description> | ||
17 | + | ||
12 | 18 | ||
13 | <properties> | 19 | <properties> |
14 | - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | 20 | + <!-- dependencies version --> |
15 | - <spring.platform-bom.version>2.0.7.RELEASE</spring.platform-bom.version> | 21 | + <spring.platform-bom.version>Athens-SR1</spring.platform-bom.version> |
16 | <omnifaces.version>2.5.1</omnifaces.version> | 22 | <omnifaces.version>2.5.1</omnifaces.version> |
17 | <primefaces.version>6.0</primefaces.version> | 23 | <primefaces.version>6.0</primefaces.version> |
18 | <myfaces.version>2.2.10</myfaces.version> | 24 | <myfaces.version>2.2.10</myfaces.version> |
19 | <tomee.javaee-api.version>7.0</tomee.javaee-api.version> | 25 | <tomee.javaee-api.version>7.0</tomee.javaee-api.version> |
20 | <assertj-core.version>1.6.1</assertj-core.version> | 26 | <assertj-core.version>1.6.1</assertj-core.version> |
21 | <openjpa.version>2.4.1</openjpa.version> | 27 | <openjpa.version>2.4.1</openjpa.version> |
28 | + <rewrite.version>3.4.1.Final</rewrite.version> | ||
29 | + <hibernate-commons-annotations.version>5.0.1.Final</hibernate-commons-annotations.version> | ||
30 | + <hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version> | ||
31 | + <junit.platform.version>1.0.0-M2</junit.platform.version> | ||
32 | + <junit.jupiter.version>5.0.0-M2</junit.jupiter.version> | ||
33 | + <mockito-core.version>2.2.16</mockito-core.version> | ||
34 | + | ||
35 | + <!-- paths --> | ||
36 | + <custom.web.dir>src/main/java/org/legrog/web</custom.web.dir> | ||
37 | + | ||
38 | + <!-- misc --> | ||
39 | + <debug.jvm.args /> | ||
40 | + <tomee.autoreload /> | ||
41 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
42 | + <maven.compiler.source>1.8</maven.compiler.source> | ||
43 | + <maven.compiler.target>1.8</maven.compiler.target> | ||
44 | + | ||
45 | + | ||
46 | + </properties> | ||
47 | + | ||
48 | + <profiles> | ||
49 | + <profile> | ||
50 | + <id>debug</id> | ||
51 | + <!-- | ||
52 | + activate this one to be able to attach a remote debbuger on tomee | ||
53 | + --> | ||
54 | + <properties> | ||
55 | + <debug.jvm.args>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</debug.jvm.args> | ||
56 | + </properties> | ||
57 | + </profile> | ||
58 | + | ||
59 | + <profile> | ||
60 | + <id>autoreload</id> | ||
61 | + <!-- | ||
62 | + activate this one for tomee to reload (takes times) every times it detect a synchro | ||
63 | + reminder : you can always force a reload by typing reload in the console while tomee:run is active | ||
64 | + --> | ||
65 | + <properties> | ||
66 | + <tomee.autoreload>true</tomee.autoreload> | ||
22 | </properties> | 67 | </properties> |
68 | + </profile> | ||
69 | + </profiles> | ||
23 | 70 | ||
24 | <dependencyManagement> | 71 | <dependencyManagement> |
25 | <dependencies> | 72 | <dependencies> |
26 | <dependency> | 73 | <dependency> |
27 | <groupId>io.spring.platform</groupId> | 74 | <groupId>io.spring.platform</groupId> |
28 | <artifactId>platform-bom</artifactId> | 75 | <artifactId>platform-bom</artifactId> |
29 | - <!-- Nécessaire à la compilation --> | ||
30 | <version>${spring.platform-bom.version}</version> | 76 | <version>${spring.platform-bom.version}</version> |
31 | <type>pom</type> | 77 | <type>pom</type> |
32 | <scope>import</scope> | 78 | <scope>import</scope> |
... | @@ -35,12 +81,21 @@ | ... | @@ -35,12 +81,21 @@ |
35 | </dependencyManagement> | 81 | </dependencyManagement> |
36 | 82 | ||
37 | <dependencies> | 83 | <dependencies> |
38 | - <!-- **** PREREQUIS MIGRATION **** --> | 84 | + |
85 | + | ||
86 | + <!-- **** FRAMEWORK : JSF + CDI **** --> | ||
87 | + | ||
88 | + <dependency> | ||
89 | + <groupId>org.apache.tomee</groupId> | ||
90 | + <artifactId>javaee-api</artifactId> | ||
91 | + <version>${tomee.javaee-api.version}</version> | ||
92 | + <scope>provided</scope> | ||
93 | + </dependency> | ||
94 | + | ||
39 | <!-- https://mvnrepository.com/artifact/org.omnifaces/omnifaces --> | 95 | <!-- https://mvnrepository.com/artifact/org.omnifaces/omnifaces --> |
40 | <dependency> | 96 | <dependency> |
41 | <groupId>org.omnifaces</groupId> | 97 | <groupId>org.omnifaces</groupId> |
42 | <artifactId>omnifaces</artifactId> | 98 | <artifactId>omnifaces</artifactId> |
43 | - <!-- Nécessaire à la compilation --> | ||
44 | <version>${omnifaces.version}</version> | 99 | <version>${omnifaces.version}</version> |
45 | </dependency> | 100 | </dependency> |
46 | 101 | ||
... | @@ -48,34 +103,57 @@ | ... | @@ -48,34 +103,57 @@ |
48 | <dependency> | 103 | <dependency> |
49 | <groupId>org.primefaces</groupId> | 104 | <groupId>org.primefaces</groupId> |
50 | <artifactId>primefaces</artifactId> | 105 | <artifactId>primefaces</artifactId> |
51 | - <!-- Nécessaire à la compilation --> | ||
52 | <version>${primefaces.version}</version> | 106 | <version>${primefaces.version}</version> |
53 | </dependency> | 107 | </dependency> |
54 | 108 | ||
55 | <dependency> | 109 | <dependency> |
56 | <groupId>org.apache.myfaces.core</groupId> | 110 | <groupId>org.apache.myfaces.core</groupId> |
57 | <artifactId>myfaces-api</artifactId> | 111 | <artifactId>myfaces-api</artifactId> |
58 | - <!-- Nécessaire à la compilation --> | ||
59 | <version>${myfaces.version}</version> | 112 | <version>${myfaces.version}</version> |
60 | </dependency> | 113 | </dependency> |
61 | <dependency> | 114 | <dependency> |
62 | <groupId>org.apache.myfaces.core</groupId> | 115 | <groupId>org.apache.myfaces.core</groupId> |
63 | <artifactId>myfaces-impl</artifactId> | 116 | <artifactId>myfaces-impl</artifactId> |
64 | - <!-- Nécessaire à l'exécution --> | ||
65 | <version>${myfaces.version}</version> | 117 | <version>${myfaces.version}</version> |
118 | + <scope>runtime</scope> | ||
66 | </dependency> | 119 | </dependency> |
67 | - <!-- **** FRAMEWORK : JSF + CDI **** --> | 120 | + |
121 | + | ||
122 | + <!-- Rewriting tool --> | ||
68 | 123 | ||
69 | <dependency> | 124 | <dependency> |
70 | - <groupId>org.apache.tomee</groupId> | 125 | + <groupId>org.ocpsoft.rewrite</groupId> |
71 | - <artifactId>javaee-api</artifactId> | 126 | + <artifactId>rewrite-servlet</artifactId> |
72 | - <!-- Nécessaire à la compilation --> | 127 | + <version>${rewrite.version}</version> |
73 | - <version>${tomee.javaee-api.version}</version> | ||
74 | - <scope>provided</scope> | ||
75 | </dependency> | 128 | </dependency> |
76 | 129 | ||
130 | + <dependency> | ||
131 | + <groupId>org.ocpsoft.rewrite</groupId> | ||
132 | + <artifactId>rewrite-integration-faces</artifactId> | ||
133 | + <version>${rewrite.version}</version> | ||
134 | + </dependency> | ||
135 | + | ||
136 | + <dependency> | ||
137 | + <groupId>org.ocpsoft.rewrite</groupId> | ||
138 | + <artifactId>rewrite-integration-cdi</artifactId> | ||
139 | + <version>${rewrite.version}</version> | ||
140 | + </dependency> | ||
141 | + | ||
142 | + <!--<dependency>--> | ||
143 | + <!--<groupId>com.ocpsoft</groupId>--> | ||
144 | + <!--<artifactId>prettyfaces-jsf2</artifactId>--> | ||
145 | + <!--<version>3.3.3</version>--> | ||
146 | + <!--</dependency>--> | ||
147 | + <!--<dependency>--> | ||
148 | + <!--<groupId>org.ocpsoft.rewrite</groupId>--> | ||
149 | + <!--<artifactId>rewrite-config-prettyfaces</artifactId>--> | ||
150 | + <!--<version>${rewrite.version}</version>--> | ||
151 | + <!--</dependency> --> | ||
152 | + | ||
153 | + | ||
77 | 154 | ||
78 | <!-- **** TOOLS : LOGS + UTILS **** --> | 155 | <!-- **** TOOLS : LOGS + UTILS **** --> |
156 | + | ||
79 | <dependency> | 157 | <dependency> |
80 | <groupId>org.slf4j</groupId> | 158 | <groupId>org.slf4j</groupId> |
81 | <artifactId>slf4j-api</artifactId> | 159 | <artifactId>slf4j-api</artifactId> |
... | @@ -99,19 +177,121 @@ | ... | @@ -99,19 +177,121 @@ |
99 | <artifactId>spring-data-jpa</artifactId> | 177 | <artifactId>spring-data-jpa</artifactId> |
100 | </dependency> | 178 | </dependency> |
101 | 179 | ||
180 | + <!-- ** Hibernate deps ** --> | ||
181 | + <dependency> | ||
182 | + <groupId>antlr</groupId> | ||
183 | + <artifactId>antlr</artifactId> | ||
184 | + </dependency> | ||
185 | + <dependency> | ||
186 | + <groupId>dom4j</groupId> | ||
187 | + <artifactId>dom4j</artifactId> | ||
188 | + </dependency> | ||
189 | + <dependency> | ||
190 | + <groupId>org.hibernate.common</groupId> | ||
191 | + <artifactId>hibernate-commons-annotations</artifactId> | ||
192 | + <version>${hibernate-commons-annotations.version}</version> | ||
193 | + </dependency> | ||
194 | + <dependency> | ||
195 | + <groupId>org.hibernate.javax.persistence</groupId> | ||
196 | + <artifactId>hibernate-jpa-2.1-api</artifactId> | ||
197 | + <version>${hibernate-jpa-2.1-api.version}</version> | ||
198 | + </dependency> | ||
199 | + <dependency> | ||
200 | + <groupId>org.hibernate</groupId> | ||
201 | + <artifactId>hibernate-core</artifactId> | ||
202 | + </dependency> | ||
203 | + <dependency> | ||
204 | + <groupId>org.hibernate</groupId> | ||
205 | + <artifactId>hibernate-ehcache</artifactId> | ||
206 | + </dependency> | ||
207 | + <dependency> | ||
208 | + <groupId>org.hibernate</groupId> | ||
209 | + <artifactId>hibernate-entitymanager</artifactId> | ||
210 | + </dependency> | ||
211 | + <dependency> | ||
212 | + <groupId>org.hibernate</groupId> | ||
213 | + <artifactId>hibernate-validator</artifactId> | ||
214 | + </dependency> | ||
215 | + <dependency> | ||
216 | + <groupId>org.jboss.logging</groupId> | ||
217 | + <artifactId>jboss-logging</artifactId> | ||
218 | + </dependency> | ||
219 | + <dependency> | ||
220 | + <groupId>org.javassist</groupId> | ||
221 | + <artifactId>javassist</artifactId> | ||
222 | + </dependency> | ||
223 | + <!-- ** Hibernate deps ** --> | ||
224 | + | ||
225 | + | ||
102 | 226 | ||
103 | <!-- **** TEST SCOPE **** --> | 227 | <!-- **** TEST SCOPE **** --> |
228 | + <dependency> | ||
229 | + <groupId>org.junit.platform</groupId> | ||
230 | + <artifactId>junit-platform-runner</artifactId> | ||
231 | + <version>${junit.platform.version}</version> | ||
232 | + <scope>test</scope> | ||
233 | + </dependency> | ||
234 | + | ||
235 | + <dependency> | ||
236 | + <groupId>org.junit.platform</groupId> | ||
237 | + <artifactId>junit-platform-launcher</artifactId> | ||
238 | + <version>${junit.platform.version}</version> | ||
239 | + <scope>test</scope> | ||
240 | + </dependency> | ||
241 | + | ||
242 | + <dependency> | ||
243 | + <groupId>org.junit.platform</groupId> | ||
244 | + <artifactId> junit-platform-console</artifactId> | ||
245 | + <version>${junit.platform.version}</version> | ||
246 | + <scope>test</scope> | ||
247 | + </dependency> | ||
248 | + | ||
249 | + <dependency> | ||
250 | + <groupId>org.junit.platform</groupId> | ||
251 | + <artifactId>junit-platform-commons</artifactId> | ||
252 | + <version>${junit.platform.version}</version> | ||
253 | + <scope>test</scope> | ||
254 | + </dependency> | ||
255 | + | ||
256 | + <dependency> | ||
257 | + <groupId>org.junit.platform</groupId> | ||
258 | + <artifactId>junit-platform-engine</artifactId> | ||
259 | + <version>${junit.platform.version}</version> | ||
260 | + <scope>test</scope> | ||
261 | + </dependency> | ||
262 | + | ||
263 | + <dependency> | ||
264 | + <groupId>org.junit.platform</groupId> | ||
265 | + <artifactId>junit-platform-surefire-provider</artifactId> | ||
266 | + <version>${junit.platform.version}</version> | ||
267 | + <scope>test</scope> | ||
268 | + </dependency> | ||
269 | + | ||
270 | + <dependency> | ||
271 | + <groupId>org.junit.jupiter</groupId> | ||
272 | + <artifactId>junit-jupiter-api</artifactId> | ||
273 | + <version>${junit.jupiter.version}</version> | ||
274 | + <scope>test</scope> | ||
275 | + </dependency> | ||
104 | 276 | ||
277 | + <dependency> | ||
278 | + <groupId>org.junit.jupiter</groupId> | ||
279 | + <artifactId>junit-jupiter-engine</artifactId> | ||
280 | + <version>${junit.jupiter.version}</version> | ||
281 | + <scope>test</scope> | ||
282 | + </dependency> | ||
105 | 283 | ||
284 | + <!-- JUnit 4 | ||
106 | <dependency> | 285 | <dependency> |
107 | <groupId>junit</groupId> | 286 | <groupId>junit</groupId> |
108 | <artifactId>junit</artifactId> | 287 | <artifactId>junit</artifactId> |
109 | <scope>test</scope> | 288 | <scope>test</scope> |
110 | </dependency> | 289 | </dependency> |
111 | - | 290 | +--> |
112 | <dependency> | 291 | <dependency> |
113 | <groupId>org.mockito</groupId> | 292 | <groupId>org.mockito</groupId> |
114 | <artifactId>mockito-core</artifactId> | 293 | <artifactId>mockito-core</artifactId> |
294 | + <version>${mockito-core.version}</version> | ||
115 | <scope>test</scope> | 295 | <scope>test</scope> |
116 | </dependency> | 296 | </dependency> |
117 | 297 | ||
... | @@ -121,14 +301,14 @@ | ... | @@ -121,14 +301,14 @@ |
121 | <version>${assertj-core.version}</version> | 301 | <version>${assertj-core.version}</version> |
122 | <scope>test</scope> | 302 | <scope>test</scope> |
123 | </dependency> | 303 | </dependency> |
124 | -<!-- | 304 | + <!-- |
125 | <dependency> | 305 | <dependency> |
126 | <groupId>org.apache.openjpa</groupId> | 306 | <groupId>org.apache.openjpa</groupId> |
127 | <artifactId>openjpa</artifactId> | 307 | <artifactId>openjpa</artifactId> |
128 | <version>${openjpa.version}</version> | 308 | <version>${openjpa.version}</version> |
129 | <scope>test</scope> | 309 | <scope>test</scope> |
130 | </dependency> | 310 | </dependency> |
131 | ---> | 311 | + --> |
132 | <!-- to test with TomEE and Arquillian | 312 | <!-- to test with TomEE and Arquillian |
133 | <dependency> | 313 | <dependency> |
134 | <groupId>org.apache.tomee</groupId> | 314 | <groupId>org.apache.tomee</groupId> |
... | @@ -170,60 +350,7 @@ | ... | @@ -170,60 +350,7 @@ |
170 | <scope>test</scope> | 350 | <scope>test</scope> |
171 | </dependency> | 351 | </dependency> |
172 | --> | 352 | --> |
173 | - <!-- Hibernate --> | 353 | + |
174 | - <dependency> | ||
175 | - <groupId>antlr</groupId> | ||
176 | - <artifactId>antlr</artifactId> | ||
177 | -<!-- <version>2.7.7</version>--> | ||
178 | - </dependency> | ||
179 | - <dependency> | ||
180 | - <groupId>dom4j</groupId> | ||
181 | - <artifactId>dom4j</artifactId> | ||
182 | -<!-- <version>1.6.1</version>--> | ||
183 | - </dependency> | ||
184 | - <dependency> | ||
185 | - <groupId>org.hibernate.common</groupId> | ||
186 | - <artifactId>hibernate-commons-annotations</artifactId> | ||
187 | - <!-- Nécessaire --> | ||
188 | - <version>5.0.1.Final</version> | ||
189 | - </dependency> | ||
190 | - <dependency> | ||
191 | - <groupId>org.hibernate.javax.persistence</groupId> | ||
192 | - <artifactId>hibernate-jpa-2.1-api</artifactId> | ||
193 | - <!-- Nécessaire --> | ||
194 | - <version>1.0.0.Final</version> | ||
195 | - <scope>compile</scope> | ||
196 | - </dependency> | ||
197 | - <dependency> | ||
198 | - <groupId>org.hibernate</groupId> | ||
199 | - <artifactId>hibernate-core</artifactId> | ||
200 | -<!-- <version>5.2.3.Final</version>--> | ||
201 | - </dependency> | ||
202 | - <dependency> | ||
203 | - <groupId>org.hibernate</groupId> | ||
204 | - <artifactId>hibernate-ehcache</artifactId> | ||
205 | -<!-- <version>5.2.3.Final</version>--> | ||
206 | - </dependency> | ||
207 | - <dependency> | ||
208 | - <groupId>org.hibernate</groupId> | ||
209 | - <artifactId>hibernate-entitymanager</artifactId> | ||
210 | -<!-- <version>5.2.3.Final</version>--> | ||
211 | - </dependency> | ||
212 | - <dependency> | ||
213 | - <groupId>org.hibernate</groupId> | ||
214 | - <artifactId>hibernate-validator</artifactId> | ||
215 | -<!-- <version>5.2.3.Final</version>--> | ||
216 | - </dependency> | ||
217 | - <dependency> | ||
218 | - <groupId>org.jboss.logging</groupId> | ||
219 | - <artifactId>jboss-logging</artifactId> | ||
220 | -<!-- <version>3.3.0.Final</version>--> | ||
221 | - </dependency> | ||
222 | - <dependency> | ||
223 | - <groupId>org.javassist</groupId> | ||
224 | - <artifactId>javassist</artifactId> | ||
225 | -<!-- <version>3.20.0-GA</version>--> | ||
226 | - </dependency> | ||
227 | </dependencies> | 354 | </dependencies> |
228 | 355 | ||
229 | <build> | 356 | <build> |
... | @@ -231,29 +358,75 @@ | ... | @@ -231,29 +358,75 @@ |
231 | <plugin> | 358 | <plugin> |
232 | <groupId>org.apache.maven.plugins</groupId> | 359 | <groupId>org.apache.maven.plugins</groupId> |
233 | <artifactId>maven-compiler-plugin</artifactId> | 360 | <artifactId>maven-compiler-plugin</artifactId> |
234 | -<!-- <version>3.5.1</version>--> | 361 | + <version>3.5.1</version> |
235 | </plugin> | 362 | </plugin> |
236 | <plugin> | 363 | <plugin> |
237 | <groupId>org.apache.maven.plugins</groupId> | 364 | <groupId>org.apache.maven.plugins</groupId> |
238 | <artifactId>maven-surefire-plugin</artifactId> | 365 | <artifactId>maven-surefire-plugin</artifactId> |
239 | -<!-- <version>2.19.1</version>--> | 366 | + <version>2.19.1</version> |
240 | </plugin> | 367 | </plugin> |
241 | <plugin> | 368 | <plugin> |
242 | <groupId>org.apache.maven.plugins</groupId> | 369 | <groupId>org.apache.maven.plugins</groupId> |
243 | <artifactId>maven-war-plugin</artifactId> | 370 | <artifactId>maven-war-plugin</artifactId> |
244 | -<!-- <version>2.6</version>--> | 371 | + <version>2.6</version> |
245 | <configuration> | 372 | <configuration> |
246 | <failOnMissingWebXml>false</failOnMissingWebXml> | 373 | <failOnMissingWebXml>false</failOnMissingWebXml> |
374 | + <webResources> | ||
375 | + <resource> | ||
376 | + <!-- this is relative to the pom.xml directory --> | ||
377 | + <directory>${custom.web.dir}</directory> | ||
378 | + <excludes> | ||
379 | + <exclude>**/*.java</exclude> | ||
380 | + </excludes> | ||
381 | + | ||
382 | + </resource> | ||
383 | + </webResources> | ||
384 | + | ||
247 | </configuration> | 385 | </configuration> |
248 | </plugin> | 386 | </plugin> |
387 | + | ||
388 | + | ||
389 | + <!-- **** TOMEE **** --> | ||
390 | + <!-- For now we just get a generic one from the repo and put it in target dir --> | ||
391 | + <!-- For production release, we will need another pom doing a real provisionning and build it with grog-cubi already inside --> | ||
392 | + <!-- | ||
393 | + see http://tomee.apache.org/ng/developer/tools/maven/tomee.html | ||
394 | + and http://tomee.apache.org/maven/index.html | ||
395 | + for conf references (I love when a new reference page doesn't get the same info as the former one) | ||
396 | + --> | ||
249 | <plugin> | 397 | <plugin> |
250 | <groupId>org.apache.tomee.maven</groupId> | 398 | <groupId>org.apache.tomee.maven</groupId> |
251 | <artifactId>tomee-maven-plugin</artifactId> | 399 | <artifactId>tomee-maven-plugin</artifactId> |
252 | -<!-- <version>7.0.1</version>--> | 400 | + <version>7.0.1</version> |
253 | <configuration> | 401 | <configuration> |
254 | <context>ROOT</context> | 402 | <context>ROOT</context> |
403 | + | ||
404 | + <!-- debug agent to attach a remote debbuger, activate profile for that --> | ||
405 | + <args>${debug.jvm.args}</args> | ||
406 | + | ||
407 | + <systemVariables> | ||
408 | + <!-- | ||
409 | + taken from http://tomee-openejb.979440.n4.nabble.com/7-0-0-M3-synchronization-td4677806.html for synchro to work | ||
410 | + --> | ||
411 | + <openejb.system.apps>true</openejb.system.apps> | ||
412 | + <tomee.serialization.class.blacklist>-</tomee.serialization.class.blacklist> | ||
413 | + </systemVariables> | ||
414 | + | ||
415 | + | ||
416 | + <synchronization> | ||
417 | + <resourcesDir>${custom.web.dir}</resourcesDir> | ||
418 | + <extensions> | ||
419 | + <extension>.class</extension> <!-- update each time you build with mvn compile --> | ||
420 | + <extension>.xhtml</extension> <!-- update each time you save an xhtml in custom web dir --> | ||
421 | + </extensions> | ||
422 | + </synchronization> | ||
423 | + <reloadOnUpdate>${tomee.autoreload}</reloadOnUpdate> | ||
424 | + | ||
255 | </configuration> | 425 | </configuration> |
256 | </plugin> | 426 | </plugin> |
427 | + | ||
428 | + | ||
429 | + | ||
257 | <!-- | 430 | <!-- |
258 | <plugin> | 431 | <plugin> |
259 | <groupId>org.apache.openjpa</groupId> | 432 | <groupId>org.apache.openjpa</groupId> |
... | @@ -284,6 +457,26 @@ | ... | @@ -284,6 +457,26 @@ |
284 | </dependencies> | 457 | </dependencies> |
285 | </plugin> | 458 | </plugin> |
286 | --> | 459 | --> |
460 | + <plugin> | ||
461 | + <groupId>org.jacoco</groupId> | ||
462 | + <artifactId>jacoco-maven-plugin</artifactId> | ||
463 | + <version>0.7.7.201606060606</version> | ||
464 | + <executions> | ||
465 | + <execution> | ||
466 | + <id>default-prepare-agent</id> | ||
467 | + <goals> | ||
468 | + <goal>prepare-agent</goal> | ||
469 | + </goals> | ||
470 | + </execution> | ||
471 | + <execution> | ||
472 | + <id>default-report</id> | ||
473 | + <phase>prepare-package</phase> | ||
474 | + <goals> | ||
475 | + <goal>report</goal> | ||
476 | + </goals> | ||
477 | + </execution> | ||
478 | + </executions> | ||
479 | + </plugin> | ||
287 | </plugins> | 480 | </plugins> |
288 | </build> | 481 | </build> |
289 | 482 | ... | ... |
1 | -package org.legrog.application; | ||
2 | - | ||
3 | -import org.legrog.entities.PublisherRevision; | ||
4 | - | ||
5 | -import java.util.List; | ||
6 | - | ||
7 | -public interface PublisherRevisionService { | ||
8 | - void addPublisherRevision(PublisherRevision publisherRevision); | ||
9 | - | ||
10 | - List<PublisherRevision> getAllPublisherRevisions(); | ||
11 | - | ||
12 | - PublisherRevision getPublisherRevision(Integer publisherRevisionId); | ||
13 | -} |
1 | -package org.legrog.application; | ||
2 | - | ||
3 | -import org.legrog.entities.PublisherRevision; | ||
4 | -import org.legrog.entities.PublisherRevisionRepository; | ||
5 | - | ||
6 | -import javax.ejb.Stateless; | ||
7 | -import javax.inject.Inject; | ||
8 | -import java.util.List; | ||
9 | - | ||
10 | -@Stateless | ||
11 | -public class PublisherRevisionServiceSpring implements PublisherRevisionService { | ||
12 | - @Inject | ||
13 | - PublisherRevisionRepository publisherRevisionRepository; | ||
14 | - | ||
15 | - public void addPublisherRevision(PublisherRevision publisherRevision) { | ||
16 | - publisherRevisionRepository.save(publisherRevision); | ||
17 | - } | ||
18 | - | ||
19 | - public List<PublisherRevision> getAllPublisherRevisions() { | ||
20 | - return publisherRevisionRepository.findAll(); | ||
21 | - } | ||
22 | - | ||
23 | - public PublisherRevision getPublisherRevision(Integer publisherRevisionId) { | ||
24 | - return publisherRevisionRepository.findOne(publisherRevisionId); | ||
25 | - } | ||
26 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -package org.legrog.application; | ||
2 | - | ||
3 | - | ||
4 | -import org.legrog.entities.Publisher; | ||
5 | -import org.legrog.entities.PublisherRepository; | ||
6 | - | ||
7 | -import javax.ejb.Stateless; | ||
8 | -import javax.inject.Inject; | ||
9 | -import java.util.List; | ||
10 | - | ||
11 | -@Stateless | ||
12 | -public class PublisherServiceSpring implements PublisherService { | ||
13 | - @Inject | ||
14 | - PublisherRepository publisherRepository; | ||
15 | - | ||
16 | - public void addPublisher(Publisher publisher) { | ||
17 | - publisherRepository.save(publisher); | ||
18 | - } | ||
19 | - | ||
20 | - public List<Publisher> getAllPublishers() { | ||
21 | - return publisherRepository.findAll(); | ||
22 | - } | ||
23 | -} |
1 | -package org.legrog.application; | ||
2 | - | ||
3 | -import org.legrog.entities.User; | ||
4 | -import org.legrog.entities.UserRepository; | ||
5 | - | ||
6 | -import javax.ejb.Stateless; | ||
7 | -import javax.inject.Inject; | ||
8 | -import java.util.List; | ||
9 | - | ||
10 | -@Stateless | ||
11 | -public class UserServiceSpring implements UserService { | ||
12 | - @Inject | ||
13 | - UserRepository userRepository; | ||
14 | - | ||
15 | - public void addUser(User user) { | ||
16 | - userRepository.save(user); | ||
17 | - } | ||
18 | - | ||
19 | - public List<User> getAllUsers() { | ||
20 | - return userRepository.findAll(); | ||
21 | - } | ||
22 | - | ||
23 | - public User findUserById(int id) { | ||
24 | - return userRepository.findOne(new Integer(id)); | ||
25 | - } | ||
26 | - | ||
27 | - public void updateUser(User user) { | ||
28 | - userRepository.save(user); | ||
29 | - } | ||
30 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +package org.legrog.configuration; | ||
2 | + | ||
3 | +import org.omnifaces.filter.CharacterEncodingFilter; | ||
4 | + | ||
5 | +import javax.servlet.annotation.WebFilter; | ||
6 | + | ||
7 | +/** | ||
8 | + * ensure every request parameters (and so the content of forms in POST request) are done in utf-8 | ||
9 | + */ | ||
10 | +@WebFilter("/*") | ||
11 | +public class Utf8CharacterEncodingFilter extends CharacterEncodingFilter { | ||
12 | +} |
1 | +package org.legrog.entities; | ||
2 | + | ||
3 | +import javax.persistence.Entity; | ||
4 | +import javax.persistence.GeneratedValue; | ||
5 | +import javax.persistence.GenerationType; | ||
6 | +import javax.persistence.Id; | ||
7 | + | ||
8 | +/** | ||
9 | + * Classe des actions possibles. | ||
10 | + */ | ||
11 | +@Entity | ||
12 | +public class ActionType { | ||
13 | + @Id | ||
14 | + @GeneratedValue(strategy = GenerationType.AUTO) | ||
15 | + private int actionTypeId; | ||
16 | + | ||
17 | + private String actionTypeName; | ||
18 | + | ||
19 | + public String getActionTypeName() { | ||
20 | + return actionTypeName; | ||
21 | + } | ||
22 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -6,7 +6,7 @@ import javax.persistence.*; | ... | @@ -6,7 +6,7 @@ import javax.persistence.*; |
6 | public class Book { | 6 | public class Book { |
7 | 7 | ||
8 | @Id | 8 | @Id |
9 | - @GeneratedValue(strategy = GenerationType.AUTO) | 9 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
10 | private int bookId; | 10 | private int bookId; |
11 | private String bookTitle; | 11 | private String bookTitle; |
12 | 12 | ... | ... |
... | @@ -2,12 +2,14 @@ package org.legrog.entities; | ... | @@ -2,12 +2,14 @@ package org.legrog.entities; |
2 | 2 | ||
3 | import javax.persistence.*; | 3 | import javax.persistence.*; |
4 | 4 | ||
5 | +/* | ||
6 | + Entité persistante repésentant un pays. | ||
7 | + Simplement composée d'un identitiant et d'un libellé. | ||
8 | + */ | ||
5 | @Entity | 9 | @Entity |
6 | public class Country /* extends org.roliste.data.DbEntity */ { | 10 | public class Country /* extends org.roliste.data.DbEntity */ { |
7 | @Id | 11 | @Id |
8 | -// @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ | 12 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
9 | - @GeneratedValue(strategy = GenerationType.AUTO) | ||
10 | - @Column(name="COUNTRY_ID") | ||
11 | private int countryId; | 13 | private int countryId; |
12 | private String countryName; | 14 | private String countryName; |
13 | 15 | ||
... | @@ -27,21 +29,9 @@ public class Country /* extends org.roliste.data.DbEntity */ { | ... | @@ -27,21 +29,9 @@ public class Country /* extends org.roliste.data.DbEntity */ { |
27 | this.countryName = countryName; | 29 | this.countryName = countryName; |
28 | } | 30 | } |
29 | 31 | ||
30 | - /** | 32 | + @Override |
31 | - * Returns a string representation of this country definition. | ||
32 | - * @return a string representing this country definition. | ||
33 | - * @hidden | ||
34 | - */ | ||
35 | public String toString() | 33 | public String toString() |
36 | { | 34 | { |
37 | - StringBuilder sb = new StringBuilder(); | 35 | + return "ID_PAYS=" + countryId + " LIB_PAYS=" + countryName; |
38 | - | ||
39 | - sb.append("ID_PAYS="); | ||
40 | - sb.append(countryId); | ||
41 | - | ||
42 | - sb.append(" LIB_PAYS="); | ||
43 | - sb.append(countryName); | ||
44 | - | ||
45 | - return sb.toString(); | ||
46 | } | 36 | } |
47 | } | 37 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -6,6 +6,9 @@ package org.legrog.entities; | ... | @@ -6,6 +6,9 @@ package org.legrog.entities; |
6 | * capabilities, that may be "masked", thus shown in some specific way depending on chosen | 6 | * capabilities, that may be "masked", thus shown in some specific way depending on chosen |
7 | * NameMask. | 7 | * NameMask. |
8 | */ | 8 | */ |
9 | +/* | ||
10 | + v3 {@link org.legrog.entities.DisplayNameConfigurable} | ||
11 | + */ | ||
9 | public enum DisplayNameMask | 12 | public enum DisplayNameMask |
10 | { | 13 | { |
11 | PRENOMNOM("Prénom Nom") | 14 | PRENOMNOM("Prénom Nom") |
... | @@ -89,7 +92,7 @@ public enum DisplayNameMask | ... | @@ -89,7 +92,7 @@ public enum DisplayNameMask |
89 | 92 | ||
90 | public String getDisplayName(DisplayNameConfigurable person) | 93 | public String getDisplayName(DisplayNameConfigurable person) |
91 | { | 94 | { |
92 | - StringBuffer myResult = new StringBuffer(); | 95 | + StringBuilder myResult = new StringBuilder(); |
93 | 96 | ||
94 | if (person.getFirstName() != null) | 97 | if (person.getFirstName() != null) |
95 | { | 98 | { |
... | @@ -113,8 +116,7 @@ public enum DisplayNameMask | ... | @@ -113,8 +116,7 @@ public enum DisplayNameMask |
113 | 116 | ||
114 | private final String symbol; | 117 | private final String symbol; |
115 | 118 | ||
116 | - private DisplayNameMask(String symbol) | 119 | + DisplayNameMask(String symbol) { |
117 | - { | ||
118 | this.symbol = symbol; | 120 | this.symbol = symbol; |
119 | } | 121 | } |
120 | 122 | ... | ... |
... | @@ -2,19 +2,19 @@ package org.legrog.entities; | ... | @@ -2,19 +2,19 @@ package org.legrog.entities; |
2 | 2 | ||
3 | import javax.persistence.*; | 3 | import javax.persistence.*; |
4 | import java.util.*; | 4 | import java.util.*; |
5 | -// TODO Evaluer l'interet de ces imports | 5 | +// TODO Evaluer l'interet de cet import |
6 | -//import org.roliste.data.DbMaskableEntity; | ||
7 | //import org.roliste.data.DbValidationEntity; | 6 | //import org.roliste.data.DbValidationEntity; |
8 | 7 | ||
9 | // TODO Vérifier les extends | 8 | // TODO Vérifier les extends |
10 | -// TODO NameMask et DbMaskableEntity à traiter ensemble | 9 | +/* |
10 | + Entité persistante représentant un utilisateur. | ||
11 | + Migréee depuis la v2. | ||
12 | + */ | ||
11 | @Entity | 13 | @Entity |
12 | -@Table(name="UserTable") | 14 | +public class Person /* extends org.roliste.data.DbTraceableEntity */ implements DisplayNameConfigurable /*, DbValidationEntity */ { |
13 | -public class User /* extends org.roliste.data.DbTraceableEntity */ implements DisplayNameConfigurable /*, DbValidationEntity */ { | ||
14 | 15 | ||
15 | @Id | 16 | @Id |
16 | - @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ | 17 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
17 | - @Column(name="USER_ID") | ||
18 | private int userId; | 18 | private int userId; |
19 | 19 | ||
20 | // TODO traiter Traceable | 20 | // TODO traiter Traceable |
... | @@ -36,7 +36,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -36,7 +36,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
36 | return _traceRoot; | 36 | return _traceRoot; |
37 | } | 37 | } |
38 | */ | 38 | */ |
39 | - // TODO NameMask et DbMaskableEntity à traiter ensemble | 39 | + |
40 | /** | 40 | /** |
41 | * The mask used for user name. | 41 | * The mask used for user name. |
42 | */ | 42 | */ |
... | @@ -68,7 +68,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -68,7 +68,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
68 | * column="MASQUE_NOM_UTILISATEUR" | 68 | * column="MASQUE_NOM_UTILISATEUR" |
69 | * access="property" | 69 | * access="property" |
70 | * length="50" | 70 | * length="50" |
71 | - * @hibernate.type | 71 | + * hibernate.type |
72 | * name="org.roliste.data.util.NameMaskUserType" | 72 | * name="org.roliste.data.util.NameMaskUserType" |
73 | */ | 73 | */ |
74 | public DisplayNameMask getDisplayNameMask() { | 74 | public DisplayNameMask getDisplayNameMask() { |
... | @@ -81,7 +81,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -81,7 +81,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
81 | * see #getNameMask() | 81 | * see #getNameMask() |
82 | */ | 82 | */ |
83 | public void setDisplayNameMask(DisplayNameMask mask) { | 83 | public void setDisplayNameMask(DisplayNameMask mask) { |
84 | - mask = mask; | 84 | + this.displayNameMask = mask; |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
... | @@ -120,7 +120,6 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -120,7 +120,6 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
120 | * The {link org.roliste.data.db.UserRole}s for this user. | 120 | * The {link org.roliste.data.db.UserRole}s for this user. |
121 | */ | 121 | */ |
122 | @ManyToMany(fetch = FetchType.EAGER) | 122 | @ManyToMany(fetch = FetchType.EAGER) |
123 | - @Column(name = "USER_ROLE_ID") | ||
124 | private List<UserRole> roles; | 123 | private List<UserRole> roles; |
125 | 124 | ||
126 | /** | 125 | /** |
... | @@ -181,7 +180,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -181,7 +180,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
181 | { | 180 | { |
182 | if ((role != null) && !(getRoles().contains(role)) ) | 181 | if ((role != null) && !(getRoles().contains(role)) ) |
183 | { | 182 | { |
184 | - role.getUsers().add(this); | 183 | + role.getPersons().add(this); |
185 | getRoles().add(role); | 184 | getRoles().add(role); |
186 | } | 185 | } |
187 | } | 186 | } |
... | @@ -189,7 +188,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -189,7 +188,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
189 | */ | 188 | */ |
190 | /** | 189 | /** |
191 | * Remove the user from a given {@link UserRole}s. | 190 | * Remove the user from a given {@link UserRole}s. |
192 | - * @param role the {@link UserRole} this {@link User} will lose. Ignored if <code>null</code>. | 191 | + * @param role the {@link UserRole} this {@link Person} will lose. Ignored if <code>null</code>. |
193 | * @see #getRoles() | 192 | * @see #getRoles() |
194 | * @see #setRoles(List) | 193 | * @see #setRoles(List) |
195 | * @see #addToRole(UserRole) | 194 | * @see #addToRole(UserRole) |
... | @@ -200,7 +199,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -200,7 +199,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
200 | { | 199 | { |
201 | if ((role != null) && (getRoles().contains(role)) ) | 200 | if ((role != null) && (getRoles().contains(role)) ) |
202 | { | 201 | { |
203 | - role.getUsers().remove(this); | 202 | + role.getPersons().remove(this); |
204 | getRoles().remove(role); | 203 | getRoles().remove(role); |
205 | } | 204 | } |
206 | } | 205 | } |
... | @@ -301,7 +300,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -301,7 +300,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
301 | */ | 300 | */ |
302 | /** | 301 | /** |
303 | * Remove a book from user's collection. | 302 | * Remove a book from user's collection. |
304 | - * @param book the {@link org.roliste.data.db.BookDetails} this {@link User} will lose. Ignored if <code>null</code>. | 303 | + * @param book the {@link org.roliste.data.db.BookDetails} this {@link Person} will lose. Ignored if <code>null</code>. |
305 | * @see #getCollection() | 304 | * @see #getCollection() |
306 | * @see #setCollection(List) | 305 | * @see #setCollection(List) |
307 | * @see #addToCollection(BookDetails) | 306 | * @see #addToCollection(BookDetails) |
... | @@ -390,7 +389,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -390,7 +389,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
390 | */ | 389 | */ |
391 | /** | 390 | /** |
392 | * Remove delegation on a given {@link Traceable} from this user. | 391 | * Remove delegation on a given {@link Traceable} from this user. |
393 | - * @param object the delegation this {@link User} will lose. Ignored if <code>null</code>. | 392 | + * @param object the delegation this {@link Person} will lose. Ignored if <code>null</code>. |
394 | * @see #getDelegations() | 393 | * @see #getDelegations() |
395 | * @see #setDelegations(List) | 394 | * @see #setDelegations(List) |
396 | * @see #giveDelegation(Traceable) | 395 | * @see #giveDelegation(Traceable) |
... | @@ -426,7 +425,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -426,7 +425,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
426 | /** | 425 | /** |
427 | * The list of attributes / properties for this user. | 426 | * The list of attributes / properties for this user. |
428 | */ | 427 | */ |
429 | - @OneToMany(mappedBy = "user") | 428 | + @OneToMany(mappedBy = "person") |
430 | private List<UserAttribute> userAttributes; | 429 | private List<UserAttribute> userAttributes; |
431 | 430 | ||
432 | /** | 431 | /** |
... | @@ -773,33 +772,10 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -773,33 +772,10 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
773 | this.creationDate = date; | 772 | this.creationDate = date; |
774 | } | 773 | } |
775 | 774 | ||
776 | - /** | 775 | + @Override |
777 | - * Returns a string representation of this user definition. | ||
778 | - * @return a string representing this user definition. | ||
779 | - * hidden | ||
780 | - */ | ||
781 | public String toString() | 776 | public String toString() |
782 | { | 777 | { |
783 | - StringBuilder sb = new StringBuilder(); | 778 | + return "ID_UTILISATEUR=" + userId + " LOGIN_UTILISATEUR=" + username + " EMAIL_UTILISATEUR=" + email + |
784 | - | 779 | + " PRENOM_UTILISATEUR=" + firstName + " NOM_UTILISATEUR=" + lastName + " PSEUDO_UTILISATEUR=" + nickname; |
785 | - sb.append("ID_UTILISATEUR="); | ||
786 | - sb.append(userId); | ||
787 | - | ||
788 | - sb.append(" LOGIN_UTILISATEUR="); | ||
789 | - sb.append(username); | ||
790 | - | ||
791 | - sb.append(" EMAIL_UTILISATEUR="); | ||
792 | - sb.append(email); | ||
793 | - | ||
794 | - sb.append(" PRENOM_UTILISATEUR="); | ||
795 | - sb.append(firstName); | ||
796 | - | ||
797 | - sb.append(" NOM_UTILISATEUR="); | ||
798 | - sb.append(lastName); | ||
799 | - | ||
800 | - sb.append(" PSEUDO_UTILISATEUR="); | ||
801 | - sb.append(nickname); | ||
802 | - | ||
803 | - return sb.toString(); | ||
804 | } | 780 | } |
805 | } | 781 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -2,5 +2,5 @@ package org.legrog.entities; | ... | @@ -2,5 +2,5 @@ package org.legrog.entities; |
2 | 2 | ||
3 | import org.springframework.data.jpa.repository.JpaRepository; | 3 | import org.springframework.data.jpa.repository.JpaRepository; |
4 | 4 | ||
5 | -public interface UserRepository extends JpaRepository<User, Integer> { | 5 | +public interface PersonRepository extends JpaRepository<Person, Integer> { |
6 | } | 6 | } | ... | ... |
... | @@ -4,26 +4,27 @@ import javax.persistence.*; | ... | @@ -4,26 +4,27 @@ import javax.persistence.*; |
4 | import java.sql.Timestamp; | 4 | import java.sql.Timestamp; |
5 | import java.util.Set; | 5 | import java.util.Set; |
6 | 6 | ||
7 | +/* | ||
8 | + Entité persistante correspondant à un éditeur. | ||
9 | + Pointe vers la version valide si elle existe, ainsi que son validateur et la date de validation. | ||
10 | + Pointe vers l'ensemble de ses versions. | ||
11 | + */ | ||
7 | @Entity | 12 | @Entity |
8 | -//@Table(name = "editeur") | ||
9 | public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { | 13 | public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { |
10 | // TODO L'éventuel usage de Linkable reste à confirmer https://tree.taiga.io/project/jr-utily-grog-v3/us/48 | 14 | // TODO L'éventuel usage de Linkable reste à confirmer https://tree.taiga.io/project/jr-utily-grog-v3/us/48 |
11 | // TODO Attention, en v2 Linkable implique Traceable (journalisable) qui devrait aussi être évalué | 15 | // TODO Attention, en v2 Linkable implique Traceable (journalisable) qui devrait aussi être évalué |
12 | @Id | 16 | @Id |
13 | - @Column(name = "PUBLISHER_ID") | 17 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
14 | - @GeneratedValue(strategy = GenerationType.AUTO) | ||
15 | private int publisherId; | 18 | private int publisherId; |
16 | 19 | ||
17 | @OneToOne | 20 | @OneToOne |
18 | - private PublisherRevision activeRevision; | 21 | + private PublisherVersion validatedVersion; |
19 | 22 | ||
20 | - @OneToOne | 23 | + @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER) |
21 | - private User activeValidator; | 24 | + private Set<PublisherVersion> versions; |
22 | - | ||
23 | - private Timestamp validationDateTime; | ||
24 | 25 | ||
25 | - @OneToMany(mappedBy = "publisher") | 26 | + @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER) |
26 | - private Set<PublisherRevision> revisions; | 27 | + private Set<PublisherAction> actions; |
27 | 28 | ||
28 | public int getPublisherId() { | 29 | public int getPublisherId() { |
29 | return publisherId; | 30 | return publisherId; |
... | @@ -33,40 +34,32 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { | ... | @@ -33,40 +34,32 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { |
33 | this.publisherId = publisherId; | 34 | this.publisherId = publisherId; |
34 | } | 35 | } |
35 | 36 | ||
36 | - public PublisherRevision getActiveRevision() { | 37 | + public PublisherVersion getValidatedVersion() { |
37 | - return activeRevision; | 38 | + return validatedVersion; |
38 | - } | ||
39 | - | ||
40 | - public void setActiveRevision(PublisherRevision activeRevision) { | ||
41 | - this.activeRevision = activeRevision; | ||
42 | - } | ||
43 | - | ||
44 | - public Set<PublisherRevision> getRevisions() { | ||
45 | - return revisions; | ||
46 | } | 39 | } |
47 | 40 | ||
48 | - public void setRevisions(Set<PublisherRevision> revisions) { | 41 | + public void setValidatedVersion(PublisherVersion activeVersion) { |
49 | - this.revisions = revisions; | 42 | + this.validatedVersion = activeVersion; |
50 | } | 43 | } |
51 | 44 | ||
52 | - public User getActiveValidator() { | 45 | + public Set<PublisherVersion> getVersions() { |
53 | - return activeValidator; | 46 | + return versions; |
54 | } | 47 | } |
55 | 48 | ||
56 | - public void setActiveValidator(User activeValidator) { | 49 | + public void setVersions(Set<PublisherVersion> versions) { |
57 | - this.activeValidator = activeValidator; | 50 | + this.versions = versions; |
58 | } | 51 | } |
59 | 52 | ||
60 | - public Timestamp getValidationDateTime() { | 53 | + public Set<PublisherAction> getActions() { |
61 | - return validationDateTime; | 54 | + return actions; |
62 | } | 55 | } |
63 | 56 | ||
64 | - public void setValidationDateTime(Timestamp validationDateTime) { | 57 | + public void setActions(Set<PublisherAction> actions) { |
65 | - this.validationDateTime = validationDateTime; | 58 | + this.actions = actions; |
66 | } | 59 | } |
67 | 60 | ||
68 | @Override | 61 | @Override |
69 | public String toString() { | 62 | public String toString() { |
70 | - return "PUBLISHER_ID = " + publisherId + ", Active Revision = " + activeRevision + ", Validator = " + activeValidator + ", Validation DateTime = " + validationDateTime; | 63 | + return "PUBLISHER_ID = " + publisherId + ", Validated Version = " + validatedVersion; |
71 | } | 64 | } |
72 | } | 65 | } | ... | ... |
1 | +package org.legrog.entities; | ||
2 | + | ||
3 | +import javax.persistence.*; | ||
4 | +import java.sql.Timestamp; | ||
5 | + | ||
6 | +/** | ||
7 | + * Classe des actions sur des (versions d') éditeurs. | ||
8 | + */ | ||
9 | +@Entity | ||
10 | +public class PublisherAction { | ||
11 | + @Id | ||
12 | + @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
13 | + private int publisherActionId; | ||
14 | + | ||
15 | + @ManyToOne | ||
16 | + private ActionType actionType; | ||
17 | + @ManyToOne | ||
18 | + private Person publisherActionAuthor; | ||
19 | + @ManyToOne | ||
20 | + private PublisherVersion publisherVersion; | ||
21 | + | ||
22 | + private Timestamp publisherActionDatetime; | ||
23 | + | ||
24 | + // Accessible par publisherVersion, demande spécifique de la MOE | ||
25 | + @ManyToOne | ||
26 | + private Publisher publisher; | ||
27 | + | ||
28 | + public void setPublisherActionAuthor(Person publisherActionAuthor) { | ||
29 | + this.publisherActionAuthor = publisherActionAuthor; | ||
30 | + } | ||
31 | + | ||
32 | + public void setPublisherActionDatetime(Timestamp publisherActionDatetime) { | ||
33 | + this.publisherActionDatetime = publisherActionDatetime; | ||
34 | + } | ||
35 | + | ||
36 | + public void setActionType(ActionType actionType) { | ||
37 | + this.actionType = actionType; | ||
38 | + } | ||
39 | + | ||
40 | + public void setPublisherVersion(PublisherVersion publisherVersion) { | ||
41 | + this.publisherVersion = publisherVersion; | ||
42 | + } | ||
43 | + | ||
44 | + public void setPublisher(Publisher publisher) { | ||
45 | + this.publisher = publisher; | ||
46 | + } | ||
47 | + | ||
48 | + public ActionType getActionType() { | ||
49 | + return actionType; | ||
50 | + } | ||
51 | + | ||
52 | + public Person getPublisherActionAuthor() { | ||
53 | + return publisherActionAuthor; | ||
54 | + } | ||
55 | + | ||
56 | + public PublisherVersion getPublisherVersion() { | ||
57 | + return publisherVersion; | ||
58 | + } | ||
59 | + | ||
60 | + public Timestamp getPublisherActionDatetime() { | ||
61 | + return publisherActionDatetime; | ||
62 | + } | ||
63 | + | ||
64 | + public Publisher getPublisher() { | ||
65 | + return publisher; | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public String toString() { | ||
70 | + return "publisherActionId = " + publisherActionId + ", actionType = " + actionType + | ||
71 | + ", publisherActionAuthor = " + publisherActionAuthor + ", publisherVersion = " + publisherVersion + | ||
72 | + ", publisherActionDatetime = " + publisherActionDatetime + ", publisher = " + publisher; | ||
73 | + } | ||
74 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +package org.legrog.entities; | ||
2 | + | ||
3 | +import org.springframework.data.jpa.repository.JpaRepository; | ||
4 | +import org.springframework.data.jpa.repository.Query; | ||
5 | + | ||
6 | +public interface PublisherActionRepository extends JpaRepository<PublisherAction, Integer> { | ||
7 | + @Query("select pa from PublisherAction pa where pa.actionType = (select ua from ActionType ua where ua.actionTypeName = 'Validate') and pa.publisherActionDatetime = ( select max(pa2.publisherActionDatetime) from PublisherAction pa2 where pa2.publisher =?1)") | ||
8 | + PublisherAction publisherLastValidate(Publisher publisher); | ||
9 | +} |
1 | package org.legrog.entities; | 1 | package org.legrog.entities; |
2 | 2 | ||
3 | import javax.persistence.*; | 3 | import javax.persistence.*; |
4 | -import java.sql.Date; | ||
5 | import java.sql.Timestamp; | 4 | import java.sql.Timestamp; |
6 | 5 | ||
6 | +/* | ||
7 | + Entité persistente représentant une version d'un éditeur. | ||
8 | + Contient les données représentant un éditeur. | ||
9 | + Adresse découpée en suivant http://schema.org/PostalAddress. | ||
10 | + Pointe vers l'éditeur auquel elle correspond. | ||
11 | + Pointe vers l'auteur de la version et contient la date et heure de celle-ci. | ||
12 | + */ | ||
7 | @Entity | 13 | @Entity |
8 | -public class PublisherRevision { | 14 | +public class PublisherVersion { |
9 | @Id | 15 | @Id |
10 | - @GeneratedValue(strategy = GenerationType.AUTO) | 16 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
11 | - @Column(name = "PUBLISHER_REVISION_ID") | 17 | + private int publisherVersionId; |
12 | - private int publisherRevisionId; | ||
13 | @ManyToOne | 18 | @ManyToOne |
14 | private Publisher publisher; | 19 | private Publisher publisher; |
15 | private String publisherName; | 20 | private String publisherName; |
... | @@ -26,15 +31,15 @@ public class PublisherRevision { | ... | @@ -26,15 +31,15 @@ public class PublisherRevision { |
26 | private boolean publisherActive; | 31 | private boolean publisherActive; |
27 | private String publisherHistory; | 32 | private String publisherHistory; |
28 | @ManyToOne | 33 | @ManyToOne |
29 | - private User publisherRevisionAuthor; | 34 | + private Person publisherVersionAuthor; |
30 | - private Timestamp publisherRevisionDatetime; | 35 | + private Timestamp publisherVersionDatetime; |
31 | 36 | ||
32 | - public Timestamp getPublisherRevisionDatetime() { | 37 | + public Timestamp getPublisherVersionDatetime() { |
33 | - return publisherRevisionDatetime; | 38 | + return publisherVersionDatetime; |
34 | } | 39 | } |
35 | 40 | ||
36 | - public void setPublisherRevisionDatetime(Timestamp publisherRevisionDatetime) { | 41 | + public void setPublisherVersionDatetime(Timestamp publisherVersionDatetime) { |
37 | - this.publisherRevisionDatetime = publisherRevisionDatetime; | 42 | + this.publisherVersionDatetime = publisherVersionDatetime; |
38 | } | 43 | } |
39 | 44 | ||
40 | public boolean isPublisherActive() { | 45 | public boolean isPublisherActive() { |
... | @@ -117,12 +122,12 @@ public class PublisherRevision { | ... | @@ -117,12 +122,12 @@ public class PublisherRevision { |
117 | this.publisherURL = publisherURL; | 122 | this.publisherURL = publisherURL; |
118 | } | 123 | } |
119 | 124 | ||
120 | - public int getPublisherRevisionId() { | 125 | + public int getPublisherVersionId() { |
121 | - return publisherRevisionId; | 126 | + return publisherVersionId; |
122 | } | 127 | } |
123 | 128 | ||
124 | - public void setPublisherRevisionId(int publisherRevisionId) { | 129 | + public void setPublisherVersionId(int publisherVersionId) { |
125 | - this.publisherRevisionId = publisherRevisionId; | 130 | + this.publisherVersionId = publisherVersionId; |
126 | } | 131 | } |
127 | 132 | ||
128 | public String getPublisherName() { | 133 | public String getPublisherName() { |
... | @@ -141,21 +146,29 @@ public class PublisherRevision { | ... | @@ -141,21 +146,29 @@ public class PublisherRevision { |
141 | this.publisherAddressCountry = publisherAddressCountry; | 146 | this.publisherAddressCountry = publisherAddressCountry; |
142 | } | 147 | } |
143 | 148 | ||
144 | - public User getPublisherRevisionAuthor() { | 149 | + public Person getPublisherVersionAuthor() { |
145 | - return publisherRevisionAuthor; | 150 | + return publisherVersionAuthor; |
146 | } | 151 | } |
147 | 152 | ||
148 | - public void setPublisherRevisionAuthor(User publisherRevisionAuthor) { | 153 | + public void setPublisherVersionAuthor(Person publisherVersionAuthor) { |
149 | - this.publisherRevisionAuthor = publisherRevisionAuthor; | 154 | + this.publisherVersionAuthor = publisherVersionAuthor; |
150 | } | 155 | } |
151 | 156 | ||
152 | @Override | 157 | @Override |
153 | public String toString() { | 158 | public String toString() { |
154 | - return "PUBLISHER_REVISION_ID = " + publisherRevisionId + ", Name = " + publisherName + ", St Address = " + | 159 | + return "PUBLISHER_VERSION_ID = " + publisherVersionId + ", Name = " + publisherName + ", St Address = " + |
155 | publisherStreetAddress + ", CP = " + publisherPostalCode + ", BP = " + publisherPostOfficeBoxNumber + | 160 | publisherStreetAddress + ", CP = " + publisherPostalCode + ", BP = " + publisherPostOfficeBoxNumber + |
156 | ", Region = " + publisherAddressRegion + ", Ville = " + publisherAddressLocality + ", Pays = " + | 161 | ", Region = " + publisherAddressRegion + ", Ville = " + publisherAddressLocality + ", Pays = " + |
157 | publisherAddressCountry + ", Telephone = " + publisherTelephone + ", email = " + publisherEmail + | 162 | publisherAddressCountry + ", Telephone = " + publisherTelephone + ", email = " + publisherEmail + |
158 | ", URL = " + publisherURL + ", actif = " + publisherActive + ", History = " + publisherHistory + | 163 | ", URL = " + publisherURL + ", actif = " + publisherActive + ", History = " + publisherHistory + |
159 | - ", Revision Author = " + publisherRevisionAuthor + ", Revision DateTime = " + publisherRevisionDatetime; | 164 | + ", Version Author = " + publisherVersionAuthor + ", Version DateTime = " + publisherVersionDatetime; |
165 | + } | ||
166 | + | ||
167 | + public Publisher getPublisher() { | ||
168 | + return publisher; | ||
169 | + } | ||
170 | + | ||
171 | + public void setPublisher(Publisher publisher) { | ||
172 | + this.publisher = publisher; | ||
160 | } | 173 | } |
161 | } | 174 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -2,5 +2,5 @@ package org.legrog.entities; | ... | @@ -2,5 +2,5 @@ package org.legrog.entities; |
2 | 2 | ||
3 | import org.springframework.data.jpa.repository.JpaRepository; | 3 | import org.springframework.data.jpa.repository.JpaRepository; |
4 | 4 | ||
5 | -public interface PublisherRevisionRepository extends JpaRepository<PublisherRevision, Integer> { | 5 | +public interface PublisherVersionRepository extends JpaRepository<PublisherVersion, Integer> { |
6 | } | 6 | } | ... | ... |
... | @@ -2,10 +2,14 @@ package org.legrog.entities; | ... | @@ -2,10 +2,14 @@ package org.legrog.entities; |
2 | 2 | ||
3 | import javax.persistence.*; | 3 | import javax.persistence.*; |
4 | 4 | ||
5 | +/* | ||
6 | + Entité persistante représentant les propriétés qui sont paramétrées pour un utilisateur. | ||
7 | + Migréee depuis la v2. | ||
8 | + */ | ||
5 | @Entity | 9 | @Entity |
6 | public class UserAttribute { | 10 | public class UserAttribute { |
7 | @Id | 11 | @Id |
8 | - @GeneratedValue(strategy = GenerationType.AUTO) | 12 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
9 | private int userAttributeId; | 13 | private int userAttributeId; |
10 | 14 | ||
11 | public int getUserAttributeId() { | 15 | public int getUserAttributeId() { |
... | @@ -13,49 +17,47 @@ public class UserAttribute { | ... | @@ -13,49 +17,47 @@ public class UserAttribute { |
13 | } | 17 | } |
14 | 18 | ||
15 | /** | 19 | /** |
16 | - * The linked user. | 20 | + * The linked person. |
17 | */ | 21 | */ |
18 | @ManyToOne | 22 | @ManyToOne |
19 | - @JoinColumn(name = "USER_ID") | 23 | + private Person person; |
20 | - private User user; | ||
21 | 24 | ||
22 | /** | 25 | /** |
23 | - * Retrieve the user this attribute is attached to. | 26 | + * Retrieve the person this attribute is attached to. |
24 | - * @hibernate.many-to-one | 27 | + * hibernate.many-to-one |
25 | * column="ID_UTILISATEUR" | 28 | * column="ID_UTILISATEUR" |
26 | - * class="org.roliste.data.db.User" | 29 | + * class="org.roliste.data.db.Person" |
27 | * not-null="true" | 30 | * not-null="true" |
28 | * access="property" | 31 | * access="property" |
29 | * lazy="proxy" | 32 | * lazy="proxy" |
30 | * properties-name="PropertyPerUser" | 33 | * properties-name="PropertyPerUser" |
31 | * foreign-key="FK_ATTRIBUTUTILISATEUR_UTILISATEUR" | 34 | * foreign-key="FK_ATTRIBUTUTILISATEUR_UTILISATEUR" |
32 | - * @return the {link org.roliste.data.db.User} this attribute is attached to. | 35 | + * @return the {link org.roliste.data.db.Person} this attribute is attached to. |
33 | * Shall not be <code>null</code>. | 36 | * Shall not be <code>null</code>. |
34 | - * see #setUser(org.roliste.data.db.User) | 37 | + * see #setPerson(org.roliste.data.db.Person) |
35 | */ | 38 | */ |
36 | - public User getUser() { | 39 | + public Person getPerson() { |
37 | - return user; | 40 | + return person; |
38 | } | 41 | } |
39 | 42 | ||
40 | /** | 43 | /** |
41 | - * Set the user this attribute is attached to. | 44 | + * Set the person this attribute is attached to. |
42 | - * @param user the new {link org.roliste.data.db.User} this attribute will be attached to. Shall not be <code>null</code>. | 45 | + * @param person the new {link org.roliste.data.db.Person} this attribute will be attached to. Shall not be <code>null</code>. |
43 | - * @see #getUser() | 46 | + * @see #getPerson() |
44 | */ | 47 | */ |
45 | - public void setUser(User user) { | 48 | + public void setPerson(Person person) { |
46 | - this.user = user; | 49 | + this.person = person; |
47 | } | 50 | } |
48 | 51 | ||
49 | /** | 52 | /** |
50 | * The linked property. | 53 | * The linked property. |
51 | */ | 54 | */ |
52 | @ManyToOne | 55 | @ManyToOne |
53 | - @JoinColumn(name = "USER_PROPERTY_ID") | ||
54 | private UserProperty userProperty; | 56 | private UserProperty userProperty; |
55 | 57 | ||
56 | /** | 58 | /** |
57 | * Retrieve the property this attribute is attached to. | 59 | * Retrieve the property this attribute is attached to. |
58 | - * @hibernate.many-to-one | 60 | + * hibernate.many-to-one |
59 | * column="ID_PROP" | 61 | * column="ID_PROP" |
60 | * class="org.roliste.data.db.UserProperty" | 62 | * class="org.roliste.data.db.UserProperty" |
61 | * not-null="true" | 63 | * not-null="true" |
... | @@ -91,7 +93,7 @@ public class UserAttribute { | ... | @@ -91,7 +93,7 @@ public class UserAttribute { |
91 | * convert it yourself. May be <code>null</code>, in cases where the sole existence of the attribute | 93 | * convert it yourself. May be <code>null</code>, in cases where the sole existence of the attribute |
92 | * is the value, or for unset attributes. | 94 | * is the value, or for unset attributes. |
93 | * @see #setValue(String) | 95 | * @see #setValue(String) |
94 | - * @hibernate.property | 96 | + * hibernate.property |
95 | * column="ATTR_VALUE" | 97 | * column="ATTR_VALUE" |
96 | * access="property" | 98 | * access="property" |
97 | * length="200" | 99 | * length="200" |
... | @@ -110,24 +112,14 @@ public class UserAttribute { | ... | @@ -110,24 +112,14 @@ public class UserAttribute { |
110 | } | 112 | } |
111 | 113 | ||
112 | /** | 114 | /** |
113 | - * Returns a string representation of this user attribute definition. | 115 | + * Returns a string representation of this person attribute definition. |
114 | - * @return a string representing this user attribute definition. | 116 | + * @return a string representing this person attribute definition. |
115 | - * @hidden | 117 | + * hidden |
116 | */ | 118 | */ |
119 | + @Override | ||
117 | public String toString() | 120 | public String toString() |
118 | { | 121 | { |
119 | - StringBuilder sb = new StringBuilder(); | 122 | + return "ID_ATTR=" + getUserAttributeId() + " ATTR_PROP=" + userProperty + " ATTR_VALUE=" + value; |
120 | - | ||
121 | - sb.append("ID_ATTR="); | ||
122 | - sb.append(getUserAttributeId()); | ||
123 | - | ||
124 | - sb.append(" ATTR_PROP="); | ||
125 | - sb.append(userProperty); | ||
126 | - | ||
127 | - sb.append(" ATTR_VALUE="); | ||
128 | - sb.append(value); | ||
129 | - | ||
130 | - return sb.toString(); | ||
131 | } | 123 | } |
132 | 124 | ||
133 | } | 125 | } | ... | ... |
... | @@ -2,11 +2,14 @@ package org.legrog.entities; | ... | @@ -2,11 +2,14 @@ package org.legrog.entities; |
2 | 2 | ||
3 | import javax.persistence.*; | 3 | import javax.persistence.*; |
4 | 4 | ||
5 | +/* | ||
6 | + Entité persistente représentant la codification des propriétés qui peuvent être paramétrées pour un utilisateur. | ||
7 | + Importée depuis la v2. | ||
8 | + */ | ||
5 | @Entity | 9 | @Entity |
6 | public class UserProperty { | 10 | public class UserProperty { |
7 | @Id | 11 | @Id |
8 | @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ | 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ |
9 | - @Column(name="USER_PROPERTY_ID") | ||
10 | private int userPropertyId; | 13 | private int userPropertyId; |
11 | 14 | ||
12 | /** | 15 | /** |
... | @@ -110,23 +113,11 @@ public class UserProperty { | ... | @@ -110,23 +113,11 @@ public class UserProperty { |
110 | * @return a string representing this property definition. | 113 | * @return a string representing this property definition. |
111 | * hidden | 114 | * hidden |
112 | */ | 115 | */ |
116 | + @Override | ||
113 | public String toString() | 117 | public String toString() |
114 | { | 118 | { |
115 | - StringBuilder sb = new StringBuilder(); | ||
116 | - | ||
117 | - sb.append("ID_PROP="); | ||
118 | - sb.append(getUserPropertyId()); | ||
119 | - | ||
120 | - sb.append(" PROP_NAME="); | ||
121 | - sb.append(name); | ||
122 | - | ||
123 | - sb.append(" PROP_TAG="); | ||
124 | - sb.append(tag); | ||
125 | - | ||
126 | - sb.append(" IND_VISIBLE="); | ||
127 | - sb.append(visible); | ||
128 | 119 | ||
129 | - return sb.toString(); | 120 | + return "ID_PROP=" + getUserPropertyId() + "PROP_NAME=" + name + " PROP_TAG=" + tag + " IND_VISIBLE=" + visible; |
130 | } | 121 | } |
131 | 122 | ||
132 | } | 123 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -7,20 +7,22 @@ import javax.persistence.*; | ... | @@ -7,20 +7,22 @@ import javax.persistence.*; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * The database representation of a user role or group. | 9 | * The database representation of a user role or group. |
10 | - * A given {@link User} may be part of one or more {@link UserRole}. | 10 | + * A given {@link Person} may be part of one or more {@link UserRole}. |
11 | * <br/> | 11 | * <br/> |
12 | * Warning: due to laziness of mapped objects, private attributes of all DB entities shall never be used directly. | 12 | * Warning: due to laziness of mapped objects, private attributes of all DB entities shall never be used directly. |
13 | * You shall always use the getter/setter methods. | 13 | * You shall always use the getter/setter methods. |
14 | * alias UserRole | 14 | * alias UserRole |
15 | * | 15 | * |
16 | */ | 16 | */ |
17 | +/* | ||
18 | + Importé depuis la v2. | ||
19 | + */ | ||
17 | @Entity | 20 | @Entity |
18 | // TODO évaluer extend v2 | 21 | // TODO évaluer extend v2 |
19 | public class UserRole /* extends org.roliste.data.DbEntity */ | 22 | public class UserRole /* extends org.roliste.data.DbEntity */ |
20 | { | 23 | { |
21 | @Id | 24 | @Id |
22 | - @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ | 25 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
23 | - @Column(name="USER_ROLE_ID") | ||
24 | private int userRoleId; | 26 | private int userRoleId; |
25 | 27 | ||
26 | /** | 28 | /** |
... | @@ -29,11 +31,10 @@ public class UserRole /* extends org.roliste.data.DbEntity */ | ... | @@ -29,11 +31,10 @@ public class UserRole /* extends org.roliste.data.DbEntity */ |
29 | private String rolename; | 31 | private String rolename; |
30 | 32 | ||
31 | /** | 33 | /** |
32 | - * The {@link User}s for this user role. | 34 | + * The {@link Person}s for this user role. |
33 | */ | 35 | */ |
34 | @ManyToMany(mappedBy = "roles") | 36 | @ManyToMany(mappedBy = "roles") |
35 | - @Column(name = "USER_ID") | 37 | + private Set<Person> persons; |
36 | - private Set<User> users; | ||
37 | 38 | ||
38 | /** | 39 | /** |
39 | * Builds a new and empty user role definition. | 40 | * Builds a new and empty user role definition. |
... | @@ -46,7 +47,7 @@ public class UserRole /* extends org.roliste.data.DbEntity */ | ... | @@ -46,7 +47,7 @@ public class UserRole /* extends org.roliste.data.DbEntity */ |
46 | rolename = null; | 47 | rolename = null; |
47 | visible = true; | 48 | visible = true; |
48 | // no need to synchronize this | 49 | // no need to synchronize this |
49 | - users = new HashSet<User>(); | 50 | + persons = new HashSet<Person>(); |
50 | } | 51 | } |
51 | 52 | ||
52 | public int getUserRoleId() { | 53 | public int getUserRoleId() { |
... | @@ -89,7 +90,7 @@ public class UserRole /* extends org.roliste.data.DbEntity */ | ... | @@ -89,7 +90,7 @@ public class UserRole /* extends org.roliste.data.DbEntity */ |
89 | 90 | ||
90 | /** | 91 | /** |
91 | * Indicates if the role is visible. | 92 | * Indicates if the role is visible. |
92 | - * If not, users should not be able to access the privileges | 93 | + * If not, persons should not be able to access the privileges |
93 | * they inherit from being part of this role. | 94 | * they inherit from being part of this role. |
94 | * @return the visible flag. | 95 | * @return the visible flag. |
95 | * @see #setVisible(boolean) | 96 | * @see #setVisible(boolean) |
... | @@ -111,15 +112,15 @@ public class UserRole /* extends org.roliste.data.DbEntity */ | ... | @@ -111,15 +112,15 @@ public class UserRole /* extends org.roliste.data.DbEntity */ |
111 | } | 112 | } |
112 | 113 | ||
113 | /** | 114 | /** |
114 | - * Retrieves the list of {@link User}s for this user role. | 115 | + * Retrieves the list of {@link Person}s for this user role. |
115 | * SHALL be used as a read-only attribute. In particular, avoid | 116 | * SHALL be used as a read-only attribute. In particular, avoid |
116 | * using {@link Set#add(Object)} or {@link Set#remove(Object)} on | 117 | * using {@link Set#add(Object)} or {@link Set#remove(Object)} on |
117 | * the returned value without caution. | 118 | * the returned value without caution. |
118 | - * @return a {@link Set} of {@link User}. May be <code>null</code>. | 119 | + * @return a {@link Set} of {@link Person}. May be <code>null</code>. |
119 | - * @see #setUsers(Set) | 120 | + * @see #setPersons(Set) |
120 | * hibernate.many-to-many | 121 | * hibernate.many-to-many |
121 | * column="UTILISATEUR_FK" | 122 | * column="UTILISATEUR_FK" |
122 | - * class="org.roliste.data.db.User" | 123 | + * class="org.roliste.data.db.Person" |
123 | * foreign-key="FK_UTILISATEURROLE_UTILISATEUR" | 124 | * foreign-key="FK_UTILISATEURROLE_UTILISATEUR" |
124 | * hibernate.key | 125 | * hibernate.key |
125 | * column="ROLE_FK" | 126 | * column="ROLE_FK" |
... | @@ -131,18 +132,18 @@ public class UserRole /* extends org.roliste.data.DbEntity */ | ... | @@ -131,18 +132,18 @@ public class UserRole /* extends org.roliste.data.DbEntity */ |
131 | * lazy="true" | 132 | * lazy="true" |
132 | * inverse="true" | 133 | * inverse="true" |
133 | */ | 134 | */ |
134 | - public Set<User> getUsers() { | 135 | + public Set<Person> getPersons() { |
135 | - return users; | 136 | + return persons; |
136 | } | 137 | } |
137 | 138 | ||
138 | /** | 139 | /** |
139 | - * Sets the list of {@link User}s for this user role. | 140 | + * Sets the list of {@link Person}s for this user role. |
140 | - * @param users the new {@link Set} of {@link User}s. May be | 141 | + * @param persons the new {@link Set} of {@link Person}s. May be |
141 | * <code>null</code> (we don't handle the relation from this side). | 142 | * <code>null</code> (we don't handle the relation from this side). |
142 | - * @see #getUsers() | 143 | + * @see #getPersons() |
143 | */ | 144 | */ |
144 | - protected void setUsers(Set<User> users) { | 145 | + protected void setPersons(Set<Person> persons) { |
145 | - this.users = users; | 146 | + this.persons = persons; |
146 | } | 147 | } |
147 | 148 | ||
148 | /** | 149 | /** |
... | @@ -150,19 +151,8 @@ public class UserRole /* extends org.roliste.data.DbEntity */ | ... | @@ -150,19 +151,8 @@ public class UserRole /* extends org.roliste.data.DbEntity */ |
150 | * @return a string representing this user role definition. | 151 | * @return a string representing this user role definition. |
151 | * hidden | 152 | * hidden |
152 | */ | 153 | */ |
153 | - public String toString() | 154 | + @Override |
154 | - { | 155 | + public String toString() { |
155 | - StringBuilder sb = new StringBuilder(); | 156 | + return "ID_ROLE=" + getUserRoleId() + " NOM_ROLE=" + rolename + " IND_VISIBLE=" + visible; |
156 | - | ||
157 | - sb.append("ID_ROLE="); | ||
158 | - sb.append(getUserRoleId()); | ||
159 | - | ||
160 | - sb.append(" NOM_ROLE="); | ||
161 | - sb.append(rolename); | ||
162 | - | ||
163 | - sb.append(" IND_VISIBLE="); | ||
164 | - sb.append(visible); | ||
165 | - | ||
166 | - return sb.toString(); | ||
167 | } | 157 | } |
168 | } | 158 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | -package org.legrog.presentation; | ||
2 | - | ||
3 | -import org.legrog.application.PublisherRevisionService; | ||
4 | -import org.legrog.application.PublisherService; | ||
5 | -import org.legrog.application.SharedService; | ||
6 | -import org.legrog.application.UserService; | ||
7 | -import org.legrog.entities.Country; | ||
8 | -import org.legrog.entities.Publisher; | ||
9 | -import org.legrog.entities.PublisherRevision; | ||
10 | -import org.legrog.entities.User; | ||
11 | -import org.slf4j.Logger; | ||
12 | -import org.slf4j.LoggerFactory; | ||
13 | - | ||
14 | -import javax.annotation.PostConstruct; | ||
15 | -import javax.enterprise.context.RequestScoped; | ||
16 | -import javax.inject.Inject; | ||
17 | -import javax.inject.Named; | ||
18 | -import java.util.Date; | ||
19 | -import java.sql.Timestamp; | ||
20 | -import java.time.ZoneId; | ||
21 | -import java.util.HashSet; | ||
22 | -import java.util.List; | ||
23 | -import java.util.Random; | ||
24 | - | ||
25 | -@Named | ||
26 | -@RequestScoped | ||
27 | -public class AddPublisherBean { | ||
28 | - Logger logger = LoggerFactory.getLogger(getClass()); | ||
29 | - | ||
30 | - @Inject | ||
31 | - private SharedService sharedService; | ||
32 | - @Inject | ||
33 | - private UserService userService; | ||
34 | - @Inject | ||
35 | - private PublisherService publisherService; | ||
36 | - @Inject | ||
37 | - private PublisherRevisionService publisherRevisionService; | ||
38 | - | ||
39 | - private String publisherName; | ||
40 | - private String publisherStreetAddress; | ||
41 | - private String publisherPostalCode; | ||
42 | - private String publisherPostOfficeBoxNumber; | ||
43 | - private String publisherAddressRegion; | ||
44 | - private String publisherAddressLocality; | ||
45 | - private Country publisherAddressCountry; | ||
46 | - private String publisherTelephone; | ||
47 | - private String publisherEmail; | ||
48 | - private String publisherURL; | ||
49 | - private boolean publisherActive; | ||
50 | - private String publisherHistory; | ||
51 | - | ||
52 | - private List<Country> availableCountries; | ||
53 | - | ||
54 | - public String add() { | ||
55 | - logger.info("add"); | ||
56 | - Publisher publisher = new Publisher(); | ||
57 | - PublisherRevision publisherRevision = new PublisherRevision(); | ||
58 | - HashSet<PublisherRevision> publisherRevisions = new HashSet<PublisherRevision>(); | ||
59 | - publisherRevisions.add(publisherRevision); | ||
60 | - publisher.setRevisions(publisherRevisions); | ||
61 | - logger.info(publisher.toString()); | ||
62 | - publisherRevision.setPublisherActive(publisherActive); | ||
63 | - publisherRevision.setPublisherAddressCountry(publisherAddressCountry); | ||
64 | - publisherRevision.setPublisherAddressLocality(publisherAddressLocality); | ||
65 | - publisherRevision.setPublisherAddressRegion(publisherAddressRegion); | ||
66 | - publisherRevision.setPublisherAddressLocality(publisherAddressLocality); | ||
67 | - publisherRevision.setPublisherEmail(publisherEmail); | ||
68 | - publisherRevision.setPublisherHistory(publisherHistory); | ||
69 | - publisherRevision.setPublisherName(publisherName); | ||
70 | - publisherRevision.setPublisherPostalCode(publisherPostalCode); | ||
71 | - publisherRevision.setPublisherPostOfficeBoxNumber(publisherPostOfficeBoxNumber); | ||
72 | - publisherRevision.setPublisherStreetAddress(publisherStreetAddress); | ||
73 | - publisherRevision.setPublisherTelephone(publisherTelephone); | ||
74 | - publisherRevision.setPublisherURL(publisherURL); | ||
75 | - | ||
76 | - publisherRevision.setPublisherRevisionDatetime(new Timestamp(new Date().getTime())); | ||
77 | - | ||
78 | - // TODO Remplacer l'astuce par une vraie récupération de l'utilisateur | ||
79 | - List<User> users = userService.getAllUsers(); | ||
80 | - Random random = new Random(); | ||
81 | - User user = users.get(random.nextInt(users.size())); | ||
82 | - // End TODO | ||
83 | - publisherRevision.setPublisherRevisionAuthor(user); | ||
84 | - logger.info(publisherRevision.toString()); | ||
85 | - publisherRevisionService.addPublisherRevision(publisherRevision); | ||
86 | - publisherService.addPublisher(publisher); | ||
87 | - // Test de récupération de l'Id | ||
88 | - logger.info(publisherRevision.toString()); | ||
89 | - return "success"; | ||
90 | - } | ||
91 | - | ||
92 | - @PostConstruct | ||
93 | - public void init() { | ||
94 | - availableCountries = sharedService.getAllCountries(); | ||
95 | - } | ||
96 | - | ||
97 | - public String getPublisherName() { | ||
98 | - return publisherName; | ||
99 | - } | ||
100 | - | ||
101 | - public void setPublisherName(String publisherName) { | ||
102 | - this.publisherName = publisherName; | ||
103 | - } | ||
104 | - | ||
105 | - public String getPublisherStreetAddress() { | ||
106 | - return publisherStreetAddress; | ||
107 | - } | ||
108 | - | ||
109 | - public void setPublisherStreetAddress(String publisherStreetAddress) { | ||
110 | - this.publisherStreetAddress = publisherStreetAddress; | ||
111 | - } | ||
112 | - | ||
113 | - public String getPublisherPostalCode() { | ||
114 | - return publisherPostalCode; | ||
115 | - } | ||
116 | - | ||
117 | - public void setPublisherPostalCode(String publisherPostalCode) { | ||
118 | - this.publisherPostalCode = publisherPostalCode; | ||
119 | - } | ||
120 | - | ||
121 | - public String getPublisherPostOfficeBoxNumber() { | ||
122 | - return publisherPostOfficeBoxNumber; | ||
123 | - } | ||
124 | - | ||
125 | - public void setPublisherPostOfficeBoxNumber(String publisherPostOfficeBoxNumber) { | ||
126 | - this.publisherPostOfficeBoxNumber = publisherPostOfficeBoxNumber; | ||
127 | - } | ||
128 | - | ||
129 | - public String getPublisherAddressRegion() { | ||
130 | - return publisherAddressRegion; | ||
131 | - } | ||
132 | - | ||
133 | - public void setPublisherAddressRegion(String publisherAddressRegion) { | ||
134 | - this.publisherAddressRegion = publisherAddressRegion; | ||
135 | - } | ||
136 | - | ||
137 | - public String getPublisherAddressLocality() { | ||
138 | - return publisherAddressLocality; | ||
139 | - } | ||
140 | - | ||
141 | - public void setPublisherAddressLocality(String publisherAddressLocality) { | ||
142 | - this.publisherAddressLocality = publisherAddressLocality; | ||
143 | - } | ||
144 | - | ||
145 | - public Country getPublisherAddressCountry() { | ||
146 | - return publisherAddressCountry; | ||
147 | - } | ||
148 | - | ||
149 | - public void setPublisherAddressCountry(Country publisherAddressCountry) { | ||
150 | - this.publisherAddressCountry = publisherAddressCountry; | ||
151 | - } | ||
152 | - | ||
153 | - public String getPublisherTelephone() { | ||
154 | - return publisherTelephone; | ||
155 | - } | ||
156 | - | ||
157 | - public void setPublisherTelephone(String publisherTelephone) { | ||
158 | - this.publisherTelephone = publisherTelephone; | ||
159 | - } | ||
160 | - | ||
161 | - public String getPublisherEmail() { | ||
162 | - return publisherEmail; | ||
163 | - } | ||
164 | - | ||
165 | - public void setPublisherEmail(String publisherEmail) { | ||
166 | - this.publisherEmail = publisherEmail; | ||
167 | - } | ||
168 | - | ||
169 | - public String getPublisherURL() { | ||
170 | - return publisherURL; | ||
171 | - } | ||
172 | - | ||
173 | - public void setPublisherURL(String publisherURL) { | ||
174 | - this.publisherURL = publisherURL; | ||
175 | - } | ||
176 | - | ||
177 | - public boolean isPublisherActive() { | ||
178 | - return publisherActive; | ||
179 | - } | ||
180 | - | ||
181 | - public void setPublisherActive(boolean publisherActive) { | ||
182 | - this.publisherActive = publisherActive; | ||
183 | - } | ||
184 | - | ||
185 | - public String getPublisherHistory() { | ||
186 | - return publisherHistory; | ||
187 | - } | ||
188 | - | ||
189 | - public void setPublisherHistory(String publisherHistory) { | ||
190 | - this.publisherHistory = publisherHistory; | ||
191 | - } | ||
192 | - | ||
193 | - public List<Country> getAvailableCountries() { | ||
194 | - return availableCountries; | ||
195 | - } | ||
196 | - | ||
197 | - public void setAvailableCountries(List<Country> availableCountries) { | ||
198 | - this.availableCountries = availableCountries; | ||
199 | - } | ||
200 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -package org.legrog.presentation; | ||
2 | - | ||
3 | -import org.legrog.application.PublisherRevisionService; | ||
4 | -import org.legrog.application.PublisherService; | ||
5 | -import org.legrog.entities.Publisher; | ||
6 | -import org.legrog.entities.PublisherRevision; | ||
7 | - | ||
8 | -import javax.annotation.PostConstruct; | ||
9 | -import javax.enterprise.context.RequestScoped; | ||
10 | -import javax.inject.Inject; | ||
11 | -import javax.inject.Named; | ||
12 | -import java.util.List; | ||
13 | - | ||
14 | -@Named | ||
15 | -@RequestScoped | ||
16 | -public class ListPublisherRevisionsBean { | ||
17 | - @Inject | ||
18 | - PublisherRevisionService publisherRevisionService; | ||
19 | - | ||
20 | - private List<PublisherRevision> publisherRevisions; | ||
21 | - | ||
22 | - public List<PublisherRevision> getPublisherRevisions() { | ||
23 | - return publisherRevisions; | ||
24 | - } | ||
25 | - | ||
26 | - @PostConstruct | ||
27 | - public void init() { | ||
28 | - publisherRevisions = publisherRevisionService.getAllPublisherRevisions(); | ||
29 | - } | ||
30 | - | ||
31 | -} |
1 | -package org.legrog.presentation; | ||
2 | - | ||
3 | -import org.legrog.application.PublisherRevisionService; | ||
4 | -import org.legrog.entities.Country; | ||
5 | -import org.legrog.entities.PublisherRevision; | ||
6 | -import org.legrog.entities.User; | ||
7 | -import org.slf4j.Logger; | ||
8 | -import org.slf4j.LoggerFactory; | ||
9 | - | ||
10 | -import javax.faces.view.ViewScoped; | ||
11 | -import javax.inject.Inject; | ||
12 | -import javax.inject.Named; | ||
13 | -import java.io.Serializable; | ||
14 | -import java.sql.Timestamp; | ||
15 | - | ||
16 | -@Named | ||
17 | -@ViewScoped | ||
18 | -public class PublisherRevisionView implements Serializable { | ||
19 | - Logger logger = LoggerFactory.getLogger(getClass()); | ||
20 | - | ||
21 | - @Inject | ||
22 | - PublisherRevisionService publisherRevisionService; | ||
23 | - | ||
24 | - private int publisherRevisionId; | ||
25 | - private String publisherName; | ||
26 | - private String publisherStreetAddress; | ||
27 | - private String publisherPostalCode; | ||
28 | - private String publisherPostOfficeBoxNumber; | ||
29 | - private String publisherAddressRegion; | ||
30 | - private String publisherAddressLocality; | ||
31 | - private Country publisherAddressCountry; | ||
32 | - private String publisherTelephone; | ||
33 | - private String publisherEmail; | ||
34 | - private String publisherURL; | ||
35 | - private boolean publisherActive; | ||
36 | - private String publisherHistory; | ||
37 | - private User publisherRevisionAuthor; | ||
38 | - private Timestamp publisherRevisionDatetime; | ||
39 | - | ||
40 | - public void loadData() { | ||
41 | - logger.debug("publisherRevisionId = {}", this.publisherRevisionId); | ||
42 | - | ||
43 | - PublisherRevision publisherRevision = publisherRevisionService.getPublisherRevision(publisherRevisionId); | ||
44 | - | ||
45 | - logger.debug("Found a publisher revision : {}", publisherRevision.toString()); | ||
46 | - | ||
47 | - | ||
48 | -// Map<String,String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); | ||
49 | -// | ||
50 | -// PublisherRevision publisherRevision = publisherRevisionService.getPublisherRevision(new Integer(params.get("publisherRevisionId"))); | ||
51 | -// setPublisherRevisionId(publisherRevision.getPublisherRevisionId()); | ||
52 | -// logger.info("publisherRevisionId = " + getPublisherRevisionId()); | ||
53 | - } | ||
54 | - | ||
55 | - public int getPublisherRevisionId() { | ||
56 | - return publisherRevisionId; | ||
57 | - } | ||
58 | - | ||
59 | - public void setPublisherRevisionId(int publisherRevisionId) { | ||
60 | - this.publisherRevisionId = publisherRevisionId; | ||
61 | - } | ||
62 | - | ||
63 | - public String getPublisherName() { | ||
64 | - return publisherName; | ||
65 | - } | ||
66 | - | ||
67 | - public void setPublisherName(String publisherName) { | ||
68 | - this.publisherName = publisherName; | ||
69 | - } | ||
70 | - | ||
71 | - public String getPublisherStreetAddress() { | ||
72 | - return publisherStreetAddress; | ||
73 | - } | ||
74 | - | ||
75 | - public void setPublisherStreetAddress(String publisherStreetAddress) { | ||
76 | - this.publisherStreetAddress = publisherStreetAddress; | ||
77 | - } | ||
78 | - | ||
79 | - public String getPublisherPostalCode() { | ||
80 | - return publisherPostalCode; | ||
81 | - } | ||
82 | - | ||
83 | - public void setPublisherPostalCode(String publisherPostalCode) { | ||
84 | - this.publisherPostalCode = publisherPostalCode; | ||
85 | - } | ||
86 | - | ||
87 | - public String getPublisherPostOfficeBoxNumber() { | ||
88 | - return publisherPostOfficeBoxNumber; | ||
89 | - } | ||
90 | - | ||
91 | - public void setPublisherPostOfficeBoxNumber(String publisherPostOfficeBoxNumber) { | ||
92 | - this.publisherPostOfficeBoxNumber = publisherPostOfficeBoxNumber; | ||
93 | - } | ||
94 | - | ||
95 | - public String getPublisherAddressRegion() { | ||
96 | - return publisherAddressRegion; | ||
97 | - } | ||
98 | - | ||
99 | - public void setPublisherAddressRegion(String publisherAddressRegion) { | ||
100 | - this.publisherAddressRegion = publisherAddressRegion; | ||
101 | - } | ||
102 | - | ||
103 | - public String getPublisherAddressLocality() { | ||
104 | - return publisherAddressLocality; | ||
105 | - } | ||
106 | - | ||
107 | - public void setPublisherAddressLocality(String publisherAddressLocality) { | ||
108 | - this.publisherAddressLocality = publisherAddressLocality; | ||
109 | - } | ||
110 | - | ||
111 | - public Country getPublisherAddressCountry() { | ||
112 | - return publisherAddressCountry; | ||
113 | - } | ||
114 | - | ||
115 | - public void setPublisherAddressCountry(Country publisherAddressCountry) { | ||
116 | - this.publisherAddressCountry = publisherAddressCountry; | ||
117 | - } | ||
118 | - | ||
119 | - public String getPublisherTelephone() { | ||
120 | - return publisherTelephone; | ||
121 | - } | ||
122 | - | ||
123 | - public void setPublisherTelephone(String publisherTelephone) { | ||
124 | - this.publisherTelephone = publisherTelephone; | ||
125 | - } | ||
126 | - | ||
127 | - public String getPublisherEmail() { | ||
128 | - return publisherEmail; | ||
129 | - } | ||
130 | - | ||
131 | - public void setPublisherEmail(String publisherEmail) { | ||
132 | - this.publisherEmail = publisherEmail; | ||
133 | - } | ||
134 | - | ||
135 | - public String getPublisherURL() { | ||
136 | - return publisherURL; | ||
137 | - } | ||
138 | - | ||
139 | - public void setPublisherURL(String publisherURL) { | ||
140 | - this.publisherURL = publisherURL; | ||
141 | - } | ||
142 | - | ||
143 | - public boolean isPublisherActive() { | ||
144 | - return publisherActive; | ||
145 | - } | ||
146 | - | ||
147 | - public void setPublisherActive(boolean publisherActive) { | ||
148 | - this.publisherActive = publisherActive; | ||
149 | - } | ||
150 | - | ||
151 | - public String getPublisherHistory() { | ||
152 | - return publisherHistory; | ||
153 | - } | ||
154 | - | ||
155 | - public void setPublisherHistory(String publisherHistory) { | ||
156 | - this.publisherHistory = publisherHistory; | ||
157 | - } | ||
158 | - | ||
159 | - public User getPublisherRevisionAuthor() { | ||
160 | - return publisherRevisionAuthor; | ||
161 | - } | ||
162 | - | ||
163 | - public void setPublisherRevisionAuthor(User publisherRevisionAuthor) { | ||
164 | - this.publisherRevisionAuthor = publisherRevisionAuthor; | ||
165 | - } | ||
166 | - | ||
167 | - public Timestamp getPublisherRevisionDatetime() { | ||
168 | - return publisherRevisionDatetime; | ||
169 | - } | ||
170 | - | ||
171 | - public void setPublisherRevisionDatetime(Timestamp publisherRevisionDatetime) { | ||
172 | - this.publisherRevisionDatetime = publisherRevisionDatetime; | ||
173 | - } | ||
174 | -} |
1 | -package org.legrog.application; | 1 | +package org.legrog.web.book; |
2 | 2 | ||
3 | import org.legrog.entities.Book; | 3 | import org.legrog.entities.Book; |
4 | import org.slf4j.Logger; | 4 | import org.slf4j.Logger; |
... | @@ -8,7 +8,6 @@ import javax.ejb.Stateless; | ... | @@ -8,7 +8,6 @@ import javax.ejb.Stateless; |
8 | import javax.enterprise.inject.Alternative; | 8 | import javax.enterprise.inject.Alternative; |
9 | import javax.inject.Inject; | 9 | import javax.inject.Inject; |
10 | import javax.persistence.EntityManager; | 10 | import javax.persistence.EntityManager; |
11 | -import javax.persistence.PersistenceContext; | ||
12 | import javax.persistence.criteria.CriteriaQuery; | 11 | import javax.persistence.criteria.CriteriaQuery; |
13 | import java.util.List; | 12 | import java.util.List; |
14 | 13 | ... | ... |
1 | -package org.legrog.application; | 1 | +package org.legrog.web.book; |
2 | 2 | ||
3 | 3 | ||
4 | import org.legrog.entities.Book; | 4 | import org.legrog.entities.Book; |
5 | import org.legrog.entities.BookRepository; | 5 | import org.legrog.entities.BookRepository; |
6 | +import org.legrog.web.book.BookService; | ||
6 | import org.slf4j.Logger; | 7 | import org.slf4j.Logger; |
7 | import org.slf4j.LoggerFactory; | 8 | import org.slf4j.LoggerFactory; |
8 | 9 | ||
9 | import javax.ejb.Stateless; | 10 | import javax.ejb.Stateless; |
10 | -import javax.enterprise.inject.Alternative; | ||
11 | import javax.inject.Inject; | 11 | import javax.inject.Inject; |
12 | import java.util.List; | 12 | import java.util.List; |
13 | 13 | ... | ... |
1 | +package org.legrog.web.publisher; | ||
2 | + | ||
3 | +import org.legrog.entities.PublisherAction; | ||
4 | +import org.slf4j.Logger; | ||
5 | +import org.slf4j.LoggerFactory; | ||
6 | + | ||
7 | +import javax.faces.view.ViewScoped; | ||
8 | +import javax.inject.Inject; | ||
9 | +import javax.inject.Named; | ||
10 | +import java.io.Serializable; | ||
11 | +import java.util.List; | ||
12 | +import java.util.stream.Collectors; | ||
13 | + | ||
14 | +/* | ||
15 | + Vue de listPublisherVersions.xhtml | ||
16 | + Permet de voir l'ensemble des actions des éditeurs. | ||
17 | + Permet de voir l'ensemble des actions d'un éditeur. | ||
18 | + */ | ||
19 | +@Named | ||
20 | +@ViewScoped | ||
21 | +public class ListPublisherActionsView implements Serializable { | ||
22 | + | ||
23 | + Logger logger = LoggerFactory.getLogger(getClass()); | ||
24 | + | ||
25 | + protected PublisherService publisherService; | ||
26 | + | ||
27 | + private Integer publisherId; | ||
28 | + private boolean viewAll; | ||
29 | + private List<PublisherAction> publisherActions; | ||
30 | + | ||
31 | + @Inject | ||
32 | + public ListPublisherActionsView(PublisherService publisherService) { | ||
33 | + this.publisherService = publisherService; | ||
34 | + } | ||
35 | + | ||
36 | + //no args constructor to make it proxyable | ||
37 | + ListPublisherActionsView() { | ||
38 | + } | ||
39 | + | ||
40 | + public void setView() { | ||
41 | + logger.trace("setView : publisherId = {}", publisherId); | ||
42 | + publisherActions = publisherService.getAllPublisherActions(); | ||
43 | + viewAll = (publisherId == null); | ||
44 | + if (!viewAll) { | ||
45 | + logger.trace("setView : !viewAll"); | ||
46 | + filterOnID(); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + public void filterOnID() { | ||
51 | + publisherActions = publisherActions.stream() | ||
52 | + .filter(action -> action.getPublisher().getPublisherId() == publisherId) | ||
53 | + .collect(Collectors.toList()); | ||
54 | + } | ||
55 | + | ||
56 | + public void setPublisherId(Integer publisherId) { | ||
57 | + this.publisherId = publisherId; | ||
58 | + } | ||
59 | + | ||
60 | + public List<PublisherAction> getPublisherActions() { | ||
61 | + return publisherActions; | ||
62 | + } | ||
63 | + | ||
64 | + public boolean isViewAll() { | ||
65 | + return viewAll; | ||
66 | + } | ||
67 | + | ||
68 | + public Integer getPublisherId() { | ||
69 | + return publisherId; | ||
70 | + } | ||
71 | + | ||
72 | + public void setViewAll(boolean viewAll) { | ||
73 | + this.viewAll = viewAll; | ||
74 | + } | ||
75 | + | ||
76 | + public void setPublisherActions(List<PublisherAction> publisherActions) { | ||
77 | + this.publisherActions = publisherActions; | ||
78 | + } | ||
79 | +} |
1 | +package org.legrog.web.publisher; | ||
2 | + | ||
3 | +import org.legrog.entities.Publisher; | ||
4 | +import org.legrog.entities.PublisherAction; | ||
5 | +import org.legrog.entities.PublisherVersion; | ||
6 | +import org.slf4j.Logger; | ||
7 | +import org.slf4j.LoggerFactory; | ||
8 | + | ||
9 | +import javax.faces.view.ViewScoped; | ||
10 | +import javax.inject.Inject; | ||
11 | +import javax.inject.Named; | ||
12 | +import java.io.Serializable; | ||
13 | +import java.util.List; | ||
14 | +import java.util.stream.Collectors; | ||
15 | + | ||
16 | +/* | ||
17 | + Vue de listPublisherVersions.xhtml | ||
18 | + Permet de voir l'ensemble des versions des éditeurs. | ||
19 | + Permet de voir l'ensemble des versions d'un éditeur et de valider l'une d'elles. | ||
20 | + */ | ||
21 | +@Named | ||
22 | +@ViewScoped | ||
23 | +public class ListPublisherVersionsView implements Serializable { | ||
24 | + | ||
25 | + Logger logger = LoggerFactory.getLogger(getClass()); | ||
26 | + | ||
27 | + protected PublisherService publisherService; | ||
28 | + | ||
29 | + private Integer publisherId; | ||
30 | + private boolean viewAll; | ||
31 | + private List<PublisherVersion> publisherVersions; | ||
32 | + | ||
33 | + @Inject | ||
34 | + public ListPublisherVersionsView(PublisherService publisherService) { | ||
35 | + this.publisherService = publisherService; | ||
36 | + } | ||
37 | + | ||
38 | + //no args constructor to make it proxyable | ||
39 | + ListPublisherVersionsView() { | ||
40 | + } | ||
41 | + | ||
42 | + public PublisherAction getLastValidate(Publisher publisher) { | ||
43 | + return publisherService.getLastValidate(publisher); | ||
44 | + } | ||
45 | + | ||
46 | + // View Action being executed at view loading | ||
47 | + public void setView() { | ||
48 | + logger.trace("setView : publisherId = {}", publisherId); | ||
49 | + publisherVersions = publisherService.getAllPublisherVersions(); | ||
50 | + viewAll = (publisherId == null); | ||
51 | + if (!viewAll) { | ||
52 | + logger.trace("setView : !viewAll"); | ||
53 | + filterOnID(); | ||
54 | + } | ||
55 | + } | ||
56 | + | ||
57 | + protected void filterOnID() { | ||
58 | + publisherVersions = publisherVersions.stream() | ||
59 | + .filter(version -> version.getPublisher().getPublisherId() == publisherId) | ||
60 | + .collect(Collectors.toList()); | ||
61 | + | ||
62 | + } | ||
63 | + | ||
64 | + public void validate(PublisherVersion publisherVersion) { | ||
65 | + logger.trace("validate"); | ||
66 | + | ||
67 | + publisherService.validatePublisherVersion(publisherVersion); | ||
68 | + | ||
69 | + publisherVersions = publisherService.getAllPublisherVersions(); | ||
70 | + filterOnID(); | ||
71 | + } | ||
72 | +// | ||
73 | + | ||
74 | + public PublisherService getPublisherService() { | ||
75 | + return publisherService; | ||
76 | + } | ||
77 | + | ||
78 | + public void setPublisherService(PublisherService publisherService) { | ||
79 | + this.publisherService = publisherService; | ||
80 | + } | ||
81 | + | ||
82 | + public Integer getPublisherId() { | ||
83 | + return publisherId; | ||
84 | + } | ||
85 | + | ||
86 | + public void setPublisherId(Integer publisherId) { | ||
87 | + this.publisherId = publisherId; | ||
88 | + } | ||
89 | + | ||
90 | + public boolean isViewAll() { | ||
91 | + return viewAll; | ||
92 | + } | ||
93 | + | ||
94 | + public void setViewAll(boolean viewAll) { | ||
95 | + this.viewAll = viewAll; | ||
96 | + } | ||
97 | + | ||
98 | + public List<PublisherVersion> getPublisherVersions() { | ||
99 | + return publisherVersions; | ||
100 | + } | ||
101 | + | ||
102 | + public void setPublisherVersions(List<PublisherVersion> publisherVersions) { | ||
103 | + this.publisherVersions = publisherVersions; | ||
104 | + } | ||
105 | + | ||
106 | + @Override | ||
107 | + public String toString() { | ||
108 | + return "publisherId = " + publisherId + ", viewAll = " + viewAll + ", publisherVersions = " + publisherVersions; | ||
109 | + } | ||
110 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +package org.legrog.web.publisher; | ||
2 | + | ||
3 | +import org.legrog.entities.Publisher; | ||
4 | +import org.legrog.entities.PublisherAction; | ||
5 | +import org.legrog.entities.PublisherVersion; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +/* | ||
10 | + Interface correspondant à la gestion des éditeurs et de leurs versions. | ||
11 | + Contient des signatures méthodes d'ajout, de modification et de validation de version ainsi que de restitution. | ||
12 | + */ | ||
13 | +public interface PublisherService { | ||
14 | + | ||
15 | + PublisherVersion addNewPublisher(PublisherVersion publisherVersion); | ||
16 | + | ||
17 | + PublisherVersion addVersionToPublisher(Publisher publisher, PublisherVersion publisherVersion); | ||
18 | + | ||
19 | + PublisherAction validatePublisherVersion(PublisherVersion publisherVersion); | ||
20 | + | ||
21 | + List<PublisherVersion> getAllPublisherVersions(); | ||
22 | + | ||
23 | + PublisherVersion getPublisherVersion(Integer publisherVersionId); | ||
24 | + | ||
25 | + PublisherAction getLastValidate(Publisher publisher); | ||
26 | + | ||
27 | + List<PublisherAction> getAllPublisherActions(); | ||
28 | +} |
1 | +package org.legrog.web.publisher; | ||
2 | + | ||
3 | + | ||
4 | +import org.legrog.entities.*; | ||
5 | +import org.legrog.web.xyz.SharedService; | ||
6 | +import org.slf4j.Logger; | ||
7 | +import org.slf4j.LoggerFactory; | ||
8 | + | ||
9 | +import javax.ejb.Stateless; | ||
10 | +import javax.inject.Inject; | ||
11 | +import java.sql.Timestamp; | ||
12 | +import java.util.Date; | ||
13 | +import java.util.HashSet; | ||
14 | +import java.util.List; | ||
15 | +import java.util.Set; | ||
16 | + | ||
17 | +/* | ||
18 | + Implémentation de l'interface PublisherService | ||
19 | + */ | ||
20 | + | ||
21 | +@Stateless | ||
22 | +public class PublisherServiceSpring implements PublisherService { | ||
23 | + Logger logger = LoggerFactory.getLogger(getClass()); | ||
24 | + | ||
25 | + PublisherRepository publisherRepository; | ||
26 | + PublisherVersionRepository publisherVersionRepository; | ||
27 | + PublisherActionRepository publisherActionRepository; | ||
28 | + ActionTypeRepository actionTypeRepository; | ||
29 | + SharedService sharedService; | ||
30 | + | ||
31 | + @Inject | ||
32 | + public PublisherServiceSpring(PublisherRepository publisherRepository, | ||
33 | + PublisherVersionRepository publisherVersionRepository, | ||
34 | + PublisherActionRepository publisherActionRepository, | ||
35 | + ActionTypeRepository actionTypeRepository, | ||
36 | + SharedService sharedService) { | ||
37 | + this.publisherRepository = publisherRepository; | ||
38 | + this.publisherVersionRepository = publisherVersionRepository; | ||
39 | + this.publisherActionRepository = publisherActionRepository; | ||
40 | + this.actionTypeRepository = actionTypeRepository; | ||
41 | + this.sharedService = sharedService; | ||
42 | + } | ||
43 | + | ||
44 | + //no args constructor to make it proxyable | ||
45 | + PublisherServiceSpring() { | ||
46 | + } | ||
47 | + | ||
48 | + public PublisherVersion addNewPublisher(PublisherVersion publisherVersion) { | ||
49 | + Publisher publisher = new Publisher(); | ||
50 | + Set<PublisherVersion> publisherVersions = new HashSet<>(); | ||
51 | + publisherVersions.add(publisherVersion); | ||
52 | + publisher.setVersions(publisherVersions); | ||
53 | + publisherVersion.setPublisher(publisher); | ||
54 | + publisherVersion.setPublisherVersionAuthor(sharedService.getCurrentUser()); | ||
55 | + publisherVersion.setPublisherVersionDatetime(new Timestamp(new Date().getTime())); | ||
56 | + this.savePublisherVersion(publisherVersion); | ||
57 | + this.savePublisher(publisher); | ||
58 | + return publisherVersion; | ||
59 | + } | ||
60 | + | ||
61 | + public PublisherVersion addVersionToPublisher(Publisher publisher, PublisherVersion publisherVersion) { | ||
62 | + logger.trace("debut addVersionToPublisher, publisherVersion = {}", publisherVersion); | ||
63 | + Set<PublisherVersion> publisherVersionSet = publisher.getVersions(); | ||
64 | + publisherVersionSet.add(publisherVersion); | ||
65 | + publisher.setVersions(publisherVersionSet); | ||
66 | + publisherVersion.setPublisher(publisher); | ||
67 | + publisherVersion.setPublisherVersionAuthor(sharedService.getCurrentUser()); | ||
68 | + publisherVersion.setPublisherVersionDatetime(new Timestamp(new Date().getTime())); | ||
69 | + this.savePublisherVersion(publisherVersion); | ||
70 | + this.savePublisher(publisher); | ||
71 | + logger.trace("fin addVersionToPublisher, publisherVersion = {}", publisherVersion); | ||
72 | + return publisherVersion; | ||
73 | + } | ||
74 | + | ||
75 | + public PublisherAction validatePublisherVersion(PublisherVersion publisherVersion) { | ||
76 | + Publisher publisher = publisherVersion.getPublisher(); | ||
77 | + publisher.setValidatedVersion(publisherVersion); | ||
78 | + PublisherAction publisherAction = new PublisherAction(); | ||
79 | + publisherAction.setPublisherActionAuthor(sharedService.getCurrentUser()); | ||
80 | + publisherAction.setPublisherActionDatetime(new Timestamp(new Date().getTime())); | ||
81 | + publisherAction.setActionType(actionTypeRepository.findByActionTypeName("Validate")); | ||
82 | + publisherAction.setPublisherVersion(publisherVersion); | ||
83 | + publisherAction.setPublisher(publisher); | ||
84 | + this.savePublisher(publisher); | ||
85 | + publisherActionRepository.save(publisherAction); | ||
86 | + return publisherAction; | ||
87 | + } | ||
88 | + | ||
89 | + protected void savePublisherVersion(PublisherVersion publisherVersion) { | ||
90 | + publisherVersionRepository.save(publisherVersion); | ||
91 | + } | ||
92 | + | ||
93 | + protected void savePublisher(Publisher publisher) { | ||
94 | + publisherRepository.save(publisher); | ||
95 | + } | ||
96 | + | ||
97 | + // get | ||
98 | + public List<PublisherVersion> getAllPublisherVersions() { | ||
99 | + return publisherVersionRepository.findAll(); | ||
100 | + } | ||
101 | + | ||
102 | + public PublisherVersion getPublisherVersion(Integer publisherVersionId) { | ||
103 | + return publisherVersionRepository.findOne(publisherVersionId); | ||
104 | + } | ||
105 | + | ||
106 | + public PublisherAction getLastValidate(Publisher publisher) { | ||
107 | + return publisherActionRepository.publisherLastValidate(publisher); | ||
108 | + } | ||
109 | + | ||
110 | + public List<PublisherAction> getAllPublisherActions() { | ||
111 | + return publisherActionRepository.findAll(); | ||
112 | + } | ||
113 | + | ||
114 | +} |
1 | +package org.legrog.web.publisher; | ||
2 | + | ||
3 | +import org.legrog.entities.PublisherVersion; | ||
4 | +import org.legrog.web.xyz.SharedService; | ||
5 | +import org.legrog.entities.Country; | ||
6 | +import org.legrog.entities.Publisher; | ||
7 | +import org.legrog.entities.Person; | ||
8 | +import org.slf4j.Logger; | ||
9 | +import org.slf4j.LoggerFactory; | ||
10 | + | ||
11 | +import javax.annotation.PostConstruct; | ||
12 | +import javax.faces.view.ViewScoped; | ||
13 | +//import javax.faces.context.FacesContext; | ||
14 | +import javax.inject.Inject; | ||
15 | +import javax.inject.Named; | ||
16 | +import java.io.Serializable; | ||
17 | +import java.sql.Timestamp; | ||
18 | +import java.util.List; | ||
19 | + | ||
20 | +/* | ||
21 | + Vue de publisherVersion.xhtml | ||
22 | + Permet la création, l'affichage et la modification d'une version d'éditeur. | ||
23 | + La création d'une version crée l'éditeur et sa version initiale. | ||
24 | + Le modification crée une nouvelle version liée à l'éditeur. | ||
25 | + */ | ||
26 | +@Named | ||
27 | +@ViewScoped | ||
28 | +public class PublisherVersionView implements Serializable { | ||
29 | + Logger logger = LoggerFactory.getLogger(getClass()); | ||
30 | + | ||
31 | + PublisherService publisherService; | ||
32 | + SharedService sharedService; | ||
33 | + | ||
34 | + private boolean editMode; | ||
35 | + private boolean newPublisher; | ||
36 | + | ||
37 | + private int publisherVersionId; | ||
38 | + private String publisherName; | ||
39 | + private String publisherStreetAddress; | ||
40 | + private String publisherPostalCode; | ||
41 | + private String publisherPostOfficeBoxNumber; | ||
42 | + private String publisherAddressRegion; | ||
43 | + private String publisherAddressLocality; | ||
44 | + private Country publisherAddressCountry; | ||
45 | + private String publisherTelephone; | ||
46 | + private String publisherEmail; | ||
47 | + private String publisherURL; | ||
48 | + private boolean publisherActive; | ||
49 | + private String publisherHistory; | ||
50 | + private Person publisherVersionAuthor; | ||
51 | + private Timestamp publisherVersionDatetime; | ||
52 | + | ||
53 | + private Publisher publisher; | ||
54 | + | ||
55 | + private List<Country> availableCountries; | ||
56 | + | ||
57 | + @Inject | ||
58 | + public PublisherVersionView(PublisherService publisherService, SharedService sharedService) { | ||
59 | + this.publisherService = publisherService; | ||
60 | + this.sharedService = sharedService; | ||
61 | + } | ||
62 | + | ||
63 | + //no args constructor to make it proxyable | ||
64 | + PublisherVersionView() { | ||
65 | + } | ||
66 | + | ||
67 | + @PostConstruct | ||
68 | + public void init() { | ||
69 | + availableCountries = sharedService.getAllCountries(); | ||
70 | + } | ||
71 | + | ||
72 | + public void edit() { | ||
73 | + editMode = true; | ||
74 | + } | ||
75 | + | ||
76 | + public void cancel() { | ||
77 | + if (!newPublisher) { | ||
78 | + loadData(); | ||
79 | + editMode = false; | ||
80 | + } else { | ||
81 | + publisherName = null; | ||
82 | + publisherStreetAddress = null; | ||
83 | + publisherPostalCode = null; | ||
84 | + publisherPostOfficeBoxNumber = null; | ||
85 | + publisherAddressRegion = null; | ||
86 | + publisherAddressLocality = null; | ||
87 | + publisherAddressCountry = null; | ||
88 | + publisherTelephone = null; | ||
89 | + publisherEmail = null; | ||
90 | + publisherURL = null; | ||
91 | + publisherActive = false; | ||
92 | + publisherHistory = null; | ||
93 | + // Je ne pense pas que la ligne suivante soit nécessaire | ||
94 | + publisher = null; | ||
95 | + | ||
96 | + editMode = true; | ||
97 | + } | ||
98 | + } | ||
99 | + | ||
100 | + public void save() { | ||
101 | + logger.debug("save()"); | ||
102 | + if (newPublisher) { | ||
103 | + logger.debug("->add"); | ||
104 | + add(); | ||
105 | + } else { | ||
106 | + logger.debug("->update"); | ||
107 | + update(); | ||
108 | + } | ||
109 | + } | ||
110 | + | ||
111 | + private PublisherVersion getNewPublisherVersion() { | ||
112 | + PublisherVersion publisherVersion = new PublisherVersion(); | ||
113 | + publisherVersion.setPublisherActive(publisherActive); | ||
114 | + publisherVersion.setPublisherAddressCountry(publisherAddressCountry); | ||
115 | + publisherVersion.setPublisherAddressLocality(publisherAddressLocality); | ||
116 | + publisherVersion.setPublisherAddressRegion(publisherAddressRegion); | ||
117 | + publisherVersion.setPublisherEmail(publisherEmail); | ||
118 | + publisherVersion.setPublisherHistory(publisherHistory); | ||
119 | + publisherVersion.setPublisherName(publisherName); | ||
120 | + publisherVersion.setPublisherPostalCode(publisherPostalCode); | ||
121 | + publisherVersion.setPublisherPostOfficeBoxNumber(publisherPostOfficeBoxNumber); | ||
122 | + publisherVersion.setPublisherStreetAddress(publisherStreetAddress); | ||
123 | + publisherVersion.setPublisherTelephone(publisherTelephone); | ||
124 | + publisherVersion.setPublisherURL(publisherURL); | ||
125 | + return publisherVersion; | ||
126 | + } | ||
127 | + | ||
128 | + private void getImmutableValues() { | ||
129 | + PublisherVersion publisherVersion; | ||
130 | + | ||
131 | + publisherVersion = publisherService.getPublisherVersion(publisherVersionId); | ||
132 | + if (publisherVersion == null) { | ||
133 | + throw new IllegalStateException("Publisher version not found"); | ||
134 | + } | ||
135 | + publisherVersionAuthor = publisherVersion.getPublisherVersionAuthor(); | ||
136 | + publisherVersionDatetime = publisherVersion.getPublisherVersionDatetime(); | ||
137 | + } | ||
138 | + | ||
139 | + public void add() { | ||
140 | + PublisherVersion publisherVersion = getNewPublisherVersion(); | ||
141 | + | ||
142 | + publisherVersion = publisherService.addNewPublisher(publisherVersion); | ||
143 | + | ||
144 | + newPublisher = false; | ||
145 | + publisherVersionId = publisherVersion.getPublisherVersionId(); | ||
146 | + publisher = publisherVersion.getPublisher(); | ||
147 | + | ||
148 | + getImmutableValues(); | ||
149 | + | ||
150 | + editMode = false; | ||
151 | + } | ||
152 | + | ||
153 | + public void update() { | ||
154 | + logger.trace("debut update, attributs locaux, publisherActive = {} publisherAddressCountry = {} publisherAddressLocality = {} publisherAddressRegion = {} publisherEmail = {} publisherHistory = {} publisherName = {} publisherPostalCode = {} publisherPostOfficeBoxNumber = {} publisherStreetAddress = {} publisherTelephone {} publisherURL {}", | ||
155 | + publisherActive, publisherAddressCountry, publisherAddressLocality, publisherAddressRegion, | ||
156 | + publisherEmail, publisherHistory, publisherName, publisherPostalCode, publisherPostOfficeBoxNumber, | ||
157 | + publisherStreetAddress, publisherTelephone, publisherURL); | ||
158 | + | ||
159 | + PublisherVersion publisherVersion = getNewPublisherVersion(); | ||
160 | + | ||
161 | + logger.trace("milieu update, avant enregistrement, publisherVersion = {}", publisherVersion); | ||
162 | + publisherVersion = publisherService.addVersionToPublisher(publisher, publisherVersion); | ||
163 | + | ||
164 | + publisherVersionId = publisherVersion.getPublisherVersionId(); | ||
165 | + | ||
166 | + getImmutableValues(); | ||
167 | + | ||
168 | + editMode = false; | ||
169 | + logger.trace("fin update, après récupération, publisherVersion = {}", publisherVersion); | ||
170 | + } | ||
171 | + | ||
172 | + public void loadData() { | ||
173 | + PublisherVersion publisherVersion = null; | ||
174 | + | ||
175 | + logger.debug("publisherVersionId = {}", this.publisherVersionId); | ||
176 | + | ||
177 | + if (publisherVersionId != 0) { | ||
178 | + publisherVersion = publisherService.getPublisherVersion(publisherVersionId); | ||
179 | + } | ||
180 | + | ||
181 | + if (publisherVersion != null) { | ||
182 | + | ||
183 | + logger.debug("Found a publisher version : {}", publisherVersion.toString()); | ||
184 | + | ||
185 | + publisherName = publisherVersion.getPublisherName(); | ||
186 | + publisherStreetAddress = publisherVersion.getPublisherStreetAddress(); | ||
187 | + publisherPostalCode = publisherVersion.getPublisherPostalCode(); | ||
188 | + publisherPostOfficeBoxNumber = publisherVersion.getPublisherPostOfficeBoxNumber(); | ||
189 | + publisherAddressRegion = publisherVersion.getPublisherAddressRegion(); | ||
190 | + publisherAddressLocality = publisherVersion.getPublisherAddressLocality(); | ||
191 | + publisherAddressCountry = publisherVersion.getPublisherAddressCountry(); | ||
192 | + publisherTelephone = publisherVersion.getPublisherTelephone(); | ||
193 | + publisherEmail = publisherVersion.getPublisherEmail(); | ||
194 | + publisherURL = publisherVersion.getPublisherURL(); | ||
195 | + publisherActive = publisherVersion.isPublisherActive(); | ||
196 | + publisherHistory = publisherVersion.getPublisherHistory(); | ||
197 | + publisher = publisherVersion.getPublisher(); | ||
198 | + | ||
199 | + getImmutableValues(); | ||
200 | + | ||
201 | + logger.debug("Found a publisher : {}", publisher.toString()); | ||
202 | + newPublisher = false; | ||
203 | + } else { | ||
204 | + logger.debug("No publisher."); | ||
205 | + editMode = true; | ||
206 | + newPublisher = true; | ||
207 | + } | ||
208 | + | ||
209 | + } | ||
210 | + | ||
211 | + // get, set et is | ||
212 | + public int getPublisherVersionId() { | ||
213 | + return publisherVersionId; | ||
214 | + } | ||
215 | + | ||
216 | + public void setPublisherVersionId(int publisherVersionId) { | ||
217 | + this.publisherVersionId = publisherVersionId; | ||
218 | + } | ||
219 | + | ||
220 | + public String getPublisherName() { | ||
221 | + return publisherName; | ||
222 | + } | ||
223 | + | ||
224 | + public void setPublisherName(String publisherName) { | ||
225 | + this.publisherName = publisherName; | ||
226 | + } | ||
227 | + | ||
228 | + public String getPublisherStreetAddress() { | ||
229 | + return publisherStreetAddress; | ||
230 | + } | ||
231 | + | ||
232 | + public void setPublisherStreetAddress(String publisherStreetAddress) { | ||
233 | + this.publisherStreetAddress = publisherStreetAddress; | ||
234 | + } | ||
235 | + | ||
236 | + public String getPublisherPostalCode() { | ||
237 | + return publisherPostalCode; | ||
238 | + } | ||
239 | + | ||
240 | + public void setPublisherPostalCode(String publisherPostalCode) { | ||
241 | + this.publisherPostalCode = publisherPostalCode; | ||
242 | + } | ||
243 | + | ||
244 | + public String getPublisherPostOfficeBoxNumber() { | ||
245 | + return publisherPostOfficeBoxNumber; | ||
246 | + } | ||
247 | + | ||
248 | + public void setPublisherPostOfficeBoxNumber(String publisherPostOfficeBoxNumber) { | ||
249 | + this.publisherPostOfficeBoxNumber = publisherPostOfficeBoxNumber; | ||
250 | + } | ||
251 | + | ||
252 | + public String getPublisherAddressRegion() { | ||
253 | + return publisherAddressRegion; | ||
254 | + } | ||
255 | + | ||
256 | + public void setPublisherAddressRegion(String publisherAddressRegion) { | ||
257 | + this.publisherAddressRegion = publisherAddressRegion; | ||
258 | + } | ||
259 | + | ||
260 | + public String getPublisherAddressLocality() { | ||
261 | + return publisherAddressLocality; | ||
262 | + } | ||
263 | + | ||
264 | + public void setPublisherAddressLocality(String publisherAddressLocality) { | ||
265 | + this.publisherAddressLocality = publisherAddressLocality; | ||
266 | + } | ||
267 | + | ||
268 | + public Country getPublisherAddressCountry() { | ||
269 | + return publisherAddressCountry; | ||
270 | + } | ||
271 | + | ||
272 | + public void setPublisherAddressCountry(Country publisherAddressCountry) { | ||
273 | + this.publisherAddressCountry = publisherAddressCountry; | ||
274 | + } | ||
275 | + | ||
276 | + public String getPublisherTelephone() { | ||
277 | + return publisherTelephone; | ||
278 | + } | ||
279 | + | ||
280 | + public void setPublisherTelephone(String publisherTelephone) { | ||
281 | + this.publisherTelephone = publisherTelephone; | ||
282 | + } | ||
283 | + | ||
284 | + public String getPublisherEmail() { | ||
285 | + return publisherEmail; | ||
286 | + } | ||
287 | + | ||
288 | + public void setPublisherEmail(String publisherEmail) { | ||
289 | + this.publisherEmail = publisherEmail; | ||
290 | + } | ||
291 | + | ||
292 | + public String getPublisherURL() { | ||
293 | + return publisherURL; | ||
294 | + } | ||
295 | + | ||
296 | + public void setPublisherURL(String publisherURL) { | ||
297 | + this.publisherURL = publisherURL; | ||
298 | + } | ||
299 | + | ||
300 | + public boolean isPublisherActive() { | ||
301 | + return publisherActive; | ||
302 | + } | ||
303 | + | ||
304 | + public void setPublisherActive(boolean publisherActive) { | ||
305 | + this.publisherActive = publisherActive; | ||
306 | + } | ||
307 | + | ||
308 | + public String getPublisherHistory() { | ||
309 | + return publisherHistory; | ||
310 | + } | ||
311 | + | ||
312 | + public void setPublisherHistory(String publisherHistory) { | ||
313 | + this.publisherHistory = publisherHistory; | ||
314 | + } | ||
315 | + | ||
316 | + public Person getPublisherVersionAuthor() { | ||
317 | + return publisherVersionAuthor; | ||
318 | + } | ||
319 | + | ||
320 | + public void setPublisherVersionAuthor(Person publisherVersionAuthor) { | ||
321 | + this.publisherVersionAuthor = publisherVersionAuthor; | ||
322 | + } | ||
323 | + | ||
324 | + public Timestamp getPublisherVersionDatetime() { | ||
325 | + return publisherVersionDatetime; | ||
326 | + } | ||
327 | + | ||
328 | + public void setPublisherVersionDatetime(Timestamp publisherVersionDatetime) { | ||
329 | + this.publisherVersionDatetime = publisherVersionDatetime; | ||
330 | + } | ||
331 | + | ||
332 | + public List<Country> getAvailableCountries() { | ||
333 | + return availableCountries; | ||
334 | + } | ||
335 | + | ||
336 | + public void setAvailableCountries(List<Country> availableCountries) { | ||
337 | + this.availableCountries = availableCountries; | ||
338 | + } | ||
339 | + | ||
340 | + public boolean isNewPublisher() { | ||
341 | + return newPublisher; | ||
342 | + } | ||
343 | + | ||
344 | + public boolean isEditMode() { | ||
345 | + return editMode; | ||
346 | + } | ||
347 | + | ||
348 | + public void setEditMode(boolean editMode) { | ||
349 | + this.editMode = editMode; | ||
350 | + } | ||
351 | + | ||
352 | + public void setNewPublisher(boolean newPublisher) { | ||
353 | + this.newPublisher = newPublisher; | ||
354 | + } | ||
355 | + | ||
356 | + public Publisher getPublisher() { | ||
357 | + return publisher; | ||
358 | + } | ||
359 | + | ||
360 | + public void setPublisher(Publisher publisher) { | ||
361 | + this.publisher = publisher; | ||
362 | + } | ||
363 | +} |
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
3 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
4 | +<html xmlns="http://www.w3.org/1999/xhtml" | ||
5 | + xmlns:h="http://xmlns.jcp.org/jsf/html" | ||
6 | + xmlns:jsf="http://xmlns.jcp.org/jsf" | ||
7 | + xmlns:f="http://xmlns.jcp.org/jsf/core"> | ||
8 | +<f:metadata> | ||
9 | + <f:viewParam name="publisherId" value="#{listPublisherActionsView.publisherId}"/> | ||
10 | + <f:viewAction action="#{listPublisherActionsView.setView}"/> | ||
11 | +</f:metadata> | ||
12 | +<head> | ||
13 | + <link rel="stylesheet" type="text/css" href="/minimal.css"/> | ||
14 | +</head> | ||
15 | +<body> | ||
16 | +<ul> | ||
17 | + <li> | ||
18 | + <a jsf:outcome="/index">Menu principal</a> | ||
19 | + </li> | ||
20 | + <li> | ||
21 | + <a jsf:outcome="listPublisherVersions">Liste des versions des éditeurs</a> | ||
22 | + </li> | ||
23 | + <li> | ||
24 | + <a jsf:outcome="publisherVersion">Ajouter un éditeur</a> | ||
25 | + </li> | ||
26 | +</ul> | ||
27 | + | ||
28 | +<a jsf:outcome="listPublisherActions" jsf:rendered="#{not listPublisherActionsView.viewAll}">Voir toutes les actions</a> | ||
29 | + | ||
30 | +<h:dataTable value="#{listPublisherActionsView.publisherActions}" var="action"> | ||
31 | + <h:column> | ||
32 | + <f:facet name="header">Action</f:facet> | ||
33 | + ${action.actionType.actionTypeName} | ||
34 | + </h:column> | ||
35 | + <h:column> | ||
36 | + <f:facet name="header">Author</f:facet> | ||
37 | + ${action.publisherActionAuthor.displayName} | ||
38 | + </h:column> | ||
39 | + <h:column> | ||
40 | + <f:facet name="header">Action Datetime</f:facet> | ||
41 | + ${action.publisherActionDatetime} | ||
42 | + </h:column> | ||
43 | + <h:column> | ||
44 | + <f:facet name="header">Name</f:facet> | ||
45 | + ${action.publisherVersion.publisherName} | ||
46 | + </h:column> | ||
47 | + <h:column> | ||
48 | + <f:facet name="header">Address</f:facet> | ||
49 | + ${action.publisherVersion.publisherPostOfficeBoxNumber}<br /> | ||
50 | + ${action.publisherVersion.publisherStreetAddress}<br /> | ||
51 | + ${action.publisherVersion.publisherPostalCode} ${action.publisherVersion.publisherAddressLocality}<br /> | ||
52 | + ${action.publisherVersion.publisherAddressRegion}<br /> | ||
53 | + ${action.publisherVersion.publisherAddressCountry.countryName} | ||
54 | + </h:column> | ||
55 | + <h:column> | ||
56 | + <f:facet name="header">Telephone</f:facet> | ||
57 | + ${action.publisherVersion.publisherTelephone} | ||
58 | + </h:column> | ||
59 | + <h:column> | ||
60 | + <f:facet name="header">Email</f:facet> | ||
61 | + ${action.publisherVersion.publisherEmail} | ||
62 | + </h:column> | ||
63 | + <h:column> | ||
64 | + <f:facet name="header">URL</f:facet> | ||
65 | + ${action.publisherVersion.publisherURL} | ||
66 | + </h:column> | ||
67 | + <h:column> | ||
68 | + <f:facet name="header">Active ?</f:facet> | ||
69 | + ${action.publisherVersion.publisherActive} | ||
70 | + </h:column> | ||
71 | + <h:column> | ||
72 | + <f:facet name="header">History</f:facet> | ||
73 | + ${action.publisherVersion.publisherHistory} | ||
74 | + </h:column> | ||
75 | + <h:column> | ||
76 | + <f:facet name="header">Version Author</f:facet> | ||
77 | + ${action.publisherVersion.publisherVersionAuthor.displayName} | ||
78 | + </h:column> | ||
79 | + <h:column> | ||
80 | + <f:facet name="header">Version Datetime</f:facet> | ||
81 | + ${action.publisherVersion.publisherVersionDatetime} | ||
82 | + </h:column> | ||
83 | + | ||
84 | +</h:dataTable> | ||
85 | + | ||
86 | +</body> | ||
87 | +</html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
3 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
4 | +<html xmlns="http://www.w3.org/1999/xhtml" | ||
5 | + xmlns:h="http://xmlns.jcp.org/jsf/html" | ||
6 | + xmlns:jsf="http://xmlns.jcp.org/jsf" | ||
7 | + xmlns:f="http://xmlns.jcp.org/jsf/core"> | ||
8 | +<f:metadata> | ||
9 | + <f:viewParam name="publisherId" value="#{listPublisherVersionsView.publisherId}"/> | ||
10 | + <f:viewAction action="#{listPublisherVersionsView.setView}"/> | ||
11 | +</f:metadata> | ||
12 | +<head> | ||
13 | + <link rel="stylesheet" type="text/css" href="/minimal.css"/> | ||
14 | +</head> | ||
15 | +<body> | ||
16 | + <ul> | ||
17 | + <li> | ||
18 | + <a jsf:outcome="/index">Menu principal</a> | ||
19 | + </li> | ||
20 | + <li> | ||
21 | + <a jsf:outcome="listPublisherActions">Liste des actions des éditeurs</a> | ||
22 | + </li> | ||
23 | + <li> | ||
24 | + <a jsf:outcome="publisherVersion">Ajouter un éditeur</a> | ||
25 | + </li> | ||
26 | + </ul> | ||
27 | + | ||
28 | + <a jsf:outcome="listPublisherVersions" jsf:rendered="#{not listPublisherVersionsView.viewAll}">Voir toutes les versions d'éditeurs</a> | ||
29 | + <p jsf:rendered="#{listPublisherVersionsView.publisherVersions.isEmpty()}">Liste des révisions est vide</p> | ||
30 | + <h:dataTable value="#{listPublisherVersionsView.publisherVersions}" var="version"> | ||
31 | + <h:column> | ||
32 | + <f:facet name="header">Visualiser ou Modifier</f:facet> | ||
33 | + <a jsf:outcome="publisherVersion">Visualiser ou Modifier Version | ||
34 | + <f:param name="publisherVersionId" value="#{version.publisherVersionId}"/> | ||
35 | + </a> | ||
36 | + </h:column> | ||
37 | + <h:column rendered="#{listPublisherVersionsView.viewAll}"> | ||
38 | + <f:facet name="header">Editeur</f:facet> | ||
39 | + <a jsf:outcome="listPublisherVersions">Visualiser ou valider version éditeur | ||
40 | + <f:param name="publisherId" value="#{version.publisher.publisherId}"/> | ||
41 | + </a> | ||
42 | + </h:column> | ||
43 | + <h:column> | ||
44 | + <f:facet name="header">Actions</f:facet> | ||
45 | + <p jsf:rendered="#{version.publisher.actions.size() == 0}">Aucune action à lister</p> | ||
46 | + <a jsf:outcome="listPublisherActions" jsf:rendered="#{version.publisher.actions.size() > 0}">Voir les actions | ||
47 | + <f:param name="publisherId" value="#{version.publisher.publisherId}"/> | ||
48 | + </a> | ||
49 | + </h:column> | ||
50 | + <h:column> | ||
51 | + <f:facet name="header">Valide</f:facet> | ||
52 | + <p jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">Validé</p> | ||
53 | + <p jsf:rendered="#{listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}">Non validé</p> | ||
54 | + <!-- https://www.mkyong.com/jsf2/4-ways-to-pass-parameter-from-jsf-page-to-backing-bean/ f:param, problème avec Method expression --> | ||
55 | + <form action="" jsf:rendered="#{not listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}"> | ||
56 | + <button jsf:action="#{listPublisherVersionsView.validate(version)}">Valider | ||
57 | + </button> | ||
58 | + </form> | ||
59 | + </h:column> | ||
60 | + <h:column> | ||
61 | + <f:facet name="header">Name</f:facet> | ||
62 | + ${version.publisherName} | ||
63 | + </h:column> | ||
64 | + <h:column> | ||
65 | + <f:facet name="header">Address</f:facet> | ||
66 | + ${version.publisherPostOfficeBoxNumber}<br /> | ||
67 | + ${version.publisherStreetAddress}<br /> | ||
68 | + ${version.publisherPostalCode} ${version.publisherAddressLocality}<br /> | ||
69 | + ${version.publisherAddressRegion}<br /> | ||
70 | + ${version.publisherAddressCountry.countryName} | ||
71 | + </h:column> | ||
72 | + <h:column> | ||
73 | + <f:facet name="header">Telephone</f:facet> | ||
74 | + ${version.publisherTelephone} | ||
75 | + </h:column> | ||
76 | + <h:column> | ||
77 | + <f:facet name="header">Email</f:facet> | ||
78 | + ${version.publisherEmail} | ||
79 | + </h:column> | ||
80 | + <h:column> | ||
81 | + <f:facet name="header">URL</f:facet> | ||
82 | + ${version.publisherURL} | ||
83 | + </h:column> | ||
84 | + <h:column> | ||
85 | + <f:facet name="header">Active ?</f:facet> | ||
86 | + ${version.publisherActive} | ||
87 | + </h:column> | ||
88 | + <h:column> | ||
89 | + <f:facet name="header">History</f:facet> | ||
90 | + ${version.publisherHistory} | ||
91 | + </h:column> | ||
92 | + <h:column> | ||
93 | + <f:facet name="header">Version Author</f:facet> | ||
94 | + ${version.publisherVersionAuthor.displayName} | ||
95 | + </h:column> | ||
96 | + <h:column> | ||
97 | + <f:facet name="header">Version Datetime</f:facet> | ||
98 | + ${version.publisherVersionDatetime} | ||
99 | + </h:column> | ||
100 | + <h:column> | ||
101 | + <f:facet name="header">Validation author</f:facet> | ||
102 | + <div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}"> | ||
103 | + ${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionAuthor.displayName} | ||
104 | + </div> | ||
105 | + </h:column> | ||
106 | + <h:column> | ||
107 | + <f:facet name="header">Validation Datetime</f:facet> | ||
108 | + <div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}"> | ||
109 | + ${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionDatetime} | ||
110 | + </div> | ||
111 | + </h:column> | ||
112 | + </h:dataTable> | ||
113 | +</body> | ||
114 | +</html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
3 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
4 | +<html xmlns="http://www.w3.org/1999/xhtml" | ||
5 | + xmlns:h="http://xmlns.jcp.org/jsf/html" | ||
6 | + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" | ||
7 | + xmlns:f="http://xmlns.jcp.org/jsf/core" | ||
8 | + xmlns:jsf="http://xmlns.jcp.org/jsf"> | ||
9 | +<head> | ||
10 | +<f:metadata> | ||
11 | + <f:viewParam name="publisherVersionId" value="#{publisherVersionView.publisherVersionId}" /> | ||
12 | + <f:viewAction action="#{publisherVersionView.loadData}" /> | ||
13 | +</f:metadata> | ||
14 | +</head> | ||
15 | +<body> | ||
16 | + | ||
17 | +<form jsf:id="publisherVersion" action=""> | ||
18 | + <ul> | ||
19 | + <li> | ||
20 | + <a jsf:outcome="/index">Menu principal</a> | ||
21 | + </li> | ||
22 | + <li> | ||
23 | + <a jsf:outcome="listPublisherVersions">Liste des versions des éditeurs</a> | ||
24 | + </li> | ||
25 | + <li> | ||
26 | + <a jsf:outcome="listPublisherActions">Liste des actions des éditeurs</a> | ||
27 | + </li> | ||
28 | + </ul> | ||
29 | + | ||
30 | + <h:panelGrid columns="2"> | ||
31 | + <label for="publisherName">publisherName</label> | ||
32 | + <input type="text" id="publisherName" jsf:value='#{publisherVersionView.publisherName}' jsf:disabled="#{not publisherVersionView.editMode}"/> | ||
33 | + <label for="publisherStreetAddress">publisherStreetAddress</label> | ||
34 | + <input type="text" id="publisherStreetAddress" jsf:value='#{publisherVersionView.publisherStreetAddress}' jsf:disabled="#{not publisherVersionView.editMode}"/> | ||
35 | + <label for="publisherPostalCode">publisherPostalCode</label> | ||
36 | + <input type="text" id="publisherPostalCode" jsf:value='#{publisherVersionView.publisherPostalCode}' jsf:disabled="#{not publisherVersionView.editMode}"/> | ||
37 | + <label for="publisherPostOfficeBoxNumber">publisherPostOfficeBoxNumber</label> | ||
38 | + <input type="text" id="publisherPostOfficeBoxNumber" jsf:value='#{publisherVersionView.publisherPostOfficeBoxNumber}' jsf:disabled="#{not publisherVersionView.editMode}"/> | ||
39 | + <label for="publisherAddressRegion">publisherAddressRegion</label> | ||
40 | + <input type="text" id="publisherAddressRegion" jsf:value='#{publisherVersionView.publisherAddressRegion}' jsf:disabled="#{not publisherVersionView.editMode}"/> | ||
41 | + <label for="publisherAddressLocality">publisherAddressLocality</label> | ||
42 | + <input type="text" id="publisherAddressLocality" jsf:value='#{publisherVersionView.publisherAddressLocality}' jsf:disabled="#{not publisherVersionView.editMode}"/> | ||
43 | + | ||
44 | + <label for="publisherAddressCountry">publisherAddressCountry</label> | ||
45 | + <h:selectOneMenu id="publisherAddressCountry" value="#{publisherVersionView.publisherAddressCountry}" converter="omnifaces.SelectItemsConverter" disabled="#{not publisherVersionView.editMode}"> | ||
46 | + <f:selectItems value="#{publisherVersionView.availableCountries}" var="country" itemLabel="#{country.countryName}"/> | ||
47 | + </h:selectOneMenu> | ||
48 | + | ||
49 | + <label for="publisherTelephone">publisherTelephone</label> | ||
50 | + <input type="text" id="publisherTelephone" jsf:value='#{publisherVersionView.publisherTelephone}' jsf:disabled="#{not publisherVersionView.editMode}"/> | ||
51 | + <label for="publisherEmail">publisherEmail</label> | ||
52 | + <input type="text" id="publisherEmail" jsf:value='#{publisherVersionView.publisherEmail}' jsf:disabled="#{not publisherVersionView.editMode}"/> | ||
53 | + <label for="publisherURL">publisherURL</label> | ||
54 | + <input type="text" id="publisherURL" jsf:value='#{publisherVersionView.publisherURL}' jsf:disabled="#{not publisherVersionView.editMode}"/> | ||
55 | + | ||
56 | + <label for="publisherActive">publisherActive</label> | ||
57 | + <input type="checkbox" id="publisherActive" jsf:disabled="#{not publisherVersionView.editMode}" jsf:value="#{publisherVersionView.publisherActive}"/> | ||
58 | + | ||
59 | + <label for="publisherHistory">publisherHistory</label> | ||
60 | + <textarea id="publisherHistory" rows="" cols="" jsf:disabled="#{not publisherVersionView.editMode}" jsf:value="#{publisherVersionView.publisherHistory}"/> | ||
61 | + | ||
62 | + <div jsf:rendered="#{not publisherVersionView.newPublisher}">publisherVersionAuthor</div> | ||
63 | + <div jsf:rendered="#{not publisherVersionView.newPublisher}">#{publisherVersionView.publisherVersionAuthor.displayName}</div> | ||
64 | + <div jsf:rendered="#{not publisherVersionView.newPublisher}">publisherVersionDatetime</div> | ||
65 | + <div jsf:rendered="#{not publisherVersionView.newPublisher}">#{publisherVersionView.publisherVersionDatetime}</div> | ||
66 | + | ||
67 | + <button jsf:rendered="#{not publisherVersionView.editMode}" jsf:action="#{publisherVersionView.edit}">Edit</button> | ||
68 | + <button jsf:rendered="#{publisherVersionView.editMode}" jsf:action="#{publisherVersionView.save}">Save</button> | ||
69 | + <button jsf:rendered="#{publisherVersionView.editMode}" jsf:action="#{publisherVersionView.cancel}">Cancel</button> | ||
70 | + </h:panelGrid> | ||
71 | +</form> | ||
72 | +</body> | ||
73 | +</html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -package org.legrog.presentation; | 1 | +package org.legrog.web.user; |
2 | 2 | ||
3 | -import org.legrog.application.UserService; | 3 | +import org.legrog.entities.Person; |
4 | -import org.legrog.entities.User; | ||
5 | 4 | ||
6 | import javax.annotation.PostConstruct; | 5 | import javax.annotation.PostConstruct; |
7 | import javax.enterprise.context.RequestScoped; | 6 | import javax.enterprise.context.RequestScoped; |
... | @@ -15,19 +14,19 @@ public class ListUsersBean { | ... | @@ -15,19 +14,19 @@ public class ListUsersBean { |
15 | @Inject | 14 | @Inject |
16 | private UserService userService; | 15 | private UserService userService; |
17 | 16 | ||
18 | - private List<User> users; | 17 | + private List<Person> persons; |
19 | 18 | ||
20 | - public List<User> getUsers() { | 19 | + public List<Person> getPersons() { |
21 | - return users; | 20 | + return persons; |
22 | } | 21 | } |
23 | 22 | ||
24 | - public void setUsers(List<User> users) { | 23 | + public void setPersons(List<Person> persons) { |
25 | - this.users = users; | 24 | + this.persons = persons; |
26 | } | 25 | } |
27 | 26 | ||
28 | @PostConstruct | 27 | @PostConstruct |
29 | public void init() { | 28 | public void init() { |
30 | - users = userService.getAllUsers(); | 29 | + persons = userService.getAllUsers(); |
31 | } | 30 | } |
32 | 31 | ||
33 | } | 32 | } | ... | ... |
1 | -package org.legrog.presentation; | 1 | +package org.legrog.web.user; |
2 | 2 | ||
3 | -import org.legrog.application.SharedService; | 3 | +import org.legrog.web.xyz.SharedService; |
4 | -import org.legrog.application.UserService; | ||
5 | import org.legrog.entities.*; | 4 | import org.legrog.entities.*; |
6 | import org.slf4j.Logger; | 5 | import org.slf4j.Logger; |
7 | import org.slf4j.LoggerFactory; | 6 | import org.slf4j.LoggerFactory; |
8 | 7 | ||
9 | import javax.annotation.PostConstruct; | 8 | import javax.annotation.PostConstruct; |
10 | -import javax.enterprise.context.RequestScoped; | ||
11 | import javax.faces.bean.ManagedProperty; | 9 | import javax.faces.bean.ManagedProperty; |
12 | -import javax.enterprise.context.SessionScoped; | 10 | +import javax.faces.bean.RequestScoped; |
13 | -import javax.faces.context.ExternalContext; | 11 | +import javax.faces.bean.SessionScoped; |
14 | -import javax.faces.context.FacesContext; | ||
15 | -import javax.faces.view.ViewScoped; | ||
16 | import javax.inject.Inject; | 12 | import javax.inject.Inject; |
17 | import javax.inject.Named; | 13 | import javax.inject.Named; |
18 | -import java.io.IOException; | ||
19 | import java.util.ArrayList; | 14 | import java.util.ArrayList; |
20 | import java.util.Date; | 15 | import java.util.Date; |
21 | import java.util.List; | 16 | import java.util.List; |
... | @@ -23,110 +18,111 @@ import java.util.List; | ... | @@ -23,110 +18,111 @@ import java.util.List; |
23 | @Named | 18 | @Named |
24 | @RequestScoped | 19 | @RequestScoped |
25 | public class UpdateUserBean { | 20 | public class UpdateUserBean { |
26 | - @Inject | 21 | + |
22 | + Logger logger = LoggerFactory.getLogger(getClass()); | ||
23 | + | ||
27 | private UserService userService; | 24 | private UserService userService; |
28 | - @Inject | ||
29 | private SharedService sharedService; | 25 | private SharedService sharedService; |
30 | 26 | ||
27 | + private List<DisplayNameMask> allDisplayNameMasks; | ||
28 | + private List<UserRole> availableUserRoles; | ||
29 | + private List<UserProperty> availableUserProperties; | ||
30 | + | ||
31 | @ManagedProperty("#{param.userId}") | 31 | @ManagedProperty("#{param.userId}") |
32 | private int userId; | 32 | private int userId; |
33 | - | ||
34 | private String username; | 33 | private String username; |
35 | - | ||
36 | private String firstName; | 34 | private String firstName; |
37 | - | ||
38 | private String lastName; | 35 | private String lastName; |
39 | - | ||
40 | private String nickName; | 36 | private String nickName; |
41 | - | ||
42 | private DisplayNameMask displayNameMask; | 37 | private DisplayNameMask displayNameMask; |
43 | - | ||
44 | - private List<DisplayNameMask> allDisplayNameMasks; | ||
45 | - | ||
46 | - private List<UserRole> availableUserRoles; | ||
47 | - | ||
48 | - private List<UserProperty> availableUserProperties; | ||
49 | - | ||
50 | private String email; | 38 | private String email; |
51 | - | ||
52 | private boolean anonymous; | 39 | private boolean anonymous; |
53 | - | ||
54 | private String password; | 40 | private String password; |
55 | - | ||
56 | private List<UserRole> roles; | 41 | private List<UserRole> roles; |
57 | - | ||
58 | private String presentation; | 42 | private String presentation; |
59 | - | ||
60 | private List<UserAttribute> userAttributes; | 43 | private List<UserAttribute> userAttributes; |
61 | - | ||
62 | private boolean criticProvider; | 44 | private boolean criticProvider; |
63 | - | ||
64 | private boolean visible; | 45 | private boolean visible; |
65 | - | ||
66 | private boolean activated; | 46 | private boolean activated; |
67 | 47 | ||
48 | + @Inject | ||
49 | + public UpdateUserBean(UserService userService, SharedService sharedService) { | ||
50 | + this.userService = userService; | ||
51 | + this.sharedService = sharedService; | ||
52 | + } | ||
68 | 53 | ||
54 | + //no args constructor to make it proxyable | ||
55 | + UpdateUserBean() { | ||
56 | + } | ||
69 | 57 | ||
70 | - public String add() | 58 | + |
71 | - { | 59 | + @PostConstruct |
72 | - User user = new User(); | 60 | + public void init() { |
73 | - user.setActivated(activated); | 61 | + logger.info("init"); |
74 | - user.setAnonymous(anonymous); | 62 | + allDisplayNameMasks = sharedService.getAllDisplayNameMasks(); |
63 | + availableUserRoles = sharedService.getAvailableUserRoles(); | ||
64 | + availableUserProperties = sharedService.getAvailableUserProperties(); | ||
65 | + } | ||
66 | + | ||
67 | + | ||
68 | + public String add() { | ||
69 | + Person person = new Person(); | ||
70 | + person.setActivated(activated); | ||
71 | + person.setAnonymous(anonymous); | ||
75 | if (userAttributes != null) { | 72 | if (userAttributes != null) { |
76 | - user.setAttributes(userAttributes); | 73 | + person.setAttributes(userAttributes); |
77 | } | 74 | } |
78 | - user.setCriticProvider(criticProvider); | 75 | + person.setCriticProvider(criticProvider); |
79 | if (displayNameMask != null) { | 76 | if (displayNameMask != null) { |
80 | - user.setDisplayNameMask(displayNameMask); | 77 | + person.setDisplayNameMask(displayNameMask); |
81 | } else { | 78 | } else { |
82 | - user.setDisplayNameMask(DisplayNameMask.PRENOMNOM); | 79 | + person.setDisplayNameMask(DisplayNameMask.PRENOMNOM); |
83 | } | 80 | } |
84 | - user.setEmail(email); | 81 | + person.setEmail(email); |
85 | - user.setFirstName(firstName); | 82 | + person.setFirstName(firstName); |
86 | - user.setLastName(lastName); | 83 | + person.setLastName(lastName); |
87 | if (nickName != null && !nickName.isEmpty()) { | 84 | if (nickName != null && !nickName.isEmpty()) { |
88 | - user.setNickName(nickName); | 85 | + person.setNickName(nickName); |
89 | } | 86 | } |
90 | - user.setPassword(password); | 87 | + person.setPassword(password); |
91 | if (presentation != null) { | 88 | if (presentation != null) { |
92 | - user.setPresentation(presentation); | 89 | + person.setPresentation(presentation); |
93 | } | 90 | } |
94 | if (roles != null) { | 91 | if (roles != null) { |
95 | - user.setRoles(roles); | 92 | + person.setRoles(roles); |
96 | } | 93 | } |
97 | - user.setUsername(username); | 94 | + person.setUsername(username); |
98 | - user.setVisible(visible); | 95 | + person.setVisible(visible); |
99 | - user.setCreationDate(new Date()); | 96 | + person.setCreationDate(new Date()); |
100 | - userService.addUser(user); | 97 | + userService.addUser(person); |
101 | return "success"; | 98 | return "success"; |
102 | } | 99 | } |
103 | 100 | ||
104 | public String prepareUpdate(int userId) { | 101 | public String prepareUpdate(int userId) { |
105 | - Logger logger = LoggerFactory.getLogger(UpdateUserBean.class); | ||
106 | logger.info("prepareUpdate"); | 102 | logger.info("prepareUpdate"); |
107 | 103 | ||
108 | - logger.info("userId ="+userId); | 104 | + logger.info("userId =" + userId); |
109 | this.userId = userId; | 105 | this.userId = userId; |
110 | if (userId != 0) { | 106 | if (userId != 0) { |
111 | - User user = userService.findUserById(userId); | 107 | + Person person = userService.findUserById(userId); |
112 | - if (user != null) { | 108 | + if (person != null) { |
113 | - activated = user.isActivated(); | 109 | + activated = person.isActivated(); |
114 | - anonymous = user.isAnonymous(); | 110 | + anonymous = person.isAnonymous(); |
115 | - userAttributes = user.getAttributes(); | 111 | + userAttributes = person.getAttributes(); |
116 | - criticProvider = user.isCriticProvider(); | 112 | + criticProvider = person.isCriticProvider(); |
117 | - displayNameMask = user.getDisplayNameMask(); | 113 | + displayNameMask = person.getDisplayNameMask(); |
118 | - email = user.getEmail(); | 114 | + email = person.getEmail(); |
119 | - firstName = user.getFirstName(); | 115 | + firstName = person.getFirstName(); |
120 | - lastName = user.getLastName(); | 116 | + lastName = person.getLastName(); |
121 | - nickName = user.getNickName(); | 117 | + nickName = person.getNickName(); |
122 | - password = user.getPassword(); | 118 | + password = person.getPassword(); |
123 | - presentation = user.getPresentation(); | 119 | + presentation = person.getPresentation(); |
124 | - roles = user.getRoles(); | 120 | + roles = person.getRoles(); |
125 | if (roles == null) { | 121 | if (roles == null) { |
126 | roles = new ArrayList<UserRole>(); | 122 | roles = new ArrayList<UserRole>(); |
127 | } | 123 | } |
128 | - username = user.getUsername(); | 124 | + username = person.getUsername(); |
129 | - visible = user.isVisible(); | 125 | + visible = person.isVisible(); |
130 | return "updateUser.xhtml"; | 126 | return "updateUser.xhtml"; |
131 | } | 127 | } |
132 | } | 128 | } |
... | @@ -134,39 +130,29 @@ public class UpdateUserBean { | ... | @@ -134,39 +130,29 @@ public class UpdateUserBean { |
134 | } | 130 | } |
135 | 131 | ||
136 | public String update() { | 132 | public String update() { |
137 | - Logger logger = LoggerFactory.getLogger(UpdateUserBean.class); | ||
138 | logger.info("update"); | 133 | logger.info("update"); |
139 | 134 | ||
140 | - logger.info("userId ="+userId); | 135 | + logger.info("userId =" + userId); |
141 | - User user = userService.findUserById(userId); | 136 | + Person person = userService.findUserById(userId); |
142 | - user.setActivated(activated); | 137 | + person.setActivated(activated); |
143 | - user.setAnonymous(anonymous); | 138 | + person.setAnonymous(anonymous); |
144 | - user.setAttributes(userAttributes); | 139 | + person.setAttributes(userAttributes); |
145 | - user.setCriticProvider(criticProvider); | 140 | + person.setCriticProvider(criticProvider); |
146 | - user.setDisplayNameMask(displayNameMask); | 141 | + person.setDisplayNameMask(displayNameMask); |
147 | - user.setEmail(email); | 142 | + person.setEmail(email); |
148 | - user.setFirstName(firstName); | 143 | + person.setFirstName(firstName); |
149 | - user.setLastName(lastName); | 144 | + person.setLastName(lastName); |
150 | - user.setNickName(nickName); | 145 | + person.setNickName(nickName); |
151 | - user.setPassword(password); | 146 | + person.setPassword(password); |
152 | - user.setPresentation(presentation); | 147 | + person.setPresentation(presentation); |
153 | - user.setRoles(roles); | 148 | + person.setRoles(roles); |
154 | - user.setUsername(username); | 149 | + person.setUsername(username); |
155 | - user.setVisible(visible); | 150 | + person.setVisible(visible); |
156 | - userService.updateUser(user); | 151 | + userService.updateUser(person); |
157 | return "success"; | 152 | return "success"; |
158 | } | 153 | } |
159 | 154 | ||
160 | 155 | ||
161 | - @PostConstruct | ||
162 | - public void init() { | ||
163 | - Logger logger = LoggerFactory.getLogger(UpdateUserBean.class); | ||
164 | - logger.info("init"); | ||
165 | - allDisplayNameMasks = sharedService.getAllDisplayNameMasks(); | ||
166 | - availableUserRoles = sharedService.getAvailableUserRoles(); | ||
167 | - availableUserProperties = sharedService.getAvailableUserProperties(); | ||
168 | - } | ||
169 | - | ||
170 | public List<UserRole> getAvailableUserRoles() { | 156 | public List<UserRole> getAvailableUserRoles() { |
171 | return availableUserRoles; | 157 | return availableUserRoles; |
172 | } | 158 | } | ... | ... |
1 | +package org.legrog.web.user; | ||
2 | + | ||
3 | +import org.legrog.entities.Person; | ||
4 | +import org.legrog.entities.PersonRepository; | ||
5 | + | ||
6 | +import javax.ejb.Stateless; | ||
7 | +import javax.inject.Inject; | ||
8 | +import java.util.List; | ||
9 | + | ||
10 | +@Stateless | ||
11 | +public class UserServiceSpring implements UserService { | ||
12 | + @Inject | ||
13 | + PersonRepository personRepository; | ||
14 | + | ||
15 | + public void addUser(Person person) { | ||
16 | + personRepository.save(person); | ||
17 | + } | ||
18 | + | ||
19 | + public List<Person> getAllUsers() { | ||
20 | + return personRepository.findAll(); | ||
21 | + } | ||
22 | + | ||
23 | + public Person findUserById(int id) { | ||
24 | + return personRepository.findOne(new Integer(id)); | ||
25 | + } | ||
26 | + | ||
27 | + public void updateUser(Person person) { | ||
28 | + personRepository.save(person); | ||
29 | + } | ||
30 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
File moved
... | @@ -32,17 +32,17 @@ | ... | @@ -32,17 +32,17 @@ |
32 | 32 | ||
33 | <div id="listElements"> | 33 | <div id="listElements"> |
34 | 34 | ||
35 | - <h:commandLink styleClass="fRight acLink" action="add" rendered="#{not empty listUsersBean.users}" > | 35 | + <h:commandLink styleClass="fRight acLink" action="add" rendered="#{not empty listUsersBean.persons}" > |
36 | <img src="/images/structure/vide.gif" class="icAddC" alt="" title="Crer un nouvel utilisateur" /> | 36 | <img src="/images/structure/vide.gif" class="icAddC" alt="" title="Crer un nouvel utilisateur" /> |
37 | Nouvel Utilisateur | 37 | Nouvel Utilisateur |
38 | </h:commandLink> | 38 | </h:commandLink> |
39 | 39 | ||
40 | - <p:dataTable id="tableElements" rendered="#{not empty listUsersBean.users}" | 40 | + <p:dataTable id="tableElements" rendered="#{not empty listUsersBean.persons}" |
41 | - var="user" value="#{listUsersBean.users}" | 41 | + var="person" value="#{listUsersBean.persons}" |
42 | styleClass="results" rowClasses="altRichRow,altRow"> | 42 | styleClass="results" rowClasses="altRichRow,altRow"> |
43 | <!-- TODO Grer la pagination --> | 43 | <!-- TODO Grer la pagination --> |
44 | -<!-- <p:dataTable id="tableElements" rendered="#{listUsersBean.users.size>0}" | 44 | +<!-- <p:dataTable id="tableElements" rendered="#{listUsersBean.persons.size>0}" |
45 | - var="user" value="#{listUsersBean.users}" rows="#{userListMgr.pageSize}" | 45 | + var="person" value="#{listUsersBean.persons}" rows="#{userListMgr.pageSize}" |
46 | styleClass="results" rowClasses="altRichRow,altRow">--> | 46 | styleClass="results" rowClasses="altRichRow,altRow">--> |
47 | <f:facet name="header"> | 47 | <f:facet name="header"> |
48 | <p:dataScroller for="tableElements" | 48 | <p:dataScroller for="tableElements" |
... | @@ -61,35 +61,35 @@ | ... | @@ -61,35 +61,35 @@ |
61 | </h:commandLink>--> | 61 | </h:commandLink>--> |
62 | </p:column> | 62 | </p:column> |
63 | <p:column> | 63 | <p:column> |
64 | - <h:commandLink action="#{updateUserBean.prepareUpdate(user.userId)}"> | 64 | + <h:commandLink action="#{updateUserBean.prepareUpdate(person.userId)}"> |
65 | <img src="/images/structure/vide.gif" class="icEdit" alt="Modifier" title="Modifier" /> | 65 | <img src="/images/structure/vide.gif" class="icEdit" alt="Modifier" title="Modifier" /> |
66 | </h:commandLink> | 66 | </h:commandLink> |
67 | </p:column> | 67 | </p:column> |
68 | - <p:column styleClass="third" sortBy="#{user.username}"> | 68 | + <p:column styleClass="third" sortBy="#{person.username}"> |
69 | <f:facet name="header">Identifiant</f:facet> | 69 | <f:facet name="header">Identifiant</f:facet> |
70 | <!-- TODO Dcider de l'avenir de traceable --> | 70 | <!-- TODO Dcider de l'avenir de traceable --> |
71 | <ui:remove> | 71 | <ui:remove> |
72 | - <!-- <h:outputLink value="#{user.traceable.urlRewrite}">--> | 72 | + <!-- <h:outputLink value="#{person.traceable.urlRewrite}">--> |
73 | </ui:remove> | 73 | </ui:remove> |
74 | - <h:outputText value="#{user.username}" /> | 74 | + <h:outputText value="#{person.username}" /> |
75 | <!-- </h:outputLink>--> | 75 | <!-- </h:outputLink>--> |
76 | </p:column> | 76 | </p:column> |
77 | - <p:column styleClass="third" sortBy="#{user.firstName} #{user.lastName}"> | 77 | + <p:column styleClass="third" sortBy="#{person.firstName} #{person.lastName}"> |
78 | <f:facet name="header">Nom</f:facet> | 78 | <f:facet name="header">Nom</f:facet> |
79 | <ui:remove> | 79 | <ui:remove> |
80 | - <!--<h:outputLink value="#{user.traceable.urlRewrite}">--> | 80 | + <!--<h:outputLink value="#{person.traceable.urlRewrite}">--> |
81 | </ui:remove> | 81 | </ui:remove> |
82 | - <h:outputText value="#{user.firstName} #{user.lastName}" /> | 82 | + <h:outputText value="#{person.firstName} #{person.lastName}" /> |
83 | <!--</h:outputLink>--> | 83 | <!--</h:outputLink>--> |
84 | </p:column> | 84 | </p:column> |
85 | - <p:column styleClass="third" sortBy="#{user.email}"> | 85 | + <p:column styleClass="third" sortBy="#{person.email}"> |
86 | <f:facet name="header">Email</f:facet> | 86 | <f:facet name="header">Email</f:facet> |
87 | - <h:outputText value="#{user.email}" /> | 87 | + <h:outputText value="#{person.email}" /> |
88 | </p:column> | 88 | </p:column> |
89 | <p:column> | 89 | <p:column> |
90 | - <h:graphicImage value="/images/structure/dVert.gif" rendered="#{user.visible and user.activated}" title="Utilisateur activ" /> | 90 | + <h:graphicImage value="/images/structure/dVert.gif" rendered="#{person.visible and person.activated}" title="Utilisateur activ" /> |
91 | - <h:graphicImage value="/images/structure/dOrange.gif" rendered="#{(not user.visible) and user.activated}" title="Utilisateur dsactiv" /> | 91 | + <h:graphicImage value="/images/structure/dOrange.gif" rendered="#{(not person.visible) and person.activated}" title="Utilisateur dsactiv" /> |
92 | - <h:graphicImage value="/images/structure/dRouge.gif" rendered="#{not user.activated}" title="Utilisateur non enregistr" /> | 92 | + <h:graphicImage value="/images/structure/dRouge.gif" rendered="#{not person.activated}" title="Utilisateur non enregistr" /> |
93 | </p:column> | 93 | </p:column> |
94 | <f:facet name="footer"> | 94 | <f:facet name="footer"> |
95 | <h:commandLink action="add" value="Crer un nouvel utilisateur" > | 95 | <h:commandLink action="add" value="Crer un nouvel utilisateur" > |
... | @@ -99,7 +99,7 @@ | ... | @@ -99,7 +99,7 @@ |
99 | </div> | 99 | </div> |
100 | <p> | 100 | <p> |
101 | <h:commandLink action="add" value="Crer un nouvel utilisateur" | 101 | <h:commandLink action="add" value="Crer un nouvel utilisateur" |
102 | - rendered="#{empty listUsersBean.users}"> | 102 | + rendered="#{empty listUsersBean.persons}"> |
103 | </h:commandLink> | 103 | </h:commandLink> |
104 | </p> | 104 | </p> |
105 | </h:form> | 105 | </h:form> | ... | ... |
... | @@ -12,8 +12,8 @@ | ... | @@ -12,8 +12,8 @@ |
12 | </h:commandLink> | 12 | </h:commandLink> |
13 | </h:form> | 13 | </h:form> |
14 | <ul> | 14 | <ul> |
15 | - <ui:repeat value="#{listUsersBean.users}" var="user"> | 15 | + <ui:repeat value="#{listUsersBean.persons}" var="person"> |
16 | - <li>#{user.username}</li> | 16 | + <li>#{person.username}</li> |
17 | </ui:repeat> | 17 | </ui:repeat> |
18 | </ul> | 18 | </ul> |
19 | </f:view> | 19 | </f:view> | ... | ... |
1 | -package org.legrog.presentation; | 1 | +package org.legrog.web.xyz; |
2 | 2 | ||
3 | -import org.legrog.application.SharedService; | ||
4 | import org.legrog.entities.Country; | 3 | import org.legrog.entities.Country; |
5 | 4 | ||
6 | import javax.enterprise.context.RequestScoped; | 5 | import javax.enterprise.context.RequestScoped; | ... | ... |
1 | -package org.legrog.application; | 1 | +package org.legrog.web.xyz; |
2 | 2 | ||
3 | -import org.legrog.entities.Country; | 3 | +import org.legrog.entities.*; |
4 | -import org.legrog.entities.DisplayNameMask; | ||
5 | -import org.legrog.entities.UserProperty; | ||
6 | -import org.legrog.entities.UserRole; | ||
7 | 4 | ||
8 | import java.util.List; | 5 | import java.util.List; |
9 | 6 | ||
... | @@ -19,4 +16,5 @@ public interface SharedService { | ... | @@ -19,4 +16,5 @@ public interface SharedService { |
19 | 16 | ||
20 | List<UserProperty> getAvailableUserProperties(); | 17 | List<UserProperty> getAvailableUserProperties(); |
21 | 18 | ||
19 | + Person getCurrentUser(); | ||
22 | } | 20 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | -package org.legrog.application; | 1 | +package org.legrog.web.xyz; |
2 | 2 | ||
3 | import org.legrog.entities.*; | 3 | import org.legrog.entities.*; |
4 | +import org.legrog.web.user.UserService; | ||
4 | //import org.slf4j.Logger; | 5 | //import org.slf4j.Logger; |
5 | //import org.slf4j.LoggerFactory; | 6 | //import org.slf4j.LoggerFactory; |
6 | 7 | ||
7 | import javax.ejb.Stateless; | 8 | import javax.ejb.Stateless; |
8 | import javax.inject.Inject; | 9 | import javax.inject.Inject; |
9 | import java.util.List; | 10 | import java.util.List; |
11 | +import java.util.Random; | ||
10 | import java.util.Vector; | 12 | import java.util.Vector; |
11 | 13 | ||
12 | @Stateless | 14 | @Stateless |
... | @@ -18,6 +20,8 @@ public class SharedServiceSpring implements SharedService { | ... | @@ -18,6 +20,8 @@ public class SharedServiceSpring implements SharedService { |
18 | UserRoleRepository userRoleRepository; | 20 | UserRoleRepository userRoleRepository; |
19 | @Inject | 21 | @Inject |
20 | UserPropertyRepository userPropertyRepository; | 22 | UserPropertyRepository userPropertyRepository; |
23 | + @Inject | ||
24 | + UserService userService; | ||
21 | 25 | ||
22 | private List<DisplayNameMask> allDisplayNameMasks; | 26 | private List<DisplayNameMask> allDisplayNameMasks; |
23 | 27 | ||
... | @@ -47,4 +51,13 @@ public class SharedServiceSpring implements SharedService { | ... | @@ -47,4 +51,13 @@ public class SharedServiceSpring implements SharedService { |
47 | } | 51 | } |
48 | 52 | ||
49 | public List<UserProperty> getAvailableUserProperties() { return userPropertyRepository.findAll(); } | 53 | public List<UserProperty> getAvailableUserProperties() { return userPropertyRepository.findAll(); } |
54 | + | ||
55 | + public Person getCurrentUser() { | ||
56 | + // TODO Remplacer l'astuce par une vraie récupération de l'utilisateur | ||
57 | + List<Person> persons = userService.getAllUsers(); | ||
58 | + Random random = new Random(); | ||
59 | + Person person = persons.get(random.nextInt(persons.size())); | ||
60 | + // End TODO | ||
61 | + return person; | ||
62 | + } | ||
50 | } | 63 | } | ... | ... |
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | + | ||
3 | +<body jsf:id="root-body" xmlns="http://www.w3.org/1999/xhtml" | ||
4 | + xmlns:h="http://xmlns.jcp.org/jsf/html" | ||
5 | + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" | ||
6 | + xmlns:f="http://xmlns.jcp.org/jsf/core" | ||
7 | + xmlns:jsf="http://xmlns.jcp.org/jsf"> | ||
8 | +<p> | ||
9 | + I'm looking for something | ||
10 | +</p> | ||
11 | + | ||
12 | +<p> | ||
13 | +And this is my string : #{testRouteView.foo} | ||
14 | +</p> | ||
15 | + | ||
16 | + | ||
17 | +<p> | ||
18 | + And this is another string : #{testRouteView.bar} | ||
19 | +</p> | ||
20 | + | ||
21 | +</body> |
1 | +package org.legrog.web.xyz; | ||
2 | + | ||
3 | +import org.ocpsoft.rewrite.annotation.Join; | ||
4 | +import org.ocpsoft.rewrite.annotation.Parameter; | ||
5 | +import org.ocpsoft.rewrite.annotation.RequestAction; | ||
6 | +import org.ocpsoft.rewrite.annotation.RewriteConfiguration; | ||
7 | +import org.ocpsoft.rewrite.config.Configuration; | ||
8 | +import org.ocpsoft.rewrite.config.ConfigurationBuilder; | ||
9 | +import org.ocpsoft.rewrite.el.El; | ||
10 | +import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider; | ||
11 | + | ||
12 | +import javax.enterprise.context.RequestScoped; | ||
13 | +import javax.inject.Named; | ||
14 | +import javax.servlet.ServletContext; | ||
15 | +import java.io.Serializable; | ||
16 | + | ||
17 | +@Named | ||
18 | +@RequestScoped | ||
19 | +@Join(path = "/TestRoute/{bar}", to = "/xyz/TestRoute.jsf") | ||
20 | +public class TestRouteView implements Serializable { | ||
21 | + | ||
22 | + String foo = "my first String"; | ||
23 | + | ||
24 | + @Parameter | ||
25 | + String bar; | ||
26 | + | ||
27 | + @RequestAction | ||
28 | + public void init() { | ||
29 | + if (bar == null) { | ||
30 | + foo = "my modified string without bar"; | ||
31 | + } else { | ||
32 | + foo = "my string modified with "+ bar; | ||
33 | + } | ||
34 | + | ||
35 | + } | ||
36 | + | ||
37 | + public String getFoo() { | ||
38 | + return foo; | ||
39 | + } | ||
40 | + | ||
41 | + public void setFoo(String foo) { | ||
42 | + this.foo = foo; | ||
43 | + } | ||
44 | + | ||
45 | + public String getBar() { | ||
46 | + return bar; | ||
47 | + } | ||
48 | + | ||
49 | + public void setBar(String bar) { | ||
50 | + this.bar = bar; | ||
51 | + } | ||
52 | + | ||
53 | + @RewriteConfiguration | ||
54 | + public static class RewriteConfig extends HttpConfigurationProvider { | ||
55 | + | ||
56 | + public Configuration getConfiguration(ServletContext context) { | ||
57 | + return ConfigurationBuilder.begin() | ||
58 | + .addRule(org.ocpsoft.rewrite.servlet.config.rule.Join.path("/TestRoute2/{bar}").to("/xyz/TestRoute.jsf")) | ||
59 | + .where("bar").bindsTo(El.property("testRouteView.bar")) | ||
60 | + ; | ||
61 | + } | ||
62 | + | ||
63 | + public int priority() { | ||
64 | + return 0; | ||
65 | + } | ||
66 | + } | ||
67 | +} |
File moved
... | @@ -10,6 +10,10 @@ | ... | @@ -10,6 +10,10 @@ |
10 | <property name="hibernate.hbm2ddl.auto" value="create-drop" /> | 10 | <property name="hibernate.hbm2ddl.auto" value="create-drop" /> |
11 | <property name="hibernate.hbm2ddl.import_files" value="import.sql"/> | 11 | <property name="hibernate.hbm2ddl.import_files" value="import.sql"/> |
12 | <property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" /> | 12 | <property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" /> |
13 | +<!-- DDL control OFF | ||
14 | + <property name="hibernate.show_sql" value="true"/> | ||
15 | + <property name="hibernate.format_sql" value="true"/> | ||
16 | +--> | ||
13 | </properties> | 17 | </properties> |
14 | </persistence-unit> | 18 | </persistence-unit> |
15 | 19 | ... | ... |
src/main/resources/import.sql
0 → 100644
1 | +-- INSERT avec identifiants car GenerationType.AUTO a du être changé en GenerationType.IDENTITY (2016-11-21) | ||
2 | +INSERT INTO ActionType (actionTypeId, actionTypeName) VALUES (1, 'Validate'); | ||
3 | +INSERT INTO Country (countryId, countryName) VALUES | ||
4 | + (1, 'France'), | ||
5 | + (2, 'Suisse'), | ||
6 | + (3, 'Belgique'), | ||
7 | + (4, 'Canada'), | ||
8 | + (5, 'États-Unis d''Amérique'), | ||
9 | + (6, 'Australie'), | ||
10 | + (7, 'Espagne'), | ||
11 | + (8, 'Portugal'), | ||
12 | + (9, 'Royaume-Uni'), | ||
13 | + (10, 'Allemagne'), | ||
14 | + (11, 'Pologne'), | ||
15 | + (12, 'Italie'); | ||
16 | +INSERT INTO Person (userId, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, | ||
17 | + criticProvider) VALUES | ||
18 | + (1, 'one', 'one', 'Derrick', 'Moss', 'one', 'one@raza.org', TRUE, FALSE, TRUE, TRUE), | ||
19 | + (2, 'two', 'two', 'Portia', 'Lin', 'two', 'two@raza.org', TRUE, FALSE, TRUE, TRUE), | ||
20 | + (3, 'three', 'three', 'Marcus', 'Boone', 'three', 'three@raza.org', TRUE, FALSE, TRUE, TRUE), | ||
21 | + (4, 'four', 'four', 'Ryo', 'Tetsuda', 'four', 'four@raza.org', TRUE, FALSE, TRUE, TRUE), | ||
22 | + (5, 'five', 'five', 'Emily', 'Kolburn', 'five', 'five@raza.org', TRUE, FALSE, TRUE, TRUE), | ||
23 | + (6, 'six', 'six', 'Kal', 'Varrik', 'six', 'six@raza.org', TRUE, FALSE, TRUE, TRUE); | ||
24 | + | ||
25 | +INSERT INTO Publisher (publisherId) VALUES (1), (2), (3), (4); | ||
26 | + | ||
27 | +INSERT INTO PublisherVersion (publisherVersionId, publisher_publisherId, publisherName, publisherStreetAddress, | ||
28 | + publisherPostalCode, publisherPostOfficeBoxNumber, publisherAddressRegion, | ||
29 | + publisherAddressLocality, publisherAddressCountry_countryId, publisherTelephone, | ||
30 | + publisherEmail, publisherURL, publisherActive, publisherHistory, | ||
31 | + publisherVersionAuthor_userId, publisherVersionDatetime) VALUES | ||
32 | + (1, 1, 'GRôG', '', '', '', '', '', 1, '', 'passerelle@legrog.org', 'www.legrog.org', TRUE, 'Ouvert…', 1, {ts '2000-05-08 00:00:47'}), | ||
33 | + (2, 2, 'Rôliste TV', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'www.rolistetv.com', TRUE, 'Ouvert…', 3, {ts '2010-05-20 08:43:16'}), | ||
34 | + (3, 3, 'La Vouivre', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'la-vouivre.com', TRUE, 'Ouvert…', 1, {ts '2000-01-01 00:02:33'}), | ||
35 | + (4, 3, 'La Vouivre', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'la-vouivre.com', FALSE, '… en 2015', 2, {ts '2015-01-01 00:05:22'}), | ||
36 | + (5, 4, 'Archmagus', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'archimage.net', TRUE, 'Ouvert…', 4, {ts '2016-10-14 10:56:03'}); | ||
37 | +UPDATE Publisher SET validatedVersion_publisherVersionId = 1 WHERE publisherId = 1; | ||
38 | +UPDATE Publisher SET validatedVersion_publisherVersionId = 2 WHERE publisherId = 2; | ||
39 | +UPDATE Publisher SET validatedVersion_publisherVersionId = 4 WHERE publisherId = 3; | ||
40 | + | ||
41 | +INSERT INTO PublisherAction (publisherActionId, actionType_actionTypeId, publisherActionAuthor_userId, | ||
42 | + publisherVersion_publisherVersionId, publisherActionDatetime, publisher_publisherId) VALUES | ||
43 | + (1, 1, 2, 1, {ts '2000-05-08 12:00:28'}, 1), | ||
44 | + (2, 1, 1, 2, {ts '2010-06-20 14:27:35'}, 2), | ||
45 | + (3, 1, 1, 4, {ts '2015-01-01 16:18:17'}, 3); | ||
46 | + | ||
47 | +INSERT INTO UserRole (userRoleId, rolename, visible) VALUES | ||
48 | + (1, 'VISITEUR', TRUE), | ||
49 | + (2,'RECRUE', TRUE), | ||
50 | + (3, 'CONTRIBUTEUR', TRUE), | ||
51 | + (4, 'ADMINISTRATEUR', TRUE), | ||
52 | + (5, 'RETRAITE', TRUE), | ||
53 | + (6, 'ASSOCE', TRUE); | ||
54 | +INSERT INTO UserProperty (userPropertyId, name, tag, visible) VALUES | ||
55 | + (1, 'nb_vignettes', 'Nombre de vignettes en home', TRUE), | ||
56 | + (2, 'avatar', 'Lien vers une icône ou une photo', TRUE), | ||
57 | + (3, 'tagline', 'Ligne de présentation pour les contributeurs', TRUE), | ||
58 | + (4, 'taille_listes', 'Nombre d''éléments affichés dans les listes', TRUE), | ||
59 | + (5,'skin', 'Thème visuel', TRUE); | ||
60 | + | ||
61 | +INSERT INTO Person_UserRole VALUES (1,2); | ||
62 | +INSERT INTO Person_UserRole VALUES (2,2); | ||
63 | +INSERT INTO Person_UserRole VALUES (3,2); | ||
64 | +INSERT INTO Person_UserRole VALUES (4,2); | ||
65 | +INSERT INTO Person_UserRole VALUES (5,2); | ||
66 | +INSERT INTO Person_UserRole VALUES (6,2); | ||
67 | +INSERT INTO Person_UserRole VALUES (5,4); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
src/main/resources/logback.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<configuration> | ||
3 | + | ||
4 | + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
5 | + <layout class="ch.qos.logback.classic.PatternLayout"> | ||
6 | + <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern> | ||
7 | + </layout> | ||
8 | + </appender> | ||
9 | + | ||
10 | + <logger name="org.legrog" level="DEBUG"/> | ||
11 | + <logger name="org.legrog.web.publisher" level="TRACE"/> | ||
12 | + | ||
13 | + <!-- Liste incomplète pour diagnostiquer si nécessaire --> | ||
14 | + <logger name="org.hibernate" level="TRACE"/> | ||
15 | + <logger name="org.hibernate.SQL" level="WARN"/> | ||
16 | + <logger name="org.hibernate.annotations" level="WARN"/> | ||
17 | + <logger name="org.hibernate.boot" level="WARN"/> | ||
18 | + <logger name="org.hibernate.boot.archive" level="WARN"/> | ||
19 | + <logger name="org.hibernate.boot.cfgxml" level="WARN"/> | ||
20 | + <logger name="org.hibernate.boot.internal" level="WARN"/> | ||
21 | + <logger name="org.hibernate.boot.jaxb" level="WARN"/> | ||
22 | + <logger name="org.hibernate.boot.model" level="WARN"/> | ||
23 | + <logger name="org.hibernate.boot.registry" level="WARN"/> | ||
24 | + <logger name="org.hibernate.boot.registry.classloading" level="WARN"/> | ||
25 | + <logger name="org.hibernate.boot.registry.internal" level="WARN"/> | ||
26 | + <logger name="org.hibernate.boot.registry.selector" level="WARN"/> | ||
27 | + <logger name="org.hibernate.boot.spi" level="WARN"/> | ||
28 | + <logger name="org.hibernate.cache" level="WARN"/> | ||
29 | + <logger name="org.hibernate.cfg" level="WARN"/> | ||
30 | + <logger name="org.hibernate.cfg.Environment" level="WARN"/> | ||
31 | + <logger name="org.hibernate.cfg.AnnotationBinder" level="WARN"/> | ||
32 | + <logger name="org.hibernate.cfg.Ejb3Column" level="WARN"/> | ||
33 | + <logger name="org.hibernate.cfg.AbstractPropertyHolder" level="WARN"/> | ||
34 | + <logger name="org.hibernate.cfg.AnnotationBinder" level="WARN"/> | ||
35 | + <logger name="org.hibernate.cfg.CollectionSecondPass" level="WARN"/> | ||
36 | + <logger name="org.hibernate.cfg.Settings" level="WARN"/> | ||
37 | + <logger name="org.hibernate.cfg.annotations" level="WARN"/> | ||
38 | + <logger name="org.hibernate.cfg.beanvalidation" level="WARN"/> | ||
39 | + <logger name="org.hibernate.dialect" level="WARN"/> | ||
40 | + <logger name="org.hibernate.engine" level="WARN"/> | ||
41 | + <logger name="org.hibernate.event.internal" level="WARN"/> | ||
42 | + <logger name="org.hibernate.hql.antlr" level="WARN"/> | ||
43 | + <logger name="org.hibernate.hql.internal" level="WARN"/> | ||
44 | + <logger name="org.hibernate.id" level="WARN"/> | ||
45 | + <logger name="org.hibernate.integrator" level="WARN"/> | ||
46 | + <logger name="org.hibernate.internal" level="WARN"/> | ||
47 | + <logger name="org.hibernate.jpa" level="WARN"/> | ||
48 | + <logger name="org.hibernate.loader" level="WARN"/> | ||
49 | + <logger name="org.hibernate.mapping" level="WARN"/> | ||
50 | + <logger name="org.hibernate.persister" level="WARN"/> | ||
51 | + <logger name="org.hibernate.resource" level="WARN"/> | ||
52 | + <logger name="org.hibernate.resource.transaction.backend.jta.internal" level="WARN"/> | ||
53 | + <logger name="org.hibernate.resource.jdbc.internal" level="WARN"/> | ||
54 | + <logger name="org.hibernate.secure" level="WARN"/> | ||
55 | + <logger name="org.hibernate.service" level="WARN"/> | ||
56 | + <logger name="org.hibernate.stat.internal" level="WARN"/> | ||
57 | + <logger name="org.hibernate.stat.spi" level="WARN"/> | ||
58 | + <logger name="org.hibernate.tool" level="TRACE"/> | ||
59 | + <logger name="org.hibernate.type" level="WARN"/> | ||
60 | + <logger name="org.hibernate.validator" level="WARN"/> | ||
61 | + | ||
62 | + | ||
63 | + <root level="warn"> | ||
64 | + <appender-ref ref="STDOUT" /> | ||
65 | + </root> | ||
66 | +</configuration> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -INSERT INTO Country (countryName) VALUES ('France'); | ||
2 | -INSERT INTO Country (countryName) VALUES ('Suisse'); | ||
3 | -INSERT INTO Country (countryName) VALUES ('Belgique'); | ||
4 | -INSERT INTO Country (countryName) VALUES ('Canada'); | ||
5 | -INSERT INTO Country (countryName) VALUES ('États-Unis d''Amérique'); | ||
6 | -INSERT INTO Country (countryName) VALUES ('Australie'); | ||
7 | -INSERT INTO Country (countryName) VALUES ('Espagne'); | ||
8 | -INSERT INTO Country (countryName) VALUES ('Portugal'); | ||
9 | -INSERT INTO Country (countryName) VALUES ('Royaume-Uni'); | ||
10 | -INSERT INTO Country (countryName) VALUES ('Allemagne'); | ||
11 | -INSERT INTO Country (countryName) VALUES ('Pologne'); | ||
12 | -INSERT INTO Country (countryName) VALUES ('Italie'); | ||
13 | -INSERT INTO UserRole VALUES (1, 'VISITEUR', TRUE); | ||
14 | -INSERT INTO UserRole VALUES (2, 'RECRUE', TRUE); | ||
15 | -INSERT INTO UserRole VALUES (3, 'CONTRIBUTEUR', TRUE); | ||
16 | -INSERT INTO UserRole VALUES (4, 'ADMINISTRATEUR', TRUE); | ||
17 | -INSERT INTO UserRole VALUES (5, 'RETRAITE', TRUE); | ||
18 | -INSERT INTO UserRole VALUES (6, 'ASSOCE', TRUE); | ||
19 | -INSERT INTO UserProperty VALUES (1, 'nb_vignettes', 'Nombre de vignettes en home', TRUE); | ||
20 | -INSERT INTO UserProperty VALUES (2, 'avatar', 'Lien vers une icône ou une photo', TRUE); | ||
21 | -INSERT INTO UserProperty VALUES (3, 'tagline', 'Ligne de présentation pour les contributeurs', TRUE); | ||
22 | -INSERT INTO UserProperty VALUES (4, 'taille_listes', 'Nombre d''éléments affichés dans les listes', TRUE); | ||
23 | -INSERT INTO UserProperty VALUES (5, 'skin', 'Thème visuel', TRUE); | ||
24 | - | ||
25 | -INSERT INTO UserTable (USER_ID, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES | ||
26 | - (1, 'one', 'one', 'Derrick', 'Moss', 'one', 'one@raza.org', TRUE, FALSE, TRUE, TRUE), | ||
27 | - (2, 'two', 'two', 'Portia', 'Lin', 'two', 'two@raza.org', TRUE, FALSE, TRUE, TRUE), | ||
28 | - (3, 'three', 'three', 'Marcus', 'Boone', 'three', 'three@raza.org', TRUE, FALSE, TRUE, TRUE), | ||
29 | - (4, 'four', 'four', 'Ryo', 'Tetsuda', 'four', 'four@raza.org', TRUE, FALSE, TRUE, TRUE), | ||
30 | - (5, 'five', 'five', 'Emily', 'Kolburn', 'five', 'five@raza.org', TRUE, FALSE, TRUE, TRUE), | ||
31 | - (6, 'six', 'six', 'Kal', 'Varrik', 'six', 'six@raza.org', TRUE, FALSE, TRUE, TRUE); | ||
32 | - | ||
33 | -INSERT INTO UserTable_UserRole VALUES (1,2); | ||
34 | -INSERT INTO UserTable_UserRole VALUES (2,2); | ||
35 | -INSERT INTO UserTable_UserRole VALUES (3,2); | ||
36 | -INSERT INTO UserTable_UserRole VALUES (4,2); | ||
37 | -INSERT INTO UserTable_UserRole VALUES (5,2); | ||
38 | -INSERT INTO UserTable_UserRole VALUES (6,2); | ||
39 | -INSERT INTO UserTable_UserRole VALUES (5,4); |
... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
4 | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | 4 | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee |
5 | http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" | 5 | http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" |
6 | version="2.0"> | 6 | version="2.0"> |
7 | - | 7 | + <!-- |
8 | <navigation-rule> | 8 | <navigation-rule> |
9 | <from-view-id>*</from-view-id> | 9 | <from-view-id>*</from-view-id> |
10 | <navigation-case> | 10 | <navigation-case> |
... | @@ -17,96 +17,78 @@ | ... | @@ -17,96 +17,78 @@ |
17 | <from-view-id>/index.xhtml</from-view-id> | 17 | <from-view-id>/index.xhtml</from-view-id> |
18 | <navigation-case> | 18 | <navigation-case> |
19 | <from-outcome>addBook</from-outcome> | 19 | <from-outcome>addBook</from-outcome> |
20 | - <to-view-id>/book.xhtml</to-view-id> | 20 | + <to-view-id>/book/book.xhtml</to-view-id> |
21 | </navigation-case> | 21 | </navigation-case> |
22 | <navigation-case> | 22 | <navigation-case> |
23 | <from-outcome>listBooks</from-outcome> | 23 | <from-outcome>listBooks</from-outcome> |
24 | - <to-view-id>/result.xhtml</to-view-id> | 24 | + <to-view-id>/book/result.xhtml</to-view-id> |
25 | </navigation-case> | 25 | </navigation-case> |
26 | <navigation-case> | 26 | <navigation-case> |
27 | <from-outcome>addCountry</from-outcome> | 27 | <from-outcome>addCountry</from-outcome> |
28 | - <to-view-id>/addCountry.xhtml</to-view-id> | 28 | + <to-view-id>/xyz/addCountry.xhtml</to-view-id> |
29 | </navigation-case> | 29 | </navigation-case> |
30 | <navigation-case> | 30 | <navigation-case> |
31 | <from-outcome>listCountries</from-outcome> | 31 | <from-outcome>listCountries</from-outcome> |
32 | - <to-view-id>/listCountries.xhtml</to-view-id> | 32 | + <to-view-id>/xyz/listCountries.xhtml</to-view-id> |
33 | </navigation-case> | 33 | </navigation-case> |
34 | <navigation-case> | 34 | <navigation-case> |
35 | <from-outcome>addUser</from-outcome> | 35 | <from-outcome>addUser</from-outcome> |
36 | - <to-view-id>/updateUser.xhtml</to-view-id> | 36 | + <to-view-id>/user/updateUser.xhtml</to-view-id> |
37 | </navigation-case> | 37 | </navigation-case> |
38 | <navigation-case> | 38 | <navigation-case> |
39 | <from-outcome>listUsers</from-outcome> | 39 | <from-outcome>listUsers</from-outcome> |
40 | - <to-view-id>/listUsers.xhtml</to-view-id> | 40 | + <to-view-id>/user/listUsers.xhtml</to-view-id> |
41 | - </navigation-case> | ||
42 | - <navigation-case> | ||
43 | - <from-outcome>addPublisher</from-outcome> | ||
44 | - <to-view-id>/addPublisher.xhtml</to-view-id> | ||
45 | </navigation-case> | 41 | </navigation-case> |
46 | </navigation-rule> | 42 | </navigation-rule> |
47 | <navigation-rule> | 43 | <navigation-rule> |
48 | - <from-view-id>/addPublisher.xhtml</from-view-id> | 44 | + <from-view-id>/xyz/addCountry.xhtml</from-view-id> |
49 | <navigation-case> | 45 | <navigation-case> |
50 | <from-outcome>success</from-outcome> | 46 | <from-outcome>success</from-outcome> |
51 | - <to-view-id>/listPublisherRevisions.xhtml</to-view-id> | 47 | + <to-view-id>/xyz/listCountries.xhtml</to-view-id> |
52 | - </navigation-case> | ||
53 | - </navigation-rule> | ||
54 | - <navigation-rule> | ||
55 | - <from-view-id>/addCountry.xhtml</from-view-id> | ||
56 | - <navigation-case> | ||
57 | - <from-outcome>success</from-outcome> | ||
58 | - <to-view-id>/listCountries.xhtml</to-view-id> | ||
59 | </navigation-case> | 48 | </navigation-case> |
60 | </navigation-rule> | 49 | </navigation-rule> |
61 | 50 | ||
62 | <navigation-rule> | 51 | <navigation-rule> |
63 | - <from-view-id>/addUser_short.xhtml</from-view-id> | 52 | + <from-view-id>/user/addUser_short.xhtml</from-view-id> |
64 | <navigation-case> | 53 | <navigation-case> |
65 | <from-outcome>success</from-outcome> | 54 | <from-outcome>success</from-outcome> |
66 | - <to-view-id>/listUsers_short.xhtml</to-view-id> | 55 | + <to-view-id>/user/listUsers_short.xhtml</to-view-id> |
67 | </navigation-case> | 56 | </navigation-case> |
68 | </navigation-rule> | 57 | </navigation-rule> |
69 | 58 | ||
70 | <navigation-rule> | 59 | <navigation-rule> |
71 | - <from-view-id>/book.xhtml</from-view-id> | 60 | + <from-view-id>/book/book.xhtml</from-view-id> |
72 | <navigation-case> | 61 | <navigation-case> |
73 | <from-outcome>success</from-outcome> | 62 | <from-outcome>success</from-outcome> |
74 | - <to-view-id>/result.xhtml</to-view-id> | 63 | + <to-view-id>/book/result.xhtml</to-view-id> |
75 | </navigation-case> | 64 | </navigation-case> |
76 | </navigation-rule> | 65 | </navigation-rule> |
77 | 66 | ||
78 | <navigation-rule> | 67 | <navigation-rule> |
79 | - <from-view-id>/result.xhtml</from-view-id> | 68 | + <from-view-id>/book/result.xhtml</from-view-id> |
80 | <navigation-case> | 69 | <navigation-case> |
81 | <from-outcome>back</from-outcome> | 70 | <from-outcome>back</from-outcome> |
82 | - <to-view-id>/book.xhtml</to-view-id> | 71 | + <to-view-id>/book/book.xhtml</to-view-id> |
83 | </navigation-case> | 72 | </navigation-case> |
84 | </navigation-rule> | 73 | </navigation-rule> |
85 | 74 | ||
86 | <navigation-rule> | 75 | <navigation-rule> |
87 | - <from-view-id>/updateUser.xhtml</from-view-id> | 76 | + <from-view-id>/user/updateUser.xhtml</from-view-id> |
88 | <navigation-case> | 77 | <navigation-case> |
89 | <from-outcome>cancel</from-outcome> | 78 | <from-outcome>cancel</from-outcome> |
90 | - <to-view-id>/listUsers.xhtml</to-view-id> | 79 | + <to-view-id>/user/listUsers.xhtml</to-view-id> |
91 | </navigation-case> | 80 | </navigation-case> |
92 | <navigation-case> | 81 | <navigation-case> |
93 | <from-outcome>success</from-outcome> | 82 | <from-outcome>success</from-outcome> |
94 | - <to-view-id>/listUsers.xhtml</to-view-id> | 83 | + <to-view-id>/user/listUsers.xhtml</to-view-id> |
95 | </navigation-case> | 84 | </navigation-case> |
96 | </navigation-rule> | 85 | </navigation-rule> |
97 | <navigation-rule> | 86 | <navigation-rule> |
98 | - <from-view-id>/listUsers.xhtml</from-view-id> | 87 | + <from-view-id>/user/listUsers.xhtml</from-view-id> |
99 | <navigation-case> | 88 | <navigation-case> |
100 | <from-outcome>add</from-outcome> | 89 | <from-outcome>add</from-outcome> |
101 | - <to-view-id>/updateUser.xhtml</to-view-id> | 90 | + <to-view-id>/user/updateUser.xhtml</to-view-id> |
102 | - </navigation-case> | ||
103 | - </navigation-rule> | ||
104 | - | ||
105 | - <navigation-rule> | ||
106 | - <from-view-id>/listPublisherRevisions.xhtml</from-view-id> | ||
107 | - <navigation-case> | ||
108 | - <from-outcome>view</from-outcome> | ||
109 | - <to-view-id>/publisherRevision.xhtml</to-view-id> | ||
110 | </navigation-case> | 91 | </navigation-case> |
111 | </navigation-rule> | 92 | </navigation-rule> |
93 | + --> | ||
112 | </faces-config> | 94 | </faces-config> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
src/main/webapp/addPublisher.xhtml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
3 | - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
4 | -<html xmlns="http://www.w3.org/1999/xhtml" | ||
5 | - xmlns:h="http://xmlns.jcp.org/jsf/html" | ||
6 | - xmlns:ui="http://xmlns.jcp.org/jsf/facelets" | ||
7 | - xmlns:f="http://xmlns.jcp.org/jsf/core"> | ||
8 | -<f:view> | ||
9 | - <h:form> | ||
10 | - <h:commandLink action="home"> | ||
11 | - <h:outputText value="Menu principal"/> | ||
12 | - </h:commandLink> | ||
13 | - | ||
14 | - <h:panelGrid columns="2"> | ||
15 | - <h:outputText value='publisherName'/> | ||
16 | - <h:inputText value='#{addPublisherBean.publisherName}'/> | ||
17 | - <h:outputText value='publisherStreetAddress'/> | ||
18 | - <h:inputText value='#{addPublisherBean.publisherStreetAddress}'/> | ||
19 | - <h:outputText value='publisherPostalCode'/> | ||
20 | - <h:inputText value='#{addPublisherBean.publisherPostalCode}'/> | ||
21 | - <h:outputText value='publisherPostOfficeBoxNumber'/> | ||
22 | - <h:inputText value='#{addPublisherBean.publisherPostOfficeBoxNumber}'/> | ||
23 | - <h:outputText value='publisherAddressRegion'/> | ||
24 | - <h:inputText value='#{addPublisherBean.publisherAddressRegion}'/> | ||
25 | - <h:outputText value='publisherAddressLocality'/> | ||
26 | - <h:inputText value='#{addPublisherBean.publisherAddressLocality}'/> | ||
27 | - | ||
28 | - <h:outputText value='publisherAddressCountry'/> | ||
29 | - <h:selectOneMenu value="#{addPublisherBean.publisherAddressCountry}" converter="omnifaces.SelectItemsConverter"> | ||
30 | - <f:selectItems value="#{addPublisherBean.availableCountries}" var="country" itemLabel="#{country.countryName}"/> | ||
31 | - </h:selectOneMenu> | ||
32 | - | ||
33 | - <h:outputText value='publisherTelephone'/> | ||
34 | - <h:inputText value='#{addPublisherBean.publisherTelephone}'/> | ||
35 | - <h:outputText value='publisherEmail'/> | ||
36 | - <h:inputText value='#{addPublisherBean.publisherEmail}'/> | ||
37 | - <h:outputText value='publisherURL'/> | ||
38 | - <h:inputText value='#{addPublisherBean.publisherURL}'/> | ||
39 | - | ||
40 | - <h:outputText value='publisherActive'/> | ||
41 | - <h:selectBooleanCheckbox value="#{addPublisherBean.publisherActive}"/> | ||
42 | - | ||
43 | - <h:outputText value='publisherHistory'/> | ||
44 | - <h:inputTextarea value='#{addPublisherBean.publisherHistory}'/> | ||
45 | - <h:outputText value='Add'/> | ||
46 | - <h:commandButton action="#{addPublisherBean.add}" value="Add"/> | ||
47 | - </h:panelGrid> | ||
48 | - </h:form> | ||
49 | -</f:view> | ||
50 | -</html> |
... | @@ -2,48 +2,18 @@ | ... | @@ -2,48 +2,18 @@ |
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
3 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | 3 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
4 | <html xmlns="http://www.w3.org/1999/xhtml" | 4 | <html xmlns="http://www.w3.org/1999/xhtml" |
5 | - xmlns:h="http://xmlns.jcp.org/jsf/html" | 5 | + xmlns:jsf="http://xmlns.jcp.org/jsf"> |
6 | - xmlns:ui="http://xmlns.jcp.org/jsf/facelets" | ||
7 | - xmlns:f="http://xmlns.jcp.org/jsf/core"> | ||
8 | <body> | 6 | <body> |
9 | -<h:form> | ||
10 | <ul> | 7 | <ul> |
11 | <li> | 8 | <li> |
12 | - <h:commandLink action="addBook"> | 9 | + <a jsf:outcome="publisher/listPublisherVersions">Liste des versions des éditeurs</a> |
13 | - <h:outputText value="Add book"/> | ||
14 | - </h:commandLink> | ||
15 | </li> | 10 | </li> |
16 | <li> | 11 | <li> |
17 | - <h:commandLink action="listBooks"> | 12 | + <a jsf:outcome="publisher/listPublisherActions">Liste des actions des éditeurs</a> |
18 | - <h:outputText value="List books"/> | ||
19 | - </h:commandLink> | ||
20 | </li> | 13 | </li> |
21 | <li> | 14 | <li> |
22 | - <h:commandLink action="addCountry"> | 15 | + <a jsf:outcome="publisher/publisherVersion">Ajouter un éditeur</a> |
23 | - <h:outputText value="Add country"/> | ||
24 | - </h:commandLink> | ||
25 | - </li> | ||
26 | - <li> | ||
27 | - <h:commandLink action="listCountries"> | ||
28 | - <h:outputText value="List countries"/> | ||
29 | - </h:commandLink> | ||
30 | - </li> | ||
31 | - <li> | ||
32 | - <h:commandLink action="addUser"> | ||
33 | - <h:outputText value="Add user"/> | ||
34 | - </h:commandLink> | ||
35 | - </li> | ||
36 | - <li> | ||
37 | - <h:commandLink action="listUsers"> | ||
38 | - <h:outputText value="List users"/> | ||
39 | - </h:commandLink> | ||
40 | - </li> | ||
41 | - <li> | ||
42 | - <h:commandLink action="addPublisher"> | ||
43 | - <h:outputText value="Add Publisher"/> | ||
44 | - </h:commandLink> | ||
45 | </li> | 16 | </li> |
46 | </ul> | 17 | </ul> |
47 | -</h:form> | ||
48 | </body> | 18 | </body> |
49 | </html> | 19 | </html> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
3 | - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
4 | -<html xmlns="http://www.w3.org/1999/xhtml" | ||
5 | - xmlns:h="http://xmlns.jcp.org/jsf/html" | ||
6 | - xmlns:ui="http://xmlns.jcp.org/jsf/facelets" | ||
7 | - xmlns:f="http://xmlns.jcp.org/jsf/core"> | ||
8 | -<h:body> | ||
9 | - <h:outputText rendered="#{listPublisherRevisionsBean.publisherRevisions.isEmpty()}">Liste des révisions est vide</h:outputText> | ||
10 | - <h:dataTable value="#{listPublisherRevisionsBean.publisherRevisions}" var="revision"> | ||
11 | - <h:column> | ||
12 | - <f:facet name="header">Visualiser<!--ou Modifier--></f:facet> | ||
13 | - <h:link outcome="view">Visualiser<!--ou Modifier--> | ||
14 | - <f:param name="publisherRevisionId" value="#{revision.publisherRevisionId}"/> | ||
15 | - </h:link> | ||
16 | - </h:column> | ||
17 | - <h:column> | ||
18 | - <f:facet name="header">Name</f:facet> | ||
19 | - #{revision.publisherName} | ||
20 | - </h:column> | ||
21 | - <h:column> | ||
22 | - <f:facet name="header">Address</f:facet> | ||
23 | - #{revision.publisherPostOfficeBoxNumber}<br /> | ||
24 | - #{revision.publisherStreetAddress}<br /> | ||
25 | - #{revision.publisherPostalCode} #{revision.publisherAddressLocality}<br /> | ||
26 | - #{revision.publisherAddressRegion}<br /> | ||
27 | - #{revision.publisherAddressCountry.countryName} | ||
28 | - </h:column> | ||
29 | - <h:column> | ||
30 | - <f:facet name="header">Telephone</f:facet> | ||
31 | - #{revision.publisherTelephone} | ||
32 | - </h:column> | ||
33 | - <h:column> | ||
34 | - <f:facet name="header">Email</f:facet> | ||
35 | - #{revision.publisherEmail} | ||
36 | - </h:column> | ||
37 | - <h:column> | ||
38 | - <f:facet name="header">URL</f:facet> | ||
39 | - #{revision.publisherURL} | ||
40 | - </h:column> | ||
41 | - <h:column> | ||
42 | - <f:facet name="header">Active ?</f:facet> | ||
43 | - #{revision.publisherActive} | ||
44 | - </h:column> | ||
45 | - <h:column> | ||
46 | - <f:facet name="header">History</f:facet> | ||
47 | - #{revision.publisherHistory} | ||
48 | - </h:column> | ||
49 | - <h:column> | ||
50 | - <f:facet name="header">Revision Author</f:facet> | ||
51 | - #{revision.publisherRevisionAuthor.displayName} | ||
52 | - </h:column> | ||
53 | - <h:column> | ||
54 | - <f:facet name="header">Revision Datetime</f:facet> | ||
55 | - #{revision.publisherRevisionDatetime} | ||
56 | - </h:column> | ||
57 | - </h:dataTable> | ||
58 | -</h:body> | ||
59 | -</html> |
src/main/webapp/minimal.css
0 → 100644
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
3 | - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
4 | -<html xmlns="http://www.w3.org/1999/xhtml" | ||
5 | - xmlns:h="http://xmlns.jcp.org/jsf/html" | ||
6 | - xmlns:ui="http://xmlns.jcp.org/jsf/facelets" | ||
7 | - xmlns:f="http://xmlns.jcp.org/jsf/core" | ||
8 | - xmlns:jsf="http://xmlns.jcp.org/jsf" | ||
9 | - > | ||
10 | -<head> | ||
11 | -<f:metadata> | ||
12 | - <f:viewParam name="publisherRevisionId" value="#{publisherRevisionView.publisherRevisionId}" /> | ||
13 | - <f:viewAction action="#{publisherRevisionView.loadData}" /> | ||
14 | -</f:metadata> | ||
15 | -</head> | ||
16 | -<body> | ||
17 | - | ||
18 | -<p>Depuis le paramètre : #{param['publisherRevisionId']} </p> | ||
19 | -<p>En passant par la vue : #{publisherRevisionView.publisherRevisionId} </p> | ||
20 | - | ||
21 | -<form action="" jsf:id="reload-form"> | ||
22 | - <button jsf:id="reload" jsf:action="#{publisherRevisionView.loadData}">Reload !</button> | ||
23 | -</form> | ||
24 | - | ||
25 | -</body> | ||
26 | -</html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +package org.legrog.test; | ||
2 | + | ||
3 | +/* | ||
4 | + | ||
5 | +TAKEN FROM JUnit 5 Sample | ||
6 | +https://github.com/junit-team/junit5-samples/blob/master/junit5-mockito-extension/src/main/java/com/example/mockito/MockitoExtension.java | ||
7 | + | ||
8 | +*/ | ||
9 | + | ||
10 | +/* | ||
11 | + * Copyright 2015-2016 the original author or authors. | ||
12 | + * | ||
13 | + * All rights reserved. This program and the accompanying materials are | ||
14 | + * made available under the terms of the Eclipse Public License v1.0 which | ||
15 | + * accompanies this distribution and is available at | ||
16 | + * | ||
17 | + * http://www.eclipse.org/legal/epl-v10.html | ||
18 | + * | ||
19 | + */ | ||
20 | + | ||
21 | + | ||
22 | +import static org.mockito.Mockito.mock; | ||
23 | + | ||
24 | +import java.lang.reflect.Parameter; | ||
25 | + | ||
26 | +import org.junit.jupiter.api.extension.ExtensionContext; | ||
27 | +import org.junit.jupiter.api.extension.ExtensionContext.Namespace; | ||
28 | +import org.junit.jupiter.api.extension.ExtensionContext.Store; | ||
29 | +import org.junit.jupiter.api.extension.ParameterContext; | ||
30 | +import org.junit.jupiter.api.extension.ParameterResolver; | ||
31 | +import org.junit.jupiter.api.extension.TestInstancePostProcessor; | ||
32 | +import org.mockito.Mock; | ||
33 | +import org.mockito.MockitoAnnotations; | ||
34 | + | ||
35 | +/** | ||
36 | + * {@code MockitoExtension} showcases the {@link TestInstancePostProcessor} | ||
37 | + * and {@link ParameterResolver} extension APIs of JUnit 5 by providing | ||
38 | + * dependency injection support at the field level and at the method parameter | ||
39 | + * level via Mockito 2.x's {@link Mock @Mock} annotation. | ||
40 | + */ | ||
41 | +public class MockitoExtension implements TestInstancePostProcessor, ParameterResolver { | ||
42 | + | ||
43 | + @Override | ||
44 | + public void postProcessTestInstance(Object testInstance, ExtensionContext context) { | ||
45 | + MockitoAnnotations.initMocks(testInstance); | ||
46 | + } | ||
47 | + | ||
48 | + @Override | ||
49 | + public boolean supports(ParameterContext parameterContext, ExtensionContext extensionContext) { | ||
50 | + return parameterContext.getParameter().isAnnotationPresent(Mock.class); | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public Object resolve(ParameterContext parameterContext, ExtensionContext extensionContext) { | ||
55 | + return getMock(parameterContext.getParameter(), extensionContext); | ||
56 | + } | ||
57 | + | ||
58 | + private Object getMock(Parameter parameter, ExtensionContext extensionContext) { | ||
59 | + Class<?> mockType = parameter.getType(); | ||
60 | + Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType)); | ||
61 | + String mockName = getMockName(parameter); | ||
62 | + | ||
63 | + if (mockName != null) { | ||
64 | + return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName)); | ||
65 | + } else { | ||
66 | + return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType)); | ||
67 | + } | ||
68 | + } | ||
69 | + | ||
70 | + private String getMockName(Parameter parameter) { | ||
71 | + String explicitMockName = parameter.getAnnotation(Mock.class).name().trim(); | ||
72 | + if (!explicitMockName.isEmpty()) { | ||
73 | + return explicitMockName; | ||
74 | + } else if (parameter.isNamePresent()) { | ||
75 | + return parameter.getName(); | ||
76 | + } | ||
77 | + return null; | ||
78 | + } | ||
79 | + | ||
80 | +} | ||
81 | + |
1 | -package org.legrog.application; | 1 | +package org.legrog.web.book; |
2 | 2 | ||
3 | import org.junit.Before; | 3 | import org.junit.Before; |
4 | -import org.junit.Test; | 4 | +import org.junit.jupiter.api.Test; |
5 | +import org.junit.jupiter.api.BeforeEach; | ||
6 | +import org.junit.jupiter.api.extension.ExtendWith; | ||
7 | +import org.junit.platform.runner.JUnitPlatform; | ||
5 | import org.junit.runner.RunWith; | 8 | import org.junit.runner.RunWith; |
6 | import org.legrog.entities.Book; | 9 | import org.legrog.entities.Book; |
10 | +import org.legrog.test.MockitoExtension; | ||
11 | +import org.legrog.web.book.BookServiceOld; | ||
7 | import org.mockito.Answers; | 12 | import org.mockito.Answers; |
8 | import org.mockito.Mock; | 13 | import org.mockito.Mock; |
9 | import org.mockito.Mockito; | 14 | import org.mockito.Mockito; |
... | @@ -17,21 +22,22 @@ import java.util.List; | ... | @@ -17,21 +22,22 @@ import java.util.List; |
17 | import static org.assertj.core.api.Assertions.assertThat; | 22 | import static org.assertj.core.api.Assertions.assertThat; |
18 | 23 | ||
19 | 24 | ||
20 | -@RunWith(MockitoJUnitRunner.class) | 25 | +@RunWith(JUnitPlatform.class) |
21 | -public class BookServiceOldTest { | 26 | +@ExtendWith(MockitoExtension.class) |
27 | + public class BookServiceOldTest { | ||
22 | 28 | ||
23 | @Mock(answer = Answers.RETURNS_DEEP_STUBS) | 29 | @Mock(answer = Answers.RETURNS_DEEP_STUBS) |
24 | private EntityManager entityManager; | 30 | private EntityManager entityManager; |
25 | 31 | ||
26 | private BookServiceOld bookServiceOld; | 32 | private BookServiceOld bookServiceOld; |
27 | 33 | ||
28 | - @Before | 34 | + @BeforeEach |
29 | - public void setUp() throws Exception { | 35 | + public void setUp() { |
30 | bookServiceOld = new BookServiceOld(entityManager); | 36 | bookServiceOld = new BookServiceOld(entityManager); |
31 | } | 37 | } |
32 | 38 | ||
33 | @Test | 39 | @Test |
34 | - public void testAddBook() throws Exception { | 40 | + public void testAddBook() { |
35 | Book book = new Book(); | 41 | Book book = new Book(); |
36 | bookServiceOld.addBook(book); | 42 | bookServiceOld.addBook(book); |
37 | Mockito.verify(entityManager).persist(book); | 43 | Mockito.verify(entityManager).persist(book); |
... | @@ -39,7 +45,7 @@ public class BookServiceOldTest { | ... | @@ -39,7 +45,7 @@ public class BookServiceOldTest { |
39 | 45 | ||
40 | 46 | ||
41 | @Test | 47 | @Test |
42 | - public void testAllBooks() throws Exception { | 48 | + public void testAllBooks() { |
43 | 49 | ||
44 | Book book = new Book(); | 50 | Book book = new Book(); |
45 | book.setBookId(0); | 51 | book.setBookId(0); | ... | ... |
1 | +package org.legrog.web.publisher; | ||
2 | + | ||
3 | +import org.junit.Before; | ||
4 | +import org.junit.jupiter.api.Test; | ||
5 | +import org.junit.jupiter.api.BeforeEach; | ||
6 | +import org.junit.jupiter.api.DisplayName; | ||
7 | +import org.junit.jupiter.api.Nested; | ||
8 | +import org.junit.jupiter.api.extension.ExtendWith; | ||
9 | +import org.junit.platform.runner.JUnitPlatform; | ||
10 | +import org.junit.runner.RunWith; | ||
11 | +import org.legrog.entities.Publisher; | ||
12 | +import org.legrog.entities.PublisherAction; | ||
13 | +import org.legrog.test.MockitoExtension; | ||
14 | +import org.mockito.Mock; | ||
15 | +import org.mockito.Mockito; | ||
16 | + | ||
17 | +import javax.inject.Inject; | ||
18 | + | ||
19 | +import java.util.ArrayList; | ||
20 | +import java.util.List; | ||
21 | + | ||
22 | +import static org.assertj.core.api.Assertions.assertThat; | ||
23 | + | ||
24 | +/** | ||
25 | + * Classe testant ListPublisherActionsView. | ||
26 | + */ | ||
27 | +@RunWith(JUnitPlatform.class) | ||
28 | +@ExtendWith(MockitoExtension.class) | ||
29 | +@DisplayName("Visualisation d'actions sur éditeur") | ||
30 | +public class ListPublisherActionsViewTest { | ||
31 | + ListPublisherActionsView listPublisherActionsView; | ||
32 | + | ||
33 | + @Nested | ||
34 | + @DisplayName("setView method") | ||
35 | + public class testSetView { | ||
36 | + boolean filtered; | ||
37 | + | ||
38 | + @BeforeEach | ||
39 | + public void setUp(@Mock PublisherService publisherServiceMock){ | ||
40 | + filtered = false; | ||
41 | + listPublisherActionsView = new ListPublisherActionsView(publisherServiceMock) { | ||
42 | + @Override | ||
43 | + public void filterOnID() { | ||
44 | + filtered = true; | ||
45 | + } | ||
46 | + }; | ||
47 | + } | ||
48 | + | ||
49 | + @Test | ||
50 | + @DisplayName("should show all") | ||
51 | + public void showAll(@Mock PublisherService publisherServiceMock) { | ||
52 | + listPublisherActionsView.setPublisherId(null); | ||
53 | + listPublisherActionsView.setViewAll(false); | ||
54 | + listPublisherActionsView.setView(); | ||
55 | + Mockito.verify(publisherServiceMock).getAllPublisherActions(); | ||
56 | + assertThat(listPublisherActionsView.isViewAll()).isTrue(); | ||
57 | + assertThat(filtered).isFalse(); | ||
58 | + } | ||
59 | + | ||
60 | + @Test | ||
61 | + @DisplayName("should show filtered") | ||
62 | + public void showFiltered(@Mock PublisherService publisherServiceMock) { | ||
63 | + listPublisherActionsView.setPublisherId(1); | ||
64 | + listPublisherActionsView.setViewAll(true); | ||
65 | + listPublisherActionsView.setView(); | ||
66 | + Mockito.verify(publisherServiceMock).getAllPublisherActions(); | ||
67 | + assertThat(listPublisherActionsView.isViewAll()).isFalse(); | ||
68 | + assertThat(filtered).isTrue(); | ||
69 | + } | ||
70 | + } | ||
71 | + | ||
72 | + @Test | ||
73 | + @DisplayName("filterId should filter") | ||
74 | + public void testFilter(@Mock PublisherService publisherServiceMock) { | ||
75 | + List<PublisherAction> publisherActions = new ArrayList<PublisherAction>(); | ||
76 | + | ||
77 | + Publisher publisher = new Publisher(); | ||
78 | + Publisher publisher1 = new Publisher(); | ||
79 | + PublisherAction publisherAction = new PublisherAction(); | ||
80 | + PublisherAction publisherAction1 = new PublisherAction(); | ||
81 | + | ||
82 | + publisher.setPublisherId(0); | ||
83 | + publisher1.setPublisherId(1); | ||
84 | + publisherAction.setPublisher(publisher); | ||
85 | + publisherAction1.setPublisher(publisher1); | ||
86 | + publisherActions.add(publisherAction); | ||
87 | + publisherActions.add(publisherAction1); | ||
88 | + | ||
89 | + listPublisherActionsView = new ListPublisherActionsView(); | ||
90 | + listPublisherActionsView.setPublisherActions(publisherActions); | ||
91 | + listPublisherActionsView.setPublisherId(1); | ||
92 | + listPublisherActionsView.filterOnID(); | ||
93 | + assertThat(listPublisherActionsView.getPublisherActions()).containsExactly(publisherAction1); | ||
94 | + } | ||
95 | +} |
1 | +package org.legrog.web.publisher; | ||
2 | + | ||
3 | +import org.junit.jupiter.api.BeforeEach; | ||
4 | +import org.junit.jupiter.api.Test; | ||
5 | +import org.junit.jupiter.api.extension.ExtendWith; | ||
6 | +import org.junit.platform.runner.JUnitPlatform; | ||
7 | +import org.junit.runner.RunWith; | ||
8 | +import org.junit.jupiter.api.DisplayName; | ||
9 | +import org.legrog.entities.Publisher; | ||
10 | +import org.legrog.entities.PublisherAction; | ||
11 | +import org.legrog.entities.PublisherVersion; | ||
12 | +import org.legrog.test.MockitoExtension; | ||
13 | +import org.mockito.Answers; | ||
14 | +import org.mockito.Mock; | ||
15 | +import org.mockito.Mockito; | ||
16 | +import org.mockito.runners.MockitoJUnitRunner; | ||
17 | +import org.slf4j.Logger; | ||
18 | +import org.slf4j.LoggerFactory; | ||
19 | + | ||
20 | +import java.util.ArrayList; | ||
21 | +import java.util.List; | ||
22 | + | ||
23 | +import static org.assertj.core.api.Assertions.assertThat; | ||
24 | +import static org.mockito.Mockito.*; | ||
25 | + | ||
26 | +/** | ||
27 | + * Classe testant ListPublisherVersionsView. | ||
28 | + */ | ||
29 | +@RunWith(JUnitPlatform.class) | ||
30 | +@ExtendWith(MockitoExtension.class) | ||
31 | +@DisplayName("Listes de versions d'éditeurs") | ||
32 | +public class ListPublisherVersionsViewTest { | ||
33 | + Logger logger = LoggerFactory.getLogger(getClass()); | ||
34 | + | ||
35 | + private ListPublisherVersionsView listPublisherVersionsView; | ||
36 | + private List<PublisherVersion> publisherVersions; | ||
37 | + private PublisherVersion publisherVersion; | ||
38 | + private PublisherVersion publisherVersion1; | ||
39 | + private PublisherVersion publisherVersion2; | ||
40 | + private Publisher publisher; | ||
41 | + private Publisher publisher1; | ||
42 | + PublisherAction publisherAction; | ||
43 | + | ||
44 | + @Mock(answer = Answers.RETURNS_DEEP_STUBS) | ||
45 | + private PublisherService publisherService; | ||
46 | + | ||
47 | + @BeforeEach | ||
48 | + public void setUp() { | ||
49 | + | ||
50 | + // Données | ||
51 | + publisherVersion = new PublisherVersion(); | ||
52 | + publisherVersion1 = new PublisherVersion(); | ||
53 | + publisherVersion2 = new PublisherVersion(); | ||
54 | + publisherVersion.setPublisherVersionId(0); | ||
55 | + publisherVersion1.setPublisherVersionId(1); | ||
56 | + publisherVersion2.setPublisherVersionId(2); | ||
57 | + publisher = new Publisher(); | ||
58 | + publisher1 = new Publisher(); | ||
59 | + publisher.setPublisherId(0); | ||
60 | + publisher1.setPublisherId(1); | ||
61 | + publisherVersion.setPublisher(publisher); | ||
62 | + publisherVersion1.setPublisher(publisher1); | ||
63 | + publisherVersion2.setPublisher(publisher); | ||
64 | + publisher.setValidatedVersion(publisherVersion); | ||
65 | + publisherVersions = new ArrayList<PublisherVersion>(); | ||
66 | + publisherVersions.add(publisherVersion); | ||
67 | + publisherVersions.add(publisherVersion1); | ||
68 | + publisherAction = new PublisherAction(); | ||
69 | + | ||
70 | + // Mock | ||
71 | + when(publisherService.getAllPublisherVersions()).thenReturn(publisherVersions); | ||
72 | + listPublisherVersionsView = new ListPublisherVersionsView(publisherService); | ||
73 | + when(publisherService.getLastValidate(publisher)).thenReturn(publisherAction); | ||
74 | + when(publisherService.getLastValidate(publisher1)).thenReturn(null); | ||
75 | + | ||
76 | + } | ||
77 | + | ||
78 | + @Test | ||
79 | + @DisplayName("Liste complète") | ||
80 | + public void testSetViewAll() { | ||
81 | + listPublisherVersionsView.setPublisherId(null); | ||
82 | + listPublisherVersionsView.setView(); | ||
83 | + Mockito.verify(publisherService).getAllPublisherVersions(); | ||
84 | + assertThat(listPublisherVersionsView.isViewAll()).isTrue(); | ||
85 | + assertThat(listPublisherVersionsView.getPublisherVersions()).isEqualTo(publisherVersions); | ||
86 | + } | ||
87 | + | ||
88 | + @Test | ||
89 | + @DisplayName("Liste pour un éditeur") | ||
90 | + public void testSetViewNotAllAlsoTestingFilterOnId() { | ||
91 | + listPublisherVersionsView.setPublisherId(1); | ||
92 | + listPublisherVersionsView.setView(); | ||
93 | + Mockito.verify(publisherService).getAllPublisherVersions(); | ||
94 | + assertThat(listPublisherVersionsView.isViewAll()).isFalse(); | ||
95 | + assertThat(listPublisherVersionsView.getPublisherVersions()).containsExactly(publisherVersion1); | ||
96 | + } | ||
97 | + | ||
98 | + @Test | ||
99 | + @DisplayName("Test de l'appel de validation") | ||
100 | + public void testValidate() { | ||
101 | + listPublisherVersionsView.setPublisherId(0); | ||
102 | + listPublisherVersionsView.validate(publisherVersion2); | ||
103 | + Mockito.verify(publisherService).validatePublisherVersion(publisherVersion2); | ||
104 | + } | ||
105 | + | ||
106 | + @Test | ||
107 | + @DisplayName("Récupération effective dernière validation d'un éditeur") | ||
108 | + public void testGetLastValidate() { | ||
109 | + assertThat(listPublisherVersionsView.getLastValidate(publisher)).isEqualTo(publisherAction); | ||
110 | + } | ||
111 | + | ||
112 | + @Test | ||
113 | + @DisplayName("Échec de récupération de dernière validation d'un éditeur") | ||
114 | + public void testGetLastValidateNull() { | ||
115 | + assertThat(listPublisherVersionsView.getLastValidate(publisher1)).isNull(); | ||
116 | + } | ||
117 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +package org.legrog.web.publisher; | ||
2 | + | ||
3 | +import org.junit.jupiter.api.Test; | ||
4 | +import org.junit.jupiter.api.BeforeEach; | ||
5 | +import org.junit.jupiter.api.DisplayName; | ||
6 | +import org.junit.jupiter.api.extension.ExtendWith; | ||
7 | +import org.junit.platform.runner.JUnitPlatform; | ||
8 | +import org.junit.runner.RunWith; | ||
9 | +import org.legrog.entities.*; | ||
10 | +import org.legrog.test.MockitoExtension; | ||
11 | +import org.legrog.web.xyz.SharedService; | ||
12 | +import org.mockito.Mock; | ||
13 | + | ||
14 | +import javax.inject.Inject; | ||
15 | +import java.util.ArrayList; | ||
16 | +import java.util.HashSet; | ||
17 | +import java.util.List; | ||
18 | +import java.util.Set; | ||
19 | + | ||
20 | +import static org.assertj.core.api.Assertions.assertThat; | ||
21 | +import static org.mockito.Mockito.*; | ||
22 | + | ||
23 | +/** | ||
24 | + * Classe testant PublisherServiceSpring. | ||
25 | + */ | ||
26 | +@RunWith(JUnitPlatform.class) | ||
27 | +@ExtendWith(MockitoExtension.class) | ||
28 | +@DisplayName("Couche service de gestion d'éditeur") | ||
29 | +public class PublisherServiceSpringTest { | ||
30 | + | ||
31 | + PublisherServiceSpring publisherServiceSpring; | ||
32 | + PublisherVersion publisherVersion; | ||
33 | + PublisherVersion publisherVersion1; | ||
34 | + Publisher publisher; | ||
35 | + PublisherRepository publisherRepository; | ||
36 | + PublisherVersionRepository publisherVersionRepository; | ||
37 | + | ||
38 | + @Inject | ||
39 | + ActionTypeRepository actionTypeRepository; | ||
40 | + | ||
41 | + @Mock | ||
42 | + PublisherVersion publisherVersionMock; | ||
43 | + | ||
44 | + @BeforeEach | ||
45 | + public void setUp(@Mock PublisherRepository publisherRepository, | ||
46 | + @Mock PublisherVersionRepository publisherVersionRepository, | ||
47 | + @Mock PublisherActionRepository publisherActionRepository, | ||
48 | + @Mock ActionTypeRepository actionTypeRepository, | ||
49 | + @Mock SharedService sharedService) throws Exception { | ||
50 | + publisherServiceSpring = new PublisherServiceSpring(publisherRepository, | ||
51 | + publisherVersionRepository, publisherActionRepository, actionTypeRepository, sharedService); | ||
52 | + publisherVersion = new PublisherVersion(); | ||
53 | + publisherVersion1 = new PublisherVersion(); | ||
54 | + this.publisherRepository = publisherRepository; | ||
55 | + } | ||
56 | + | ||
57 | + @DisplayName("Test ajout nouvel éditeur") | ||
58 | + @Test | ||
59 | + public void testAddNewPublisher(@Mock PublisherVersionRepository publisherVersionRepository) { | ||
60 | + publisherServiceSpring.addNewPublisher(publisherVersion); | ||
61 | + publisher = publisherVersion.getPublisher(); | ||
62 | + assertThat(publisher.getVersions()).containsExactly(publisherVersion); | ||
63 | + assertThat(publisherVersion.getPublisher()).isEqualTo(publisher); | ||
64 | + verify(publisherRepository).save(publisher); | ||
65 | + verify(publisherVersionRepository).save(publisherVersion); | ||
66 | + } | ||
67 | + | ||
68 | + @DisplayName("Test ajout nouvelle version éditeur") | ||
69 | + @Test | ||
70 | + public void testAddVersionToPublisher(@Mock PublisherRepository publisherRepository, | ||
71 | + @Mock PublisherVersionRepository publisherVersionRepository) { | ||
72 | + publisherServiceSpring.addNewPublisher(publisherVersion); | ||
73 | + publisher = publisherVersion.getPublisher(); | ||
74 | + publisherServiceSpring.addVersionToPublisher(publisher, publisherVersion1); | ||
75 | + assertThat(publisherVersion1.getPublisher()).isEqualTo(publisher); | ||
76 | + assertThat(publisher.getVersions()).contains(publisherVersion, publisherVersion1); | ||
77 | + verify(publisherRepository, times(2)).save(publisher); | ||
78 | + verify(publisherVersionRepository).save(publisherVersion1); | ||
79 | + } | ||
80 | + | ||
81 | + @DisplayName("Test validation version éditeur") | ||
82 | + @Test | ||
83 | + public void testValidateVersion(@Mock PublisherActionRepository publisherActionRepository) { | ||
84 | + Set<PublisherVersion> publisherVersions; | ||
85 | + | ||
86 | + publisher = new Publisher(); | ||
87 | + publisherVersion = new PublisherVersion(); | ||
88 | + | ||
89 | + publisherVersions = new HashSet<PublisherVersion>(); | ||
90 | + publisherVersions.add(publisherVersion); | ||
91 | + publisherVersions.add(publisherVersionMock); | ||
92 | + | ||
93 | + when(publisherVersionMock.getPublisher()).thenReturn(publisher); | ||
94 | + PublisherAction publisherAction; | ||
95 | + publisherAction = publisherServiceSpring.validatePublisherVersion(publisherVersionMock); | ||
96 | + verify(publisherActionRepository).save(publisherAction); | ||
97 | + assertThat(publisherAction.getPublisherVersion()).isEqualTo(publisherVersionMock); | ||
98 | + assertThat(publisherAction.getPublisher()).isEqualTo(publisher); | ||
99 | + assertThat(publisherAction.getPublisher().getValidatedVersion()).isEqualTo(publisherVersionMock); | ||
100 | +// TODO Régler ce problème de NPE | ||
101 | +// assertThat(publisherAction.getActionType()).isEqualTo(actionTypeRepository.findByActionTypeName("Validate")); | ||
102 | + } | ||
103 | +} |
1 | +package org.legrog.web.publisher; | ||
2 | + | ||
3 | +import org.junit.jupiter.api.Nested; | ||
4 | +import org.junit.jupiter.api.Test; | ||
5 | +import org.junit.jupiter.api.BeforeEach; | ||
6 | +import org.junit.jupiter.api.DisplayName; | ||
7 | +import org.junit.jupiter.api.extension.ExtendWith; | ||
8 | +import org.junit.platform.runner.JUnitPlatform; | ||
9 | +import org.junit.runner.RunWith; | ||
10 | +import org.legrog.entities.Country; | ||
11 | +import org.legrog.entities.Publisher; | ||
12 | +import org.legrog.entities.PublisherVersion; | ||
13 | +import org.legrog.test.MockitoExtension; | ||
14 | +import org.legrog.web.xyz.SharedService; | ||
15 | +import org.mockito.*; | ||
16 | +import org.mockito.stubbing.Answer; | ||
17 | +import org.slf4j.Logger; | ||
18 | +import org.slf4j.LoggerFactory; | ||
19 | + | ||
20 | +import java.util.List; | ||
21 | + | ||
22 | +import static org.assertj.core.api.Assertions.assertThat; | ||
23 | +import static org.mockito.ArgumentMatchers.any; | ||
24 | +import static org.mockito.ArgumentMatchers.anyInt; | ||
25 | +import static org.mockito.Mockito.when; | ||
26 | + | ||
27 | +/** | ||
28 | + * Classe testant PublisherVersionView. | ||
29 | + */ | ||
30 | +@RunWith(JUnitPlatform.class) | ||
31 | +@ExtendWith(MockitoExtension.class) | ||
32 | +@DisplayName("Création et visualisation de version d'éditeur") | ||
33 | +public class PublisherVersionViewTest { | ||
34 | + Logger logger = LoggerFactory.getLogger(getClass()); | ||
35 | + | ||
36 | + private PublisherVersionView publisherVersionView; | ||
37 | + | ||
38 | + private PublisherVersion publisherVersion; | ||
39 | + | ||
40 | + // TODO tester add et update, mais je ne sais pas comment je suis censé faire | ||
41 | + | ||
42 | + @BeforeEach | ||
43 | + public void setUp(@Mock PublisherService publisherService, @Mock SharedService sharedService) throws Exception { | ||
44 | + publisherVersionView = new PublisherVersionView(publisherService, sharedService); | ||
45 | + publisherVersionView.setEditMode(false); | ||
46 | + publisherVersionView.setNewPublisher(false); | ||
47 | + | ||
48 | + publisherVersion = new PublisherVersion(); | ||
49 | + publisherVersion.setPublisherName("A"); | ||
50 | + publisherVersion.setPublisherStreetAddress("B"); | ||
51 | + publisherVersion.setPublisherPostalCode("C"); | ||
52 | + publisherVersion.setPublisherPostOfficeBoxNumber("D"); | ||
53 | + publisherVersion.setPublisherAddressRegion("E"); | ||
54 | + publisherVersion.setPublisherAddressLocality("F"); | ||
55 | + publisherVersion.setPublisherAddressCountry(new Country()); | ||
56 | + publisherVersion.setPublisherTelephone("G"); | ||
57 | + publisherVersion.setPublisherEmail("H"); | ||
58 | + publisherVersion.setPublisherURL("I"); | ||
59 | + publisherVersion.setPublisherActive(true); | ||
60 | + publisherVersion.setPublisherHistory("J"); | ||
61 | + publisherVersion.setPublisher(new Publisher()); | ||
62 | + | ||
63 | + when(publisherService.getPublisherVersion(1)).thenReturn(publisherVersion); | ||
64 | + | ||
65 | + } | ||
66 | + | ||
67 | + @Test | ||
68 | + @DisplayName("depends on Shared Service and Publisher Service") | ||
69 | + public void testDependencies() { | ||
70 | + assertThat(publisherVersionView).isNotNull(); | ||
71 | + } | ||
72 | + | ||
73 | + @DisplayName("Passage en mode édition") | ||
74 | + @Test | ||
75 | + public void testEdit() { | ||
76 | + assertThat(publisherVersionView.isEditMode()).isFalse(); | ||
77 | + publisherVersionView.edit(); | ||
78 | + assertThat(publisherVersionView.isEditMode()).isTrue(); | ||
79 | + } | ||
80 | + | ||
81 | + @DisplayName("Annulation des données saisie pour un nouvel éditeur") | ||
82 | + @Test | ||
83 | + public void testCancelNewPublisher() { | ||
84 | + publisherVersionView.setNewPublisher(true); | ||
85 | + | ||
86 | + publisherVersionView.cancel(); | ||
87 | + | ||
88 | + assertThat(publisherVersionView.getPublisherName()).isNull(); | ||
89 | + assertThat(publisherVersionView.getPublisherStreetAddress()).isNull(); | ||
90 | + assertThat(publisherVersionView.getPublisherPostalCode()).isNull(); | ||
91 | + assertThat(publisherVersionView.getPublisherPostOfficeBoxNumber()).isNull(); | ||
92 | + assertThat(publisherVersionView.getPublisherAddressRegion()).isNull(); | ||
93 | + assertThat(publisherVersionView.getPublisherAddressLocality()).isNull(); | ||
94 | + assertThat(publisherVersionView.getPublisherTelephone()).isNull(); | ||
95 | + assertThat(publisherVersionView.getPublisherEmail()).isNull(); | ||
96 | + assertThat(publisherVersionView.getPublisherURL()).isNull(); | ||
97 | + assertThat(publisherVersionView.getPublisherHistory()).isNull(); | ||
98 | + assertThat(publisherVersionView.isPublisherActive()).isFalse(); | ||
99 | + assertThat(publisherVersionView.isEditMode()).isTrue(); | ||
100 | + } | ||
101 | + | ||
102 | + @DisplayName("Annulation de saisie de nouvelle version d'un éditeur existant") | ||
103 | + @Test | ||
104 | + public void testCancelNewVersionOfPublisher() { | ||
105 | + publisherVersionView.setNewPublisher(false); | ||
106 | + publisherVersionView.setPublisherVersionId(1); | ||
107 | + | ||
108 | + publisherVersionView.setPublisherName("1"); | ||
109 | + publisherVersionView.setPublisherStreetAddress("2"); | ||
110 | + publisherVersionView.setPublisherPostalCode("3"); | ||
111 | + publisherVersionView.setPublisherPostOfficeBoxNumber("4"); | ||
112 | + publisherVersionView.setPublisherAddressRegion("5"); | ||
113 | + publisherVersionView.setPublisherAddressLocality("6"); | ||
114 | + publisherVersionView.setPublisherAddressCountry(new Country()); | ||
115 | + publisherVersionView.setPublisherTelephone("7"); | ||
116 | + publisherVersionView.setPublisherEmail("8"); | ||
117 | + publisherVersionView.setPublisherURL("9"); | ||
118 | + publisherVersionView.setPublisherActive(false); | ||
119 | + publisherVersionView.setPublisherHistory("10"); | ||
120 | + | ||
121 | + publisherVersionView.cancel(); | ||
122 | + | ||
123 | + assertThat(publisherVersionView.getPublisherName()).isEqualTo("A"); | ||
124 | + assertThat(publisherVersionView.getPublisherStreetAddress()).isEqualTo("B"); | ||
125 | + assertThat(publisherVersionView.getPublisherPostalCode()).isEqualTo("C"); | ||
126 | + assertThat(publisherVersionView.getPublisherPostOfficeBoxNumber()).isEqualTo("D"); | ||
127 | + assertThat(publisherVersionView.getPublisherAddressRegion()).isEqualTo("E"); | ||
128 | + assertThat(publisherVersionView.getPublisherAddressLocality()).isEqualTo("F"); | ||
129 | + assertThat(publisherVersionView.getPublisherTelephone()).isEqualTo("G"); | ||
130 | + assertThat(publisherVersionView.getPublisherEmail()).isEqualTo("H"); | ||
131 | + assertThat(publisherVersionView.getPublisherURL()).isEqualTo("I"); | ||
132 | + assertThat(publisherVersionView.getPublisherHistory()).isEqualTo("J"); | ||
133 | + assertThat(publisherVersionView.isEditMode()).isFalse(); | ||
134 | + | ||
135 | + } | ||
136 | + | ||
137 | + @Test | ||
138 | + @DisplayName("Test de la fonction de chargement des valeurs initiales pour leur affichage") | ||
139 | + public void testLoadData() { | ||
140 | + publisherVersionView.setNewPublisher(true); | ||
141 | + publisherVersionView.setPublisherVersionId(1); | ||
142 | + publisherVersionView.loadData(); | ||
143 | + assertThat(publisherVersionView.getPublisherName()).isEqualTo("A"); | ||
144 | + assertThat(publisherVersionView.getPublisherStreetAddress()).isEqualTo("B"); | ||
145 | + assertThat(publisherVersionView.getPublisherPostalCode()).isEqualTo("C"); | ||
146 | + assertThat(publisherVersionView.getPublisherPostOfficeBoxNumber()).isEqualTo("D"); | ||
147 | + assertThat(publisherVersionView.getPublisherAddressRegion()).isEqualTo("E"); | ||
148 | + assertThat(publisherVersionView.getPublisherAddressLocality()).isEqualTo("F"); | ||
149 | + assertThat(publisherVersionView.getPublisherTelephone()).isEqualTo("G"); | ||
150 | + assertThat(publisherVersionView.getPublisherEmail()).isEqualTo("H"); | ||
151 | + assertThat(publisherVersionView.getPublisherURL()).isEqualTo("I"); | ||
152 | + assertThat(publisherVersionView.isPublisherActive()).isTrue(); | ||
153 | + assertThat(publisherVersionView.getPublisherHistory()).isEqualTo("J"); | ||
154 | + assertThat(publisherVersionView.isNewPublisher()).isFalse(); | ||
155 | + } | ||
156 | + | ||
157 | + @Test | ||
158 | + @DisplayName("Test initialisation formulaire pour nouvel éditeur") | ||
159 | + public void testLoadDataEmpty() { | ||
160 | + publisherVersionView.setNewPublisher(false); | ||
161 | + publisherVersionView.setPublisherVersionId(0); | ||
162 | + publisherVersionView.loadData(); | ||
163 | + assertThat(publisherVersionView.isNewPublisher()).isTrue(); | ||
164 | + assertThat(publisherVersionView.isEditMode()).isTrue(); | ||
165 | + } | ||
166 | + | ||
167 | + @Nested | ||
168 | + @DisplayName("save method") | ||
169 | + class saveTests{ | ||
170 | + PublisherVersionView publisherVersionViewForSave; | ||
171 | + public boolean addCalled = false; | ||
172 | + public boolean updateCalled = false; | ||
173 | + | ||
174 | + @BeforeEach | ||
175 | + @DisplayName("Given some test reimplementation") | ||
176 | + public void given() { | ||
177 | + publisherVersionViewForSave = new PublisherVersionView() { | ||
178 | + | ||
179 | + @Override | ||
180 | + public void add() { | ||
181 | + addCalled = true; | ||
182 | + } | ||
183 | + | ||
184 | + @Override | ||
185 | + public void update() { | ||
186 | + updateCalled = true; | ||
187 | + } | ||
188 | + | ||
189 | + }; | ||
190 | + } | ||
191 | + | ||
192 | + @Test | ||
193 | + @DisplayName("Test should call add on new publisher") | ||
194 | + public void testSaveAdd() { | ||
195 | + publisherVersionViewForSave.setNewPublisher(true); | ||
196 | + publisherVersionViewForSave.save(); | ||
197 | + assertThat(addCalled).isTrue(); | ||
198 | + } | ||
199 | + | ||
200 | + @Test | ||
201 | + @DisplayName("Test should call update on old publisher") | ||
202 | + public void testSaveUpdate() { | ||
203 | + publisherVersionViewForSave.setNewPublisher(false); | ||
204 | + publisherVersionViewForSave.save(); | ||
205 | + assertThat(updateCalled).isTrue(); | ||
206 | + } | ||
207 | + | ||
208 | + } | ||
209 | + | ||
210 | + @Nested | ||
211 | + @DisplayName("post construct method") | ||
212 | + class init { | ||
213 | + | ||
214 | + private List<Country> countries; | ||
215 | + | ||
216 | + @BeforeEach | ||
217 | + public void setUp(@Mock SharedService sharedService) { | ||
218 | + when(sharedService.getAllCountries()).thenReturn(countries); | ||
219 | + } | ||
220 | + | ||
221 | + @Test | ||
222 | + @DisplayName("should set lists of available masks, user roles, and user properties from shared service") | ||
223 | + public void testList(@Mock SharedService sharedService) { | ||
224 | + publisherVersionView.init(); | ||
225 | + assertThat(publisherVersionView.getAvailableCountries()).isEqualTo(countries); | ||
226 | + } | ||
227 | + } | ||
228 | + | ||
229 | + @Nested | ||
230 | + @DisplayName("Update method") | ||
231 | + class updateTests { | ||
232 | + | ||
233 | + @BeforeEach | ||
234 | + public void given(@Mock Publisher publisherMock) { | ||
235 | + publisherVersionView.setNewPublisher(false); | ||
236 | + | ||
237 | + publisherVersionView.setPublisherName("1"); | ||
238 | + publisherVersionView.setPublisherStreetAddress("2"); | ||
239 | + publisherVersionView.setPublisherPostalCode("3"); | ||
240 | + publisherVersionView.setPublisherPostOfficeBoxNumber("4"); | ||
241 | + publisherVersionView.setPublisherAddressRegion("5"); | ||
242 | + publisherVersionView.setPublisherAddressLocality("6"); | ||
243 | + publisherVersionView.setPublisherAddressCountry(new Country()); | ||
244 | + publisherVersionView.setPublisherTelephone("7"); | ||
245 | + publisherVersionView.setPublisherEmail("8"); | ||
246 | + publisherVersionView.setPublisherURL("9"); | ||
247 | + publisherVersionView.setPublisherActive(true); | ||
248 | + publisherVersionView.setPublisherHistory("10"); | ||
249 | + publisherVersionView.setPublisher(publisherMock); | ||
250 | + } | ||
251 | + | ||
252 | + @Nested | ||
253 | + @DisplayName("given some input fields") | ||
254 | + class given { | ||
255 | + | ||
256 | + @Captor | ||
257 | + ArgumentCaptor<PublisherVersion> publisherVersionArgumentCaptor; | ||
258 | + | ||
259 | + @Captor | ||
260 | + ArgumentCaptor<Publisher> publisherArgumentCaptor; | ||
261 | + | ||
262 | + @BeforeEach | ||
263 | + public void test(@Mock PublisherService publisherService, @Mock Publisher publisherMock, @Mock PublisherVersion publisherVersionMock) { | ||
264 | + // mock de l'appel dans Immutables values | ||
265 | + when(publisherService.getPublisherVersion(anyInt())).thenReturn(new PublisherVersion()); | ||
266 | + | ||
267 | + when(publisherService.addVersionToPublisher(any(Publisher.class), any(PublisherVersion.class))).thenReturn(publisherVersionMock); | ||
268 | + when(publisherVersionMock.getPublisher()).thenReturn(publisherMock); | ||
269 | + when(publisherVersionMock.getPublisherVersionId()).thenReturn(13); | ||
270 | + | ||
271 | + publisherVersionView.update(); | ||
272 | + } | ||
273 | + | ||
274 | + @DisplayName("doit ajouter une nouvelle version à un éditeur") | ||
275 | + @Test | ||
276 | + public void shouldAddNewVersion(@Mock PublisherService publisherService) { | ||
277 | + Mockito.verify(publisherService).addVersionToPublisher(publisherArgumentCaptor.capture(), publisherVersionArgumentCaptor.capture()); | ||
278 | + PublisherVersion publisherVersion = publisherVersionArgumentCaptor.getValue(); | ||
279 | + assertThat(publisherVersion.getPublisherName()).isEqualTo("1"); | ||
280 | + } | ||
281 | + | ||
282 | + @DisplayName("should put state in non edit mode") | ||
283 | + @Test | ||
284 | + public void shouldNonEdit() { | ||
285 | + assertThat(publisherVersionView.isEditMode()).isFalse(); | ||
286 | + } | ||
287 | + | ||
288 | + @DisplayName("should put state in non new publisher with new ids") | ||
289 | + @Test | ||
290 | + public void shouldNonNewPublisher(@Mock Publisher publisherMock) { | ||
291 | + | ||
292 | + assertThat(publisherVersionView.isNewPublisher()).isFalse(); | ||
293 | + assertThat(publisherVersionView.getPublisher()).isEqualTo(publisherMock); | ||
294 | + assertThat(publisherVersionView.getPublisherVersionId()).isEqualTo(13); | ||
295 | + } | ||
296 | + | ||
297 | + } | ||
298 | + | ||
299 | + } | ||
300 | + | ||
301 | + @Nested | ||
302 | + @DisplayName("Add method") | ||
303 | + class addTests { | ||
304 | + | ||
305 | + @BeforeEach | ||
306 | + public void given(@Mock Publisher publisherMock) { | ||
307 | + publisherVersionView.setNewPublisher(true); | ||
308 | + | ||
309 | + publisherVersionView.setPublisherName("A"); | ||
310 | + publisherVersionView.setPublisherStreetAddress("B"); | ||
311 | + publisherVersionView.setPublisherPostalCode("C"); | ||
312 | + publisherVersionView.setPublisherPostOfficeBoxNumber("D"); | ||
313 | + publisherVersionView.setPublisherAddressRegion("E"); | ||
314 | + publisherVersionView.setPublisherAddressLocality("F"); | ||
315 | + publisherVersionView.setPublisherAddressCountry(new Country()); | ||
316 | + publisherVersionView.setPublisherTelephone("G"); | ||
317 | + publisherVersionView.setPublisherEmail("H"); | ||
318 | + publisherVersionView.setPublisherURL("I"); | ||
319 | + publisherVersionView.setPublisherActive(true); | ||
320 | + publisherVersionView.setPublisherHistory("J"); | ||
321 | + publisherVersionView.setPublisher(publisherMock); | ||
322 | + } | ||
323 | + | ||
324 | + @Nested | ||
325 | + @DisplayName("given some input fields") | ||
326 | + class given { | ||
327 | + | ||
328 | + @Captor | ||
329 | + ArgumentCaptor<PublisherVersion> publisherVersionArgumentCaptor; | ||
330 | + | ||
331 | + @BeforeEach | ||
332 | + public void test(@Mock PublisherService publisherService, @Mock Publisher publisherMock, @Mock PublisherVersion publisherVersionMock) { | ||
333 | + // mock de l'appel dans Immutables values | ||
334 | + when(publisherService.getPublisherVersion(anyInt())).thenReturn(new PublisherVersion()); | ||
335 | + | ||
336 | + | ||
337 | + when(publisherService.addNewPublisher(any(PublisherVersion.class))).thenReturn(publisherVersionMock); | ||
338 | + when(publisherVersionMock.getPublisher()).thenReturn(publisherMock); | ||
339 | + when(publisherVersionMock.getPublisherVersionId()).thenReturn(42); | ||
340 | + publisherVersionView.add(); | ||
341 | + } | ||
342 | + | ||
343 | + @DisplayName("should create in the application a new publisher with its first version") | ||
344 | + @Test | ||
345 | + public void shouldSave(@Mock PublisherService publisherService) { | ||
346 | + Mockito.verify(publisherService).addNewPublisher(publisherVersionArgumentCaptor.capture()); | ||
347 | + PublisherVersion publisherVersion = publisherVersionArgumentCaptor.getValue(); | ||
348 | + assertThat(publisherVersion.getPublisherName()).isEqualTo("A"); | ||
349 | + } | ||
350 | + | ||
351 | + | ||
352 | + @DisplayName("should put state in non edit mode") | ||
353 | + @Test | ||
354 | + public void shouldNonEdit() { | ||
355 | + assertThat(publisherVersionView.isEditMode()).isFalse(); | ||
356 | + } | ||
357 | + | ||
358 | + @DisplayName("should put state in non new publisher with new ids") | ||
359 | + @Test | ||
360 | + public void shouldNonNewPublisher(@Mock Publisher publisherMock) { | ||
361 | + | ||
362 | + assertThat(publisherVersionView.isNewPublisher()).isFalse(); | ||
363 | + assertThat(publisherVersionView.getPublisher()).isEqualTo(publisherMock); | ||
364 | + assertThat(publisherVersionView.getPublisherVersionId()).isEqualTo(42); | ||
365 | + } | ||
366 | + | ||
367 | + } | ||
368 | + | ||
369 | + } | ||
370 | + | ||
371 | +} |
1 | +package org.legrog.web.user; | ||
2 | + | ||
3 | +import org.junit.jupiter.api.BeforeEach; | ||
4 | +import org.junit.jupiter.api.DisplayName; | ||
5 | +import org.junit.jupiter.api.Nested; | ||
6 | +import org.junit.jupiter.api.Test; | ||
7 | +import org.junit.jupiter.api.extension.ExtendWith; | ||
8 | +import org.junit.platform.runner.JUnitPlatform; | ||
9 | +import org.junit.runner.RunWith; | ||
10 | +import org.legrog.entities.DisplayNameMask; | ||
11 | +import org.legrog.test.MockitoExtension; | ||
12 | +import org.legrog.web.xyz.SharedService; | ||
13 | +import org.mockito.Mock; | ||
14 | + | ||
15 | +import java.util.List; | ||
16 | + | ||
17 | +import static org.assertj.core.api.Assertions.assertThat; | ||
18 | +import static org.mockito.Mockito.when; | ||
19 | + | ||
20 | +/** | ||
21 | + * Created by jai on 15/11/16. | ||
22 | + */ | ||
23 | +@DisplayName("Update Person Bean") | ||
24 | +@ExtendWith(MockitoExtension.class) | ||
25 | +@RunWith(JUnitPlatform.class) | ||
26 | +public class UpdatePersonBeanTest { | ||
27 | + | ||
28 | + UpdateUserBean updateUserBean; | ||
29 | + | ||
30 | + @BeforeEach | ||
31 | + public void setUp(@Mock UserService userService, @Mock SharedService sharedService) throws Exception { | ||
32 | + updateUserBean = new UpdateUserBean(userService, sharedService) ; | ||
33 | + } | ||
34 | + | ||
35 | + @Test | ||
36 | + @DisplayName("depends on Shared Service and Person Service") | ||
37 | + public void testDependencies() { | ||
38 | + assertThat(updateUserBean).isNotNull(); | ||
39 | + } | ||
40 | + | ||
41 | + @Nested | ||
42 | + @DisplayName("post construct method") | ||
43 | + class init { | ||
44 | + | ||
45 | + private List<DisplayNameMask> displayNameMasks; | ||
46 | + private List<org.legrog.entities.UserProperty> userProperties; | ||
47 | + private List<org.legrog.entities.UserRole> userRoles; | ||
48 | + | ||
49 | + @BeforeEach | ||
50 | + public void setUp(@Mock SharedService sharedService) { | ||
51 | + when(sharedService.getAllDisplayNameMasks()).thenReturn(displayNameMasks); | ||
52 | + when(sharedService.getAvailableUserProperties()).thenReturn(userProperties); | ||
53 | + when(sharedService.getAvailableUserRoles()).thenReturn(userRoles); | ||
54 | + } | ||
55 | + | ||
56 | + @Test | ||
57 | + @DisplayName("should set lists of available masks, user roles, and user properties from shared service") | ||
58 | + public void testList(@Mock SharedService sharedService) { | ||
59 | + updateUserBean.init(); | ||
60 | + assertThat(updateUserBean.getAllDisplayNameMasks()).isEqualTo(displayNameMasks); | ||
61 | + assertThat(updateUserBean.getAvailableUserProperties()).isEqualTo(userProperties); | ||
62 | + assertThat(updateUserBean.getAvailableUserRoles()).isEqualTo(userRoles); | ||
63 | + } | ||
64 | + } | ||
65 | + | ||
66 | + | ||
67 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment