Jean-Francois Leveque

https://tree.taiga.io/project/jr-utily-grog-v3/us/44 Implementer l'historisation pour les éditeurs

https://tree.taiga.io/project/jr-utily-grog-v3/task/77 Présentation des versions d'un éditeur
https://tree.taiga.io/project/jr-utily-grog-v3/task/53 Validation d'une version
...@@ -15,10 +15,10 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { ...@@ -15,10 +15,10 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
15 private int publisherId; 15 private int publisherId;
16 16
17 @OneToOne 17 @OneToOne
18 - private PublisherRevision activeRevision; 18 + private PublisherRevision validatedRevision;
19 19
20 @OneToOne 20 @OneToOne
21 - private User activeValidator; 21 + private User validator;
22 22
23 private Timestamp validationDateTime; 23 private Timestamp validationDateTime;
24 24
...@@ -33,12 +33,12 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { ...@@ -33,12 +33,12 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
33 this.publisherId = publisherId; 33 this.publisherId = publisherId;
34 } 34 }
35 35
36 - public PublisherRevision getActiveRevision() { 36 + public PublisherRevision getValidatedRevision() {
37 - return activeRevision; 37 + return validatedRevision;
38 } 38 }
39 39
40 - public void setActiveRevision(PublisherRevision activeRevision) { 40 + public void setValidatedRevision(PublisherRevision activeRevision) {
41 - this.activeRevision = activeRevision; 41 + this.validatedRevision = activeRevision;
42 } 42 }
43 43
44 public Set<PublisherRevision> getRevisions() { 44 public Set<PublisherRevision> getRevisions() {
...@@ -49,12 +49,12 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { ...@@ -49,12 +49,12 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
49 this.revisions = revisions; 49 this.revisions = revisions;
50 } 50 }
51 51
52 - public User getActiveValidator() { 52 + public User getValidator() {
53 - return activeValidator; 53 + return validator;
54 } 54 }
55 55
56 - public void setActiveValidator(User activeValidator) { 56 + public void setValidator(User activeValidator) {
57 - this.activeValidator = activeValidator; 57 + this.validator = activeValidator;
58 } 58 }
59 59
60 public Timestamp getValidationDateTime() { 60 public Timestamp getValidationDateTime() {
...@@ -67,6 +67,6 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { ...@@ -67,6 +67,6 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
67 67
68 @Override 68 @Override
69 public String toString() { 69 public String toString() {
70 - return "PUBLISHER_ID = " + publisherId + ", Active Revision = " + activeRevision + ", Validator = " + activeValidator + ", Validation DateTime = " + validationDateTime; 70 + return "PUBLISHER_ID = " + publisherId + ", Active Revision = " + validatedRevision + ", Validator = " + validator + ", Validation DateTime = " + validationDateTime;
71 } 71 }
72 } 72 }
......
1 -package org.legrog.web.publisher;
2 -
3 -import org.legrog.web.xyz.SharedService;
4 -import org.legrog.web.user.UserService;
5 -import org.legrog.entities.Country;
6 -import org.legrog.entities.Publisher;
7 -import org.legrog.entities.PublisherRevision;
8 -import org.legrog.entities.User;
9 -import org.slf4j.Logger;
10 -import org.slf4j.LoggerFactory;
11 -
12 -import javax.annotation.PostConstruct;
13 -import javax.enterprise.context.RequestScoped;
14 -import javax.inject.Inject;
15 -import javax.inject.Named;
16 -import java.sql.Timestamp;
17 -import java.util.Date;
18 -import java.util.HashSet;
19 -import java.util.List;
20 -import java.util.Random;
21 -
22 -@Named
23 -@RequestScoped
24 -public class AddPublisherBean {
25 - Logger logger = LoggerFactory.getLogger(getClass());
26 -
27 - @Inject
28 - private SharedService sharedService;
29 - @Inject
30 - private UserService userService;
31 - @Inject
32 - private PublisherService publisherService;
33 -
34 -
35 - private String publisherName;
36 - private String publisherStreetAddress;
37 - private String publisherPostalCode;
38 - private String publisherPostOfficeBoxNumber;
39 - private String publisherAddressRegion;
40 - private String publisherAddressLocality;
41 - private Country publisherAddressCountry;
42 - private String publisherTelephone;
43 - private String publisherEmail;
44 - private String publisherURL;
45 - private boolean publisherActive;
46 - private String publisherHistory;
47 -
48 - private List<Country> availableCountries;
49 -
50 - public String add() {
51 - logger.info("add");
52 - Publisher publisher = new Publisher();
53 - PublisherRevision publisherRevision = new PublisherRevision();
54 - HashSet<PublisherRevision> publisherRevisions = new HashSet<PublisherRevision>();
55 - publisherRevisions.add(publisherRevision);
56 - publisher.setRevisions(publisherRevisions);
57 - logger.info(publisher.toString());
58 - publisherRevision.setPublisher(publisher);
59 - publisherRevision.setPublisherActive(publisherActive);
60 - publisherRevision.setPublisherAddressCountry(publisherAddressCountry);
61 - publisherRevision.setPublisherAddressLocality(publisherAddressLocality);
62 - publisherRevision.setPublisherAddressRegion(publisherAddressRegion);
63 - publisherRevision.setPublisherEmail(publisherEmail);
64 - publisherRevision.setPublisherHistory(publisherHistory);
65 - publisherRevision.setPublisherName(publisherName);
66 - publisherRevision.setPublisherPostalCode(publisherPostalCode);
67 - publisherRevision.setPublisherPostOfficeBoxNumber(publisherPostOfficeBoxNumber);
68 - publisherRevision.setPublisherStreetAddress(publisherStreetAddress);
69 - publisherRevision.setPublisherTelephone(publisherTelephone);
70 - publisherRevision.setPublisherURL(publisherURL);
71 -
72 - publisherRevision.setPublisherRevisionDatetime(new Timestamp(new Date().getTime()));
73 -
74 - // TODO Remplacer l'astuce par une vraie récupération de l'utilisateur
75 - List<User> users = userService.getAllUsers();
76 - Random random = new Random();
77 - User user = users.get(random.nextInt(users.size()));
78 - // End TODO
79 - publisherRevision.setPublisherRevisionAuthor(user);
80 - logger.info(publisherRevision.toString());
81 -
82 - // FIXME un seul appel logique à faire (pour la gestion du rollback)
83 - publisherService.addPublisher(publisher);
84 - publisherService.addPublisherRevision(publisherRevision);
85 -
86 - // Test de récupération de l'Id
87 - logger.info(publisherRevision.toString());
88 - return "success";
89 - }
90 -
91 - @PostConstruct
92 - public void init() {
93 - availableCountries = sharedService.getAllCountries();
94 - }
95 -
96 - public String getPublisherName() {
97 - return publisherName;
98 - }
99 -
100 - public void setPublisherName(String publisherName) {
101 - this.publisherName = publisherName;
102 - }
103 -
104 - public String getPublisherStreetAddress() {
105 - return publisherStreetAddress;
106 - }
107 -
108 - public void setPublisherStreetAddress(String publisherStreetAddress) {
109 - this.publisherStreetAddress = publisherStreetAddress;
110 - }
111 -
112 - public String getPublisherPostalCode() {
113 - return publisherPostalCode;
114 - }
115 -
116 - public void setPublisherPostalCode(String publisherPostalCode) {
117 - this.publisherPostalCode = publisherPostalCode;
118 - }
119 -
120 - public String getPublisherPostOfficeBoxNumber() {
121 - return publisherPostOfficeBoxNumber;
122 - }
123 -
124 - public void setPublisherPostOfficeBoxNumber(String publisherPostOfficeBoxNumber) {
125 - this.publisherPostOfficeBoxNumber = publisherPostOfficeBoxNumber;
126 - }
127 -
128 - public String getPublisherAddressRegion() {
129 - return publisherAddressRegion;
130 - }
131 -
132 - public void setPublisherAddressRegion(String publisherAddressRegion) {
133 - this.publisherAddressRegion = publisherAddressRegion;
134 - }
135 -
136 - public String getPublisherAddressLocality() {
137 - return publisherAddressLocality;
138 - }
139 -
140 - public void setPublisherAddressLocality(String publisherAddressLocality) {
141 - this.publisherAddressLocality = publisherAddressLocality;
142 - }
143 -
144 - public Country getPublisherAddressCountry() {
145 - return publisherAddressCountry;
146 - }
147 -
148 - public void setPublisherAddressCountry(Country publisherAddressCountry) {
149 - this.publisherAddressCountry = publisherAddressCountry;
150 - }
151 -
152 - public String getPublisherTelephone() {
153 - return publisherTelephone;
154 - }
155 -
156 - public void setPublisherTelephone(String publisherTelephone) {
157 - this.publisherTelephone = publisherTelephone;
158 - }
159 -
160 - public String getPublisherEmail() {
161 - return publisherEmail;
162 - }
163 -
164 - public void setPublisherEmail(String publisherEmail) {
165 - this.publisherEmail = publisherEmail;
166 - }
167 -
168 - public String getPublisherURL() {
169 - return publisherURL;
170 - }
171 -
172 - public void setPublisherURL(String publisherURL) {
173 - this.publisherURL = publisherURL;
174 - }
175 -
176 - public boolean isPublisherActive() {
177 - return publisherActive;
178 - }
179 -
180 - public void setPublisherActive(boolean publisherActive) {
181 - this.publisherActive = publisherActive;
182 - }
183 -
184 - public String getPublisherHistory() {
185 - return publisherHistory;
186 - }
187 -
188 - public void setPublisherHistory(String publisherHistory) {
189 - this.publisherHistory = publisherHistory;
190 - }
191 -
192 - public List<Country> getAvailableCountries() {
193 - return availableCountries;
194 - }
195 -
196 - public void setAvailableCountries(List<Country> availableCountries) {
197 - this.availableCountries = availableCountries;
198 - }
199 -}
...\ No newline at end of file ...\ No newline at end of file
1 package org.legrog.web.publisher; 1 package org.legrog.web.publisher;
2 2
3 +import org.legrog.entities.Publisher;
3 import org.legrog.entities.PublisherRevision; 4 import org.legrog.entities.PublisherRevision;
5 +import org.legrog.entities.User;
6 +import org.legrog.web.user.UserService;
7 +import org.legrog.web.xyz.SharedService;
4 import org.slf4j.Logger; 8 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory; 9 import org.slf4j.LoggerFactory;
6 10
7 import javax.annotation.PostConstruct; 11 import javax.annotation.PostConstruct;
8 import javax.enterprise.context.RequestScoped; 12 import javax.enterprise.context.RequestScoped;
13 +import javax.faces.context.FacesContext;
9 import javax.inject.Inject; 14 import javax.inject.Inject;
10 import javax.inject.Named; 15 import javax.inject.Named;
11 -import java.util.ArrayList; 16 +import java.sql.Timestamp;
12 -import java.util.Iterator; 17 +import java.util.*;
13 -import java.util.List;
14 18
15 @Named 19 @Named
16 @RequestScoped 20 @RequestScoped
...@@ -19,6 +23,11 @@ public class ListPublisherRevisionsView { ...@@ -19,6 +23,11 @@ public class ListPublisherRevisionsView {
19 23
20 @Inject 24 @Inject
21 PublisherService publisherService; 25 PublisherService publisherService;
26 + @Inject
27 + SharedService sharedService;
28 + @Inject
29 + UserService userService;
30 +
22 31
23 private Integer publisherId; 32 private Integer publisherId;
24 33
...@@ -29,8 +38,26 @@ public class ListPublisherRevisionsView { ...@@ -29,8 +38,26 @@ public class ListPublisherRevisionsView {
29 public List<PublisherRevision> getPublisherRevisions() { 38 public List<PublisherRevision> getPublisherRevisions() {
30 return publisherRevisions; 39 return publisherRevisions;
31 } 40 }
32 -/* 41 +
33 -*/ 42 + public void validate() {
43 + logger.debug("validate");
44 + Publisher publisher = publisherService.getPublisher(publisherId);
45 + logger.debug("publisher (pre-validate) = {}", publisher);
46 + FacesContext facesContext = FacesContext.getCurrentInstance();
47 + Map<String,String> params =
48 + facesContext.getExternalContext().getRequestParameterMap();
49 + Integer publisherRevisionId = new Integer(params.get("publisherRevisionId"));
50 + publisher.setValidatedRevision(publisherService.getPublisherRevision(publisherRevisionId));
51 + User user = sharedService.getCurrentUser();
52 + publisher.setValidator(user);
53 + publisher.setValidationDateTime(new Timestamp(new Date().getTime()));
54 + publisherService.updatePublisher(publisher);
55 +// TODO : comprendre pourquoi ceci est nécessaire
56 + publisherRevisions = publisherService.getAllPublisherRevisions();
57 + publisherRevisions = filter();
58 + logger.debug("publisher (post-validate) = {}", publisher);
59 + }
60 +
34 @PostConstruct 61 @PostConstruct
35 public void init() { 62 public void init() {
36 publisherRevisions = publisherService.getAllPublisherRevisions(); 63 publisherRevisions = publisherService.getAllPublisherRevisions();
...@@ -38,22 +65,24 @@ public class ListPublisherRevisionsView { ...@@ -38,22 +65,24 @@ public class ListPublisherRevisionsView {
38 65
39 } 66 }
40 67
68 + List<PublisherRevision> filter() {
69 + ArrayList<PublisherRevision> filteredPublisherRevisions= new ArrayList<PublisherRevision>();
70 +
71 + for(PublisherRevision publisherRevision : publisherRevisions) {
72 + if (publisherRevision.getPublisher().getPublisherId() == publisherId) {
73 + filteredPublisherRevisions.add(publisherRevision);
74 + }
75 + }
76 + return filteredPublisherRevisions;
77 + }
78 +
41 public void setView() { 79 public void setView() {
42 logger.info("setView"); 80 logger.info("setView");
43 logger.info("publisherId = " + publisherId); 81 logger.info("publisherId = " + publisherId);
44 viewAll = ( publisherId == null ) ; 82 viewAll = ( publisherId == null ) ;
45 if (!viewAll) { 83 if (!viewAll) {
46 logger.info("!viewAll"); 84 logger.info("!viewAll");
47 - ArrayList<PublisherRevision> filteredPublisherRevisions= new ArrayList<PublisherRevision>(); 85 + publisherRevisions = filter();
48 -
49 - Iterator<PublisherRevision> publisherRevisionIterator = publisherRevisions.iterator();
50 -
51 - for(PublisherRevision publisherRevision : publisherRevisions) {
52 - if (publisherRevision.getPublisher().getPublisherId() == publisherId.intValue()) {
53 - filteredPublisherRevisions.add(publisherRevision);
54 - }
55 - }
56 - publisherRevisions = filteredPublisherRevisions;
57 } 86 }
58 } 87 }
59 88
......
...@@ -27,12 +27,11 @@ public class PublisherRevisionView implements Serializable { ...@@ -27,12 +27,11 @@ public class PublisherRevisionView implements Serializable {
27 Logger logger = LoggerFactory.getLogger(getClass()); 27 Logger logger = LoggerFactory.getLogger(getClass());
28 28
29 @Inject 29 @Inject
30 - private PublisherService publisherService; 30 + PublisherService publisherService;
31 -
32 @Inject 31 @Inject
33 UserService userService; 32 UserService userService;
34 @Inject 33 @Inject
35 - private SharedService sharedService; 34 + SharedService sharedService;
36 35
37 private boolean editMode; 36 private boolean editMode;
38 private boolean newPublisher; 37 private boolean newPublisher;
...@@ -100,11 +99,8 @@ public class PublisherRevisionView implements Serializable { ...@@ -100,11 +99,8 @@ public class PublisherRevisionView implements Serializable {
100 99
101 publisherRevision.setPublisherRevisionDatetime(new Timestamp(new Date().getTime())); 100 publisherRevision.setPublisherRevisionDatetime(new Timestamp(new Date().getTime()));
102 101
103 - // TODO Remplacer l'astuce par une vraie récupération de l'utilisateur 102 + User user = sharedService.getCurrentUser();
104 - List<User> users = userService.getAllUsers(); 103 +
105 - Random random = new Random();
106 - User user = users.get(random.nextInt(users.size()));
107 - // End TODO
108 publisherRevision.setPublisherRevisionAuthor(user); 104 publisherRevision.setPublisherRevisionAuthor(user);
109 105
110 } 106 }
......
...@@ -9,6 +9,8 @@ public interface PublisherService { ...@@ -9,6 +9,8 @@ public interface PublisherService {
9 9
10 void addPublisher(Publisher publisher); 10 void addPublisher(Publisher publisher);
11 11
12 + void updatePublisher(Publisher publisher);
13 +
12 void addRevisionToPublisher(Publisher publisher, PublisherRevision publisherRevision); 14 void addRevisionToPublisher(Publisher publisher, PublisherRevision publisherRevision);
13 15
14 List<Publisher> getAllPublishers(); 16 List<Publisher> getAllPublishers();
......
...@@ -35,6 +35,10 @@ public class PublisherServiceSpring implements PublisherService { ...@@ -35,6 +35,10 @@ public class PublisherServiceSpring implements PublisherService {
35 publisherRepository.save(publisher); 35 publisherRepository.save(publisher);
36 } 36 }
37 37
38 + public void updatePublisher(Publisher publisher) {
39 + publisherRepository.save(publisher);
40 + }
41 +
38 public void addRevisionToPublisher(Publisher publisher, PublisherRevision publisherRevision) { 42 public void addRevisionToPublisher(Publisher publisher, PublisherRevision publisherRevision) {
39 Set<PublisherRevision> publisherRevisionSet = publisher.getRevisions(); 43 Set<PublisherRevision> publisherRevisionSet = publisher.getRevisions();
40 publisherRevisionSet.add(publisherRevision); 44 publisherRevisionSet.add(publisherRevision);
......
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>
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
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:h="http://xmlns.jcp.org/jsf/html"
6 + xmlns:jsf="http://xmlns.jcp.org/jsf"
6 xmlns:ui="http://xmlns.jcp.org/jsf/facelets" 7 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
7 xmlns:f="http://xmlns.jcp.org/jsf/core"> 8 xmlns:f="http://xmlns.jcp.org/jsf/core">
8 <f:metadata> 9 <f:metadata>
...@@ -13,21 +14,26 @@ ...@@ -13,21 +14,26 @@
13 <h:form> 14 <h:form>
14 <ul> 15 <ul>
15 <li> 16 <li>
16 - <h:link outcome="/index"> 17 + <a jsf:outcome="/index">Menu principal</a>
17 - <h:outputText value="Menu principal"/>
18 - </h:link>
19 </li> 18 </li>
20 <li> 19 <li>
21 - <h:link outcome="/publisherRevision"> 20 + <a jsf:outcome="publisherRevision">Ajouter un éditeur</a>
22 - <h:outputText value="Ajouter un éditeur"/>
23 - </h:link>
24 </li> 21 </li>
25 </ul> 22 </ul>
26 </h:form> 23 </h:form>
27 24
28 - <h:link rendered="#{not listPublisherRevisionsView.viewAll}" outcome="/listPublisherRevisions.xhtml">Voir tous les éditeurs</h:link> 25 + <h:link rendered="#{not listPublisherRevisionsView.viewAll}" outcome="listPublisherRevisions">Voir tous les éditeurs</h:link>
26 + <ui:remove>
27 + <h:outputText rendered="#{not listPublisherRevisionsView.viewAll}">Révision valide #{listPublisherRevisionsView.publisherRevisions.get(0).publisher.validatedRevision.publisherRevisionId}</h:outputText>
28 + </ui:remove>
29 <h:outputText rendered="#{listPublisherRevisionsView.publisherRevisions.isEmpty()}">Liste des révisions est vide</h:outputText> 29 <h:outputText rendered="#{listPublisherRevisionsView.publisherRevisions.isEmpty()}">Liste des révisions est vide</h:outputText>
30 <h:dataTable value="#{listPublisherRevisionsView.publisherRevisions}" var="revision"> 30 <h:dataTable value="#{listPublisherRevisionsView.publisherRevisions}" var="revision">
31 + <ui:remove>
32 + <h:column>
33 + <f:facet name="header">Id</f:facet>
34 + #{revision.publisherRevisionId}
35 + </h:column>
36 + </ui:remove>
31 <h:column> 37 <h:column>
32 <f:facet name="header">Visualiser ou Modifier</f:facet> 38 <f:facet name="header">Visualiser ou Modifier</f:facet>
33 <h:link outcome="view">Visualiser ou Modifier Version 39 <h:link outcome="view">Visualiser ou Modifier Version
...@@ -36,14 +42,21 @@ ...@@ -36,14 +42,21 @@
36 </h:column> 42 </h:column>
37 <h:column rendered="#{listPublisherRevisionsView.viewAll}"> 43 <h:column rendered="#{listPublisherRevisionsView.viewAll}">
38 <f:facet name="header">Editeur</f:facet> 44 <f:facet name="header">Editeur</f:facet>
39 - <h:link outcome="/listPublisherRevisions"> 45 + <h:link outcome="listPublisherRevisions">
40 - #{revision.publisher.publisherId} 46 + Visualiser ou valider version éditeur
41 <f:param name="publisherId" value="#{revision.publisher.publisherId}"/> 47 <f:param name="publisherId" value="#{revision.publisher.publisherId}"/>
42 </h:link> 48 </h:link>
43 </h:column> 49 </h:column>
44 - <h:column rendered="#{not listPublisherRevisionsView.viewAll}"> 50 + <h:column>
45 <f:facet name="header">Valide</f:facet> 51 <f:facet name="header">Valide</f:facet>
46 - #{revision.publisherRevisionId == revision.publisher.activeRevision} 52 + <h:outputText rendered="#{revision.publisherRevisionId == revision.publisher.validatedRevision.publisherRevisionId}">Validé</h:outputText>
53 + <h:outputText rendered="#{listPublisherRevisionsView.viewAll and revision.publisherRevisionId != revision.publisher.validatedRevision.publisherRevisionId}">Non validé</h:outputText>
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 + <h:form rendered="#{not listPublisherRevisionsView.viewAll and revision.publisherRevisionId != revision.publisher.validatedRevision.publisherRevisionId}">
56 + <h:commandButton action="#{listPublisherRevisionsView.validate()}" value="Valider">
57 + <f:param name="publisherRevisionId" value="#{revision.publisherRevisionId}"/>
58 + </h:commandButton>
59 + </h:form>
47 </h:column> 60 </h:column>
48 <h:column> 61 <h:column>
49 <f:facet name="header">Name</f:facet> 62 <f:facet name="header">Name</f:facet>
......
...@@ -18,14 +18,10 @@ ...@@ -18,14 +18,10 @@
18 <h:form> 18 <h:form>
19 <ul> 19 <ul>
20 <li> 20 <li>
21 - <h:link outcome="/index"> 21 + <a jsf:outcome="/index">Menu principal</a>
22 - <h:outputText value="Menu principal"/>
23 - </h:link>
24 </li> 22 </li>
25 <li> 23 <li>
26 - <h:link outcome="/listPublisherRevisions"> 24 + <a jsf:outcome="listPublisherRevisions">Versions des éditeurs</a>
27 - <h:outputText value="Versions des éditeurs"/>
28 - </h:link>
29 </li> 25 </li>
30 </ul> 26 </ul>
31 27
......
1 package org.legrog.web.xyz; 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 + User getCurrentUser();
22 } 20 }
...\ No newline at end of file ...\ No newline at end of file
......
1 package org.legrog.web.xyz; 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 User getCurrentUser() {
56 + // TODO Remplacer l'astuce par une vraie récupération de l'utilisateur
57 + List<User> users = userService.getAllUsers();
58 + Random random = new Random();
59 + User user = users.get(random.nextInt(users.size()));
60 + // End TODO
61 + return user;
62 + }
50 } 63 }
......
...@@ -31,9 +31,9 @@ INSERT INTO PublisherRevision (publisher_PUBLISHER_ID, publisherName, publisherS ...@@ -31,9 +31,9 @@ INSERT INTO PublisherRevision (publisher_PUBLISHER_ID, publisherName, publisherS
31 (3, 'La Vouivre', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'la-vouivre.com', TRUE, 'Ouvert…', 1, {ts '2000-01-01 00:02:33'}), 31 (3, 'La Vouivre', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'la-vouivre.com', TRUE, 'Ouvert…', 1, {ts '2000-01-01 00:02:33'}),
32 (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'}), 32 (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'}),
33 (4, 'Archmagus', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'archimage.net', TRUE, 'Ouvert…', 4, {ts '2016-10-14 10:56:03'}); 33 (4, 'Archmagus', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'archimage.net', TRUE, 'Ouvert…', 4, {ts '2016-10-14 10:56:03'});
34 -UPDATE Publisher SET (activeRevision_PUBLISHER_REVISION_ID, activeValidator_USER_ID, validationDateTime) VALUES (1, 2, {ts '2000-05-08 12:00:28'}) WHERE PUBLISHER_ID = 1; 34 +UPDATE Publisher SET validatedRevision_PUBLISHER_REVISION_ID = 1, validator_USER_ID = 2, validationDateTime = {ts '2000-05-08 12:00:28'} WHERE PUBLISHER_ID = 1;
35 -UPDATE Publisher SET (activeRevision_PUBLISHER_REVISION_ID, activeValidator_USER_ID, validationDateTime) VALUES (2, 1, TIMESTAMP '2010-06-20 14:27:35') WHERE PUBLISHER_ID = 2; 35 +UPDATE Publisher SET validatedRevision_PUBLISHER_REVISION_ID = 2, validator_USER_ID = 1, validationDateTime = {ts '2010-06-20 14:27:35'} WHERE PUBLISHER_ID = 2;
36 -UPDATE Publisher SET (activeRevision_PUBLISHER_REVISION_ID, activeValidator_USER_ID, validationDateTime) VALUES (4, 1, TIMESTAMP '2015-01-01 16:18:17') WHERE PUBLISHER_ID = 3; 36 +UPDATE Publisher SET validatedRevision_PUBLISHER_REVISION_ID = 4, validator_USER_ID = 1, validationDateTime = {ts '2015-01-01 16:18:17'} WHERE PUBLISHER_ID = 3;
37 37
38 INSERT INTO UserRole VALUES (1, 'VISITEUR', TRUE); 38 INSERT INTO UserRole VALUES (1, 'VISITEUR', TRUE);
39 INSERT INTO UserRole VALUES (2, 'RECRUE', TRUE); 39 INSERT INTO UserRole VALUES (2, 'RECRUE', TRUE);
......
...@@ -41,13 +41,6 @@ ...@@ -41,13 +41,6 @@
41 </navigation-case> 41 </navigation-case>
42 </navigation-rule> 42 </navigation-rule>
43 <navigation-rule> 43 <navigation-rule>
44 - <from-view-id>/publisher/addPublisher.xhtml</from-view-id>
45 - <navigation-case>
46 - <from-outcome>success</from-outcome>
47 - <to-view-id>/publisher/listPublisherRevisions.xhtml</to-view-id>
48 - </navigation-case>
49 - </navigation-rule>
50 - <navigation-rule>
51 <from-view-id>/xyz/addCountry.xhtml</from-view-id> 44 <from-view-id>/xyz/addCountry.xhtml</from-view-id>
52 <navigation-case> 45 <navigation-case>
53 <from-outcome>success</from-outcome> 46 <from-outcome>success</from-outcome>
......
...@@ -3,52 +3,17 @@ ...@@ -3,52 +3,17 @@
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:h="http://xmlns.jcp.org/jsf/html"
6 + xmlns:jsf="http://xmlns.jcp.org/jsf"
6 xmlns:ui="http://xmlns.jcp.org/jsf/facelets" 7 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
7 xmlns:f="http://xmlns.jcp.org/jsf/core"> 8 xmlns:f="http://xmlns.jcp.org/jsf/core">
8 <body> 9 <body>
9 -<h:form>
10 <ul> 10 <ul>
11 <li> 11 <li>
12 - <h:commandLink action="addBook"> 12 + <a jsf:outcome="publisher/publisherRevision">Ajouter un éditeur</a>
13 - <h:outputText value="Add book"/>
14 - </h:commandLink>
15 </li> 13 </li>
16 <li> 14 <li>
17 - <h:commandLink action="listBooks"> 15 + <a jsf:outcome="publisher/listPublisherRevisions">Liste des versions des éditeurs</a>
18 - <h:outputText value="List books"/>
19 - </h:commandLink>
20 - </li>
21 - <li>
22 - <h:commandLink action="addCountry">
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:link outcome="/publisherRevision">
43 - <h:outputText value="Ajouter un éditeur"/>
44 - </h:link>
45 - </li>
46 - <li>
47 - <h:link outcome="/listPublisherRevisions">
48 - <h:outputText value="Liste des versions des éditeurs"/>
49 - </h:link>
50 </li> 16 </li>
51 </ul> 17 </ul>
52 -</h:form>
53 </body> 18 </body>
54 </html> 19 </html>
......