Showing
11 changed files
with
181 additions
and
15 deletions
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 addPublisherRevission(PublisherRevision publisherRevision); | ||
9 | + | ||
10 | + List<PublisherRevision> getAllPublisherRevisions(); | ||
11 | +} |
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 addPublisherRevission(PublisherRevision publisherRevision) { | ||
16 | + publisherRevisionRepository.save(publisherRevision); | ||
17 | + } | ||
18 | + | ||
19 | + public List<PublisherRevision> getAllPublisherRevisions() { | ||
20 | + return publisherRevisionRepository.findAll(); | ||
21 | + } | ||
22 | +} |
... | @@ -5,7 +5,8 @@ import javax.persistence.*; | ... | @@ -5,7 +5,8 @@ import javax.persistence.*; |
5 | @Entity | 5 | @Entity |
6 | public class Country /* extends org.roliste.data.DbEntity */ { | 6 | public class Country /* extends org.roliste.data.DbEntity */ { |
7 | @Id | 7 | @Id |
8 | - @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ | 8 | +// @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ |
9 | + @GeneratedValue(strategy = GenerationType.AUTO) | ||
9 | @Column(name="COUNTRY_ID") | 10 | @Column(name="COUNTRY_ID") |
10 | private int countryId; | 11 | private int countryId; |
11 | private String countryName; | 12 | private String countryName; | ... | ... |
1 | package org.legrog.presentation; | 1 | package org.legrog.presentation; |
2 | 2 | ||
3 | +import org.legrog.application.PublisherRevisionService; | ||
4 | +import org.legrog.application.PublisherService; | ||
3 | import org.legrog.application.SharedService; | 5 | import org.legrog.application.SharedService; |
4 | import org.legrog.application.UserService; | 6 | import org.legrog.application.UserService; |
5 | import org.legrog.entities.Country; | 7 | import org.legrog.entities.Country; |
... | @@ -13,7 +15,9 @@ import javax.annotation.PostConstruct; | ... | @@ -13,7 +15,9 @@ import javax.annotation.PostConstruct; |
13 | import javax.enterprise.context.RequestScoped; | 15 | import javax.enterprise.context.RequestScoped; |
14 | import javax.inject.Inject; | 16 | import javax.inject.Inject; |
15 | import javax.inject.Named; | 17 | import javax.inject.Named; |
18 | +import java.util.Date; | ||
16 | import java.sql.Timestamp; | 19 | import java.sql.Timestamp; |
20 | +import java.time.ZoneId; | ||
17 | import java.util.HashSet; | 21 | import java.util.HashSet; |
18 | import java.util.List; | 22 | import java.util.List; |
19 | import java.util.Random; | 23 | import java.util.Random; |
... | @@ -27,6 +31,10 @@ public class AddPublisherBean { | ... | @@ -27,6 +31,10 @@ public class AddPublisherBean { |
27 | private SharedService sharedService; | 31 | private SharedService sharedService; |
28 | @Inject | 32 | @Inject |
29 | private UserService userService; | 33 | private UserService userService; |
34 | + @Inject | ||
35 | + private PublisherService publisherService; | ||
36 | + @Inject | ||
37 | + private PublisherRevisionService publisherRevisionService; | ||
30 | 38 | ||
31 | private String publisherName; | 39 | private String publisherName; |
32 | private String publisherStreetAddress; | 40 | private String publisherStreetAddress; |
... | @@ -65,8 +73,7 @@ public class AddPublisherBean { | ... | @@ -65,8 +73,7 @@ public class AddPublisherBean { |
65 | publisherRevision.setPublisherTelephone(publisherTelephone); | 73 | publisherRevision.setPublisherTelephone(publisherTelephone); |
66 | publisherRevision.setPublisherURL(publisherURL); | 74 | publisherRevision.setPublisherURL(publisherURL); |
67 | 75 | ||
68 | - // TODO Savoir si on utilise les temps UTC dans la base ou pas (ici, c'est le cas, mais il faut convertir à chaque affichage) | 76 | + publisherRevision.setPublisherRevisionDatetime(new Timestamp(new Date().getTime())); |
69 | - publisherRevision.setPublisherRevisionDatetime(new Timestamp(System.currentTimeMillis())); | ||
70 | 77 | ||
71 | // TODO Remplacer l'astuce par une vraie récupération de l'utilisateur | 78 | // TODO Remplacer l'astuce par une vraie récupération de l'utilisateur |
72 | List<User> users = userService.getAllUsers(); | 79 | List<User> users = userService.getAllUsers(); |
... | @@ -75,6 +82,8 @@ public class AddPublisherBean { | ... | @@ -75,6 +82,8 @@ public class AddPublisherBean { |
75 | // End TODO | 82 | // End TODO |
76 | publisherRevision.setPublisherRevisionAuthor(user); | 83 | publisherRevision.setPublisherRevisionAuthor(user); |
77 | logger.info(publisherRevision.toString()); | 84 | logger.info(publisherRevision.toString()); |
85 | + publisherRevisionService.addPublisherRevission(publisherRevision); | ||
86 | + publisherService.addPublisher(publisher); | ||
78 | return "success"; | 87 | return "success"; |
79 | } | 88 | } |
80 | 89 | ... | ... |
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 | -INSERT INTO Country VALUES (1, 'France'); | 1 | +INSERT INTO Country (countryName) VALUES ('France'); |
2 | -INSERT INTO Country VALUES (2, 'Suisse'); | 2 | +INSERT INTO Country (countryName) VALUES ('Suisse'); |
3 | -INSERT INTO Country VALUES (4, 'Belgique'); | 3 | +INSERT INTO Country (countryName) VALUES ('Belgique'); |
4 | -INSERT INTO Country VALUES (5, 'Canada'); | 4 | +INSERT INTO Country (countryName) VALUES ('Canada'); |
5 | -INSERT INTO Country VALUES (6, 'États-Unis d''Amérique'); | 5 | +INSERT INTO Country (countryName) VALUES ('États-Unis d''Amérique'); |
6 | -INSERT INTO Country VALUES (7, 'Australie'); | 6 | +INSERT INTO Country (countryName) VALUES ('Australie'); |
7 | -INSERT INTO Country VALUES (8, 'Espagne'); | 7 | +INSERT INTO Country (countryName) VALUES ('Espagne'); |
8 | -INSERT INTO Country VALUES (9, 'Portugal'); | 8 | +INSERT INTO Country (countryName) VALUES ('Portugal'); |
9 | -INSERT INTO Country VALUES (10, 'Royaume-Uni'); | 9 | +INSERT INTO Country (countryName) VALUES ('Royaume-Uni'); |
10 | -INSERT INTO Country VALUES (11, 'Allemagne'); | 10 | +INSERT INTO Country (countryName) VALUES ('Allemagne'); |
11 | -INSERT INTO Country VALUES (12, 'Pologne'); | 11 | +INSERT INTO Country (countryName) VALUES ('Pologne'); |
12 | +INSERT INTO Country (countryName) VALUES ('Italie'); | ||
12 | INSERT INTO UserRole VALUES (1, 'VISITEUR', TRUE); | 13 | INSERT INTO UserRole VALUES (1, 'VISITEUR', TRUE); |
13 | INSERT INTO UserRole VALUES (2, 'RECRUE', TRUE); | 14 | INSERT INTO UserRole VALUES (2, 'RECRUE', TRUE); |
14 | INSERT INTO UserRole VALUES (3, 'CONTRIBUTEUR', TRUE); | 15 | INSERT INTO UserRole VALUES (3, 'CONTRIBUTEUR', TRUE); | ... | ... |
... | @@ -44,7 +44,13 @@ | ... | @@ -44,7 +44,13 @@ |
44 | <to-view-id>/addPublisher.xhtml</to-view-id> | 44 | <to-view-id>/addPublisher.xhtml</to-view-id> |
45 | </navigation-case> | 45 | </navigation-case> |
46 | </navigation-rule> | 46 | </navigation-rule> |
47 | - | 47 | + <navigation-rule> |
48 | + <from-view-id>/addPublisher.xhtml</from-view-id> | ||
49 | + <navigation-case> | ||
50 | + <from-outcome>success</from-outcome> | ||
51 | + <to-view-id>/listPublisherRevisions.xhtml</to-view-id> | ||
52 | + </navigation-case> | ||
53 | + </navigation-rule> | ||
48 | <navigation-rule> | 54 | <navigation-rule> |
49 | <from-view-id>/addCountry.xhtml</from-view-id> | 55 | <from-view-id>/addCountry.xhtml</from-view-id> |
50 | <navigation-case> | 56 | <navigation-case> |
... | @@ -95,4 +101,12 @@ | ... | @@ -95,4 +101,12 @@ |
95 | <to-view-id>/updateUser.xhtml</to-view-id> | 101 | <to-view-id>/updateUser.xhtml</to-view-id> |
96 | </navigation-case> | 102 | </navigation-case> |
97 | </navigation-rule> | 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> | ||
111 | + </navigation-rule> | ||
98 | </faces-config> | 112 | </faces-config> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
src/main/webapp/listPublisherRevisions.xhtml
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 | +<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 id="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/publisherRevision.xhtml
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 | +<body> | ||
9 | +<h:outputText value="#{param['publisherRevisionId']}" /> | ||
10 | +</body> | ||
11 | +</html> |
-
Please register or login to post a comment