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/83 Ajouter les commentaires de début de classe
classes contenues dans src/main/java/org/legrog/web/publisher/
...@@ -14,6 +14,11 @@ import java.util.ArrayList; ...@@ -14,6 +14,11 @@ import java.util.ArrayList;
14 import java.util.List; 14 import java.util.List;
15 import java.util.Map; 15 import java.util.Map;
16 16
17 +/*
18 + Vue de listPublisherRevisions.xhtml
19 + Permet de voir l'ensemble des versions des éditeurs.
20 + Permet de voir l'ensemble des versions d'un éditeur et de valider l'une d'elles.
21 + */
17 @Named 22 @Named
18 @RequestScoped 23 @RequestScoped
19 public class ListPublisherRevisionsBean { 24 public class ListPublisherRevisionsBean {
...@@ -28,10 +33,6 @@ public class ListPublisherRevisionsBean { ...@@ -28,10 +33,6 @@ public class ListPublisherRevisionsBean {
28 33
29 private List<PublisherRevision> publisherRevisions; 34 private List<PublisherRevision> publisherRevisions;
30 35
31 - public List<PublisherRevision> getPublisherRevisions() {
32 - return publisherRevisions;
33 - }
34 -
35 public void validate() { 36 public void validate() {
36 logger.debug("validate"); 37 logger.debug("validate");
37 Publisher publisher = publisherService.getPublisher(publisherId); 38 Publisher publisher = publisherService.getPublisher(publisherId);
...@@ -64,16 +65,20 @@ public class ListPublisherRevisionsBean { ...@@ -64,16 +65,20 @@ public class ListPublisherRevisionsBean {
64 } 65 }
65 66
66 public void setView() { 67 public void setView() {
67 - logger.info("setView"); 68 + logger.debug("setView");
68 - logger.info("publisherId = " + publisherId); 69 + logger.debug("publisherId = " + publisherId);
69 viewAll = ( publisherId == null ) ; 70 viewAll = ( publisherId == null ) ;
70 if (!viewAll) { 71 if (!viewAll) {
71 - logger.info("!viewAll"); 72 + logger.debug("!viewAll");
72 publisherRevisions = filter(); 73 publisherRevisions = filter();
73 } 74 }
74 } 75 }
75 76
76 // get, set et is 77 // get, set et is
78 + public List<PublisherRevision> getPublisherRevisions() {
79 + return publisherRevisions;
80 + }
81 +
77 public Integer getPublisherId() { 82 public Integer getPublisherId() {
78 return publisherId; 83 return publisherId;
79 } 84 }
......
...@@ -17,6 +17,12 @@ import java.io.Serializable; ...@@ -17,6 +17,12 @@ import java.io.Serializable;
17 import java.sql.Timestamp; 17 import java.sql.Timestamp;
18 import java.util.List; 18 import java.util.List;
19 19
20 +/*
21 + Vue de publisherRevision.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 + */
20 @Named 26 @Named
21 @ViewScoped 27 @ViewScoped
22 public class PublisherRevisionView implements Serializable { 28 public class PublisherRevisionView implements Serializable {
...@@ -30,7 +36,6 @@ public class PublisherRevisionView implements Serializable { ...@@ -30,7 +36,6 @@ public class PublisherRevisionView implements Serializable {
30 private boolean editMode; 36 private boolean editMode;
31 private boolean newPublisher; 37 private boolean newPublisher;
32 38
33 - // Données temporaires d'un PublisherRevision
34 private int publisherRevisionId; 39 private int publisherRevisionId;
35 private String publisherName; 40 private String publisherName;
36 private String publisherStreetAddress; 41 private String publisherStreetAddress;
...@@ -48,7 +53,6 @@ public class PublisherRevisionView implements Serializable { ...@@ -48,7 +53,6 @@ public class PublisherRevisionView implements Serializable {
48 private Timestamp publisherRevisionDatetime; 53 private Timestamp publisherRevisionDatetime;
49 private Publisher publisher; 54 private Publisher publisher;
50 55
51 - // Table de codification
52 private List<Country> availableCountries; 56 private List<Country> availableCountries;
53 57
54 @PostConstruct 58 @PostConstruct
...@@ -64,10 +68,6 @@ public class PublisherRevisionView implements Serializable { ...@@ -64,10 +68,6 @@ public class PublisherRevisionView implements Serializable {
64 editMode = false; 68 editMode = false;
65 } 69 }
66 70
67 - public boolean isEditMode() {
68 - return editMode;
69 - }
70 -
71 public void save() { 71 public void save() {
72 logger.debug("save()"); 72 logger.debug("save()");
73 if (newPublisher) { 73 if (newPublisher) {
...@@ -94,6 +94,14 @@ public class PublisherRevisionView implements Serializable { ...@@ -94,6 +94,14 @@ public class PublisherRevisionView implements Serializable {
94 publisherRevision.setPublisherURL(publisherURL); 94 publisherRevision.setPublisherURL(publisherURL);
95 } 95 }
96 96
97 + private void getImmutableValues() {
98 + PublisherRevision publisherRevision;
99 +
100 + publisherRevision = publisherService.getPublisherRevision(publisherRevisionId);
101 + publisherRevisionAuthor = publisherRevision.getPublisherRevisionAuthor();
102 + publisherRevisionDatetime = publisherRevision.getPublisherRevisionDatetime();
103 + }
104 +
97 public void add() { 105 public void add() {
98 Publisher publisher = new Publisher(); 106 Publisher publisher = new Publisher();
99 PublisherRevision publisherRevision = new PublisherRevision(); 107 PublisherRevision publisherRevision = new PublisherRevision();
...@@ -104,8 +112,9 @@ public class PublisherRevisionView implements Serializable { ...@@ -104,8 +112,9 @@ public class PublisherRevisionView implements Serializable {
104 newPublisher = false; 112 newPublisher = false;
105 publisherRevisionId = publisherRevision.getPublisherRevisionId(); 113 publisherRevisionId = publisherRevision.getPublisherRevisionId();
106 this.publisher = publisher; 114 this.publisher = publisher;
107 - publisherRevisionAuthor = publisherRevision.getPublisherRevisionAuthor(); 115 +
108 - publisherRevisionDatetime = publisherRevision.getPublisherRevisionDatetime(); 116 + getImmutableValues();
117 +
109 editMode = false; 118 editMode = false;
110 } 119 }
111 120
...@@ -115,6 +124,10 @@ public class PublisherRevisionView implements Serializable { ...@@ -115,6 +124,10 @@ public class PublisherRevisionView implements Serializable {
115 124
116 publisherService.addRevisionToPublisher(publisher, publisherRevision); 125 publisherService.addRevisionToPublisher(publisher, publisherRevision);
117 126
127 + publisherRevisionId = publisherRevision.getPublisherRevisionId();
128 +
129 + getImmutableValues();
130 +
118 editMode = false; 131 editMode = false;
119 } 132 }
120 133
...@@ -138,10 +151,10 @@ public class PublisherRevisionView implements Serializable { ...@@ -138,10 +151,10 @@ public class PublisherRevisionView implements Serializable {
138 publisherURL = publisherRevision.getPublisherURL(); 151 publisherURL = publisherRevision.getPublisherURL();
139 publisherActive = publisherRevision.isPublisherActive(); 152 publisherActive = publisherRevision.isPublisherActive();
140 publisherHistory = publisherRevision.getPublisherHistory(); 153 publisherHistory = publisherRevision.getPublisherHistory();
141 - publisherRevisionAuthor = publisherRevision.getPublisherRevisionAuthor();
142 - publisherRevisionDatetime = publisherRevision.getPublisherRevisionDatetime();
143 publisher = publisherRevision.getPublisher(); 154 publisher = publisherRevision.getPublisher();
144 155
156 + getImmutableValues();
157 +
145 logger.debug("Found a publisher : {}", publisher.toString()); 158 logger.debug("Found a publisher : {}", publisher.toString());
146 newPublisher = false; 159 newPublisher = false;
147 } else { 160 } else {
...@@ -284,4 +297,9 @@ public class PublisherRevisionView implements Serializable { ...@@ -284,4 +297,9 @@ public class PublisherRevisionView implements Serializable {
284 public boolean isNewPublisher() { 297 public boolean isNewPublisher() {
285 return newPublisher; 298 return newPublisher;
286 } 299 }
300 +
301 + public boolean isEditMode() {
302 + return editMode;
303 + }
304 +
287 } 305 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -5,15 +5,17 @@ import org.legrog.entities.PublisherRevision; ...@@ -5,15 +5,17 @@ import org.legrog.entities.PublisherRevision;
5 5
6 import java.util.List; 6 import java.util.List;
7 7
8 +/*
9 + Interface correspondant à la gestion des éditeurs et de leurs versions.
10 + Contient des signatures méthodes d'ajout, de modification et de validation de version ainsi que de restitution.
11 + */
8 public interface PublisherService { 12 public interface PublisherService {
9 13
10 void addPublisherWithRevision(Publisher publisher, PublisherRevision publisherRevision); 14 void addPublisherWithRevision(Publisher publisher, PublisherRevision publisherRevision);
11 15
12 - void validatePublisherRevision(Publisher publisher, Integer publisherRevisionId);
13 -
14 void addRevisionToPublisher(Publisher publisher, PublisherRevision publisherRevision); 16 void addRevisionToPublisher(Publisher publisher, PublisherRevision publisherRevision);
15 17
16 -// List<Publisher> getAllPublishers(); 18 + void validatePublisherRevision(Publisher publisher, Integer publisherRevisionId);
17 19
18 Publisher getPublisher(Integer publisherId); 20 Publisher getPublisher(Integer publisherId);
19 21
......
1 package org.legrog.web.publisher; 1 package org.legrog.web.publisher;
2 2
3 3
4 -import org.legrog.entities.*; 4 +import org.legrog.entities.Publisher;
5 +import org.legrog.entities.PublisherRepository;
6 +import org.legrog.entities.PublisherRevision;
7 +import org.legrog.entities.PublisherRevisionRepository;
5 import org.legrog.web.xyz.SharedService; 8 import org.legrog.web.xyz.SharedService;
6 9
7 import javax.ejb.Stateless; 10 import javax.ejb.Stateless;
...@@ -12,6 +15,10 @@ import java.util.HashSet; ...@@ -12,6 +15,10 @@ import java.util.HashSet;
12 import java.util.List; 15 import java.util.List;
13 import java.util.Set; 16 import java.util.Set;
14 17
18 +/*
19 + Implémentation de l'interface PublisherService
20 + */
21 +
15 @Stateless 22 @Stateless
16 public class PublisherServiceSpring implements PublisherService { 23 public class PublisherServiceSpring implements PublisherService {
17 @Inject 24 @Inject
...@@ -72,9 +79,5 @@ public class PublisherServiceSpring implements PublisherService { ...@@ -72,9 +79,5 @@ public class PublisherServiceSpring implements PublisherService {
72 public Publisher getPublisher(Integer publisherId) { 79 public Publisher getPublisher(Integer publisherId) {
73 return publisherRepository.findOne(publisherId); 80 return publisherRepository.findOne(publisherId);
74 } 81 }
75 -/* 82 +
76 - public List<Publisher> getAllPublishers() {
77 - return publisherRepository.findAll();
78 - }
79 - */
80 } 83 }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 </head> 14 </head>
15 <body> 15 <body>
16 16
17 -<form jsf:id="publisherRevisionView" action=""> 17 +<h:form>
18 <ul> 18 <ul>
19 <li> 19 <li>
20 <a jsf:outcome="/index">Menu principal</a> 20 <a jsf:outcome="/index">Menu principal</a>
...@@ -65,6 +65,6 @@ ...@@ -65,6 +65,6 @@
65 <button jsf:rendered="#{publisherRevisionView.editMode}" jsf:action="#{publisherRevisionView.save}">Save</button> 65 <button jsf:rendered="#{publisherRevisionView.editMode}" jsf:action="#{publisherRevisionView.save}">Save</button>
66 <button jsf:rendered="#{publisherRevisionView.editMode}" jsf:action="#{publisherRevisionView.cancel}">Cancel</button> 66 <button jsf:rendered="#{publisherRevisionView.editMode}" jsf:action="#{publisherRevisionView.cancel}">Cancel</button>
67 </h:panelGrid> 67 </h:panelGrid>
68 -</form> 68 +</h:form>
69 </body> 69 </body>
70 </html> 70 </html>
...\ No newline at end of file ...\ No newline at end of file
......