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 ListPublisherRevisionsView { 24 public class ListPublisherRevisionsView {
...@@ -28,10 +33,6 @@ public class ListPublisherRevisionsView { ...@@ -28,10 +33,6 @@ public class ListPublisherRevisionsView {
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 ListPublisherRevisionsView { ...@@ -64,16 +65,20 @@ public class ListPublisherRevisionsView {
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 }
......
...@@ -16,6 +16,12 @@ import java.io.Serializable; ...@@ -16,6 +16,12 @@ import java.io.Serializable;
16 import java.sql.Timestamp; 16 import java.sql.Timestamp;
17 import java.util.List; 17 import java.util.List;
18 18
19 +/*
20 + Vue de publisherRevision.xhtml
21 + Permet la création, l'affichage et la modification d'une version d'éditeur.
22 + La création d'une version crée l'éditeur et sa version initiale.
23 + Le modification crée une nouvelle version liée à l'éditeur.
24 + */
19 @Named 25 @Named
20 @ViewScoped 26 @ViewScoped
21 public class PublisherRevisionView implements Serializable { 27 public class PublisherRevisionView implements Serializable {
...@@ -29,7 +35,6 @@ public class PublisherRevisionView implements Serializable { ...@@ -29,7 +35,6 @@ public class PublisherRevisionView implements Serializable {
29 private boolean editMode; 35 private boolean editMode;
30 private boolean newPublisher; 36 private boolean newPublisher;
31 37
32 - // Données temporaires d'un PublisherRevision
33 private int publisherRevisionId; 38 private int publisherRevisionId;
34 private String publisherName; 39 private String publisherName;
35 private String publisherStreetAddress; 40 private String publisherStreetAddress;
...@@ -47,7 +52,6 @@ public class PublisherRevisionView implements Serializable { ...@@ -47,7 +52,6 @@ public class PublisherRevisionView implements Serializable {
47 private Timestamp publisherRevisionDatetime; 52 private Timestamp publisherRevisionDatetime;
48 private Publisher publisher; 53 private Publisher publisher;
49 54
50 - // Table de codification
51 private List<Country> availableCountries; 55 private List<Country> availableCountries;
52 56
53 @PostConstruct 57 @PostConstruct
...@@ -63,10 +67,6 @@ public class PublisherRevisionView implements Serializable { ...@@ -63,10 +67,6 @@ public class PublisherRevisionView implements Serializable {
63 editMode = false; 67 editMode = false;
64 } 68 }
65 69
66 - public boolean isEditMode() {
67 - return editMode;
68 - }
69 -
70 public void save() { 70 public void save() {
71 logger.debug("save()"); 71 logger.debug("save()");
72 if (newPublisher) { 72 if (newPublisher) {
...@@ -93,6 +93,14 @@ public class PublisherRevisionView implements Serializable { ...@@ -93,6 +93,14 @@ public class PublisherRevisionView implements Serializable {
93 publisherRevision.setPublisherURL(publisherURL); 93 publisherRevision.setPublisherURL(publisherURL);
94 } 94 }
95 95
96 + private void getImmutableValues() {
97 + PublisherRevision publisherRevision;
98 +
99 + publisherRevision = publisherService.getPublisherRevision(publisherRevisionId);
100 + publisherRevisionAuthor = publisherRevision.getPublisherRevisionAuthor();
101 + publisherRevisionDatetime = publisherRevision.getPublisherRevisionDatetime();
102 + }
103 +
96 public void add() { 104 public void add() {
97 Publisher publisher = new Publisher(); 105 Publisher publisher = new Publisher();
98 PublisherRevision publisherRevision = new PublisherRevision(); 106 PublisherRevision publisherRevision = new PublisherRevision();
...@@ -103,8 +111,9 @@ public class PublisherRevisionView implements Serializable { ...@@ -103,8 +111,9 @@ public class PublisherRevisionView implements Serializable {
103 newPublisher = false; 111 newPublisher = false;
104 publisherRevisionId = publisherRevision.getPublisherRevisionId(); 112 publisherRevisionId = publisherRevision.getPublisherRevisionId();
105 this.publisher = publisher; 113 this.publisher = publisher;
106 - publisherRevisionAuthor = publisherRevision.getPublisherRevisionAuthor(); 114 +
107 - publisherRevisionDatetime = publisherRevision.getPublisherRevisionDatetime(); 115 + getImmutableValues();
116 +
108 editMode = false; 117 editMode = false;
109 } 118 }
110 119
...@@ -114,6 +123,10 @@ public class PublisherRevisionView implements Serializable { ...@@ -114,6 +123,10 @@ public class PublisherRevisionView implements Serializable {
114 123
115 publisherService.addRevisionToPublisher(publisher, publisherRevision); 124 publisherService.addRevisionToPublisher(publisher, publisherRevision);
116 125
126 + publisherRevisionId = publisherRevision.getPublisherRevisionId();
127 +
128 + getImmutableValues();
129 +
117 editMode = false; 130 editMode = false;
118 } 131 }
119 132
...@@ -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 }
287 -} 300 +
301 + public boolean isEditMode() {
302 + return editMode;
303 + }
304 +
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
......